include	clib.inc

conventional	= 0
expanded	= 1
emmpage		= 4000h

S_EMM		STRUC
dlength		dd ? ; region length in bytes
src_type	db ? ; source memory type
src_handle	dw ? ; 0000h if conventional memory
src_off		dw ? ; within page if EMS, segment if convent
src_seg		dw ? ; segment or logical page (EMS)
des_type	db ? ; destination memory type
des_handle	dw ? ;
des_off		dw ? ; in page
des_seg		dw ? ; or page
S_EMM		ENDS

PPROC	emmread, dest:DPTR, emhnd:word, wpage:word
local	emm:S_EMM
	push	si
	mov	word ptr emm.dlength+2,0
	mov	word ptr emm.dlength,emmpage
	mov	emm.des_type,conventional
	mov	emm.des_handle,0
  ifdef LDATA
	mov	ax,word ptr [dest]
	mov	emm.des_off,ax
	mov	ax,word ptr [dest+2]
	mov	emm.des_seg,ax
  else
	mov	emm.des_off,dest
	mov	emm.des_seg,ds
  endif
	mov	emm.src_type,expanded
	mov	ax,emhnd
	mov	emm.src_handle,ax
	mov	emm.src_off,0
	mov	ax,wpage
	mov	emm.src_seg,ax
	mov	ax,5700h
	lea	si,emm
	int	67h
	mov	al,ah
	mov	ah,0
	pop	si
	ret
PEND	emmread

	end
