include	clib.inc
include	io.inc

PPROC	readword, file_name:DWORD
local	result_dx:WORD
local	result_ax:WORD
	xor	ax,ax
	mov	result_ax,ax
	mov	result_dx,ax
	pushm	file_name
	push	_A_ARCH
	push	M_RDONLY
	push	A_OPEN
	call	osopen
	cmp	ax,-1
	je	readword_error
	push	ax
	push	ax
	push	ss
	lea	ax,result_ax
	push	ax
	push	4
	call	osread
	pop	dx
	push	ax
	push	dx
	call	close
	pop	ax
	test	ax,ax
    readword_error:
	mov	ax,result_ax
	mov	dx,result_dx
    readword_end:
	ret
PEND	readword

	END
