www.pudn.com > fxvmm210.zip > _FXEMM.ASM


;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
; 
; Expanded Memory manipulation procedures 
; 
 
	TITLE	FXEMM 
	.386p 
	.387 
 
FXEMM_TEXT	SEGMENT	BYTE public USE16 'CODE' 
FXEMM_TEXT	ENDS 
 
_DATA	SEGMENT	WORD public USE16 'DATA' 
_DATA	ENDS 
_BSS	SEGMENT	WORD public USE16 'BSS' 
_BSS	ENDS 
 
DGROUP	GROUP	_DATA, _BSS 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
include ..\source.asm\_fxvmm.inc 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
	extrn		_movedata:NEAR 
	extrn		_fxvmm_global_ems_handle:WORD 
	extrn		F_LXURSH@:NEAR 
	extrn		F_LDIV@:NEAR 
	extrn		F_LMOD@:NEAR 
	extrn		F_LXLSH@:NEAR 
	extrn		F_PADA@:NEAR 
	extrn		F_PADD@:NEAR 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
	public		__fxvmm_emm_exist 
	public		__fxvmm_emm_address 
	public		__fxvmm_emm_free_handle 
	public		__fxvmm_emm_handle_numpages 
	public		__fxvmm_emm_map_handle 
	public		__fxvmm_emm_close 
	public		__fxvmm_emm_alloc_handle 
	public		__fxvmm_emm_init_handle 
	public		__fxvmm_ems_handle_absread 
	public		__fxvmm_ems_handle_abswrite 
	public		__fxvmm_ems_handle_free 
	public		__fxvmm_ems_handle_alloc 
	public		__fxvmm_ems_handle_deinit 
 
	public		_fxvmm_local_ems_handle 
	public		_fxvmm_strat_ems_handle 
 
	public		_fxvmm_emm_segment 
	public		_fxvmm_emm_swaphandle 
	public		_fxvmm_emm_pointer 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
FXEMM_TEXT	SEGMENT 
	assume	cs: FXEMM_TEXT 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_exist: 
	push	bp 
	mov	bp,sp 
	sub	sp,+008h 
	mov	word ptr [bp-006h],0000h 
	mov	word ptr [bp-008h],019Eh 
	les	bx,dword ptr [bp-008h] 
	mov	ax,es:[bx] 
	mov	[bp-002h],ax 
	mov	word ptr [bp-004h],000Ah 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx],45h 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+001h],4Dh 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+002h],4Dh 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+003h],58h 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+004h],58h 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+005h],58h 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+006h],58h 
	jnz	@@L1 
	les	bx,dword ptr [bp-004h] 
	cmp	byte ptr es:[bx+007h],30h 
	jnz	@@L1 
	mov	ax,0001h 
	jmp	short @@L2 
@@L1:	xor	ax,ax 
@@L2:	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_address: 
	push	bp 
	mov	bp,sp 
	sub	sp,+004h 
	mov	ah,41h 
	int	67h 
	mov	[bp-001h],ah 
	mov	[bp-004h],bx 
	cmp	byte ptr [bp-001h],00h 
	jz	@@L3 
	xor	ax,ax 
	jmp	short @@L4 
@@L3:	mov	ax,[bp-004h] 
@@L4:	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_free_handle: 
	push	bp 
	mov	bp,sp 
	mov	ah,45h 
	mov	dx,[bp+006h] 
	int	67h 
	mov	ax,0001h 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_handle_numpages: 
	push	bp 
	mov	bp,sp 
	sub	sp,+002h 
	mov	ah,42h 
	int	67h 
	mov	[bp-002h],bx 
	mov	ax,[bp-002h] 
	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_map_handle: 
	push	bp 
	mov	bp,sp 
	mov	ah,44h 
	mov	al,[bp+00Ah] 
	mov	bx,[bp+008h] 
	mov	dx,[bp+006h] 
	int	67h 
	mov	ax,0001h 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_close: 
	push	bp 
	mov	bp,sp 
	assume	ds: DGROUP 
	cmp	word ptr _fxvmm_emm_tmpoff,+000h 
	jz	@@L6 
	mov	ah,48h 
	mov	dx,_fxvmm_emm_tmpoff 
	int	67h 
	push	_fxvmm_emm_tmpoff 
	push	cs 
	call	near ptr __fxvmm_emm_free_handle 
	add	sp,+002h 
	mov	word ptr _fxvmm_emm_tmpoff,0000h 
@@L6:	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_alloc_handle: 
	push	bp 
	mov	bp,sp 
	sub	sp,+006h 
	push	si 
	mov	dx,[bp+00Ch] 
	mov	ax,[bp+00Ah] 
	mov	cl,04h 
	call	far ptr F_LXURSH@ 
	push	ax 
	mov	ax,[bp+00Ah] 
	and	ax,000Fh 
	or	ax,0000h 
	jz	@@L7 
	mov	ax,0001h 
	jmp	short @@L8 
@@L7:	xor	ax,ax 
@@L8:	pop	dx 
	add	dx,ax 
	mov	si,dx 
	xor	ax,ax 
	mov	dx,0400h 
	push	ax 
	push	dx 
	xor	ax,ax 
	push	ax 
	push	si 
	call	far ptr F_LDIV@ 
	push	ax 
	xor	ax,ax 
	mov	dx,0400h 
	push	ax 
	push	dx 
	xor	ax,ax 
	push	ax 
	push	si 
	call	far ptr F_LMOD@ 
	or	ax,dx 
	jz	@@L9 
	mov	ax,0001h 
	jmp	short @@L10 
@@L9:	xor	ax,ax 
@@L10:	pop	dx 
	add	dx,ax 
	mov	[bp-002h],dx 
	cmp	word ptr _fxvmm_emm_swaphandle,+000h 
	jnz	@@L11 
	call	far ptr FXEMM_TEXT:__fxvmm_emm_init_handle 
@@L11:	cmp	word ptr _fxvmm_emm_swaphandle,+000h 
	jz	@@L12 
	mov	ah,43h 
	mov	bx,[bp-002h] 
	int	67h 
	mov	[bp-003h],ah 
	mov	[bp-006h],dx 
	cmp	byte ptr [bp-003h],00h 
	jz	@@L13 
	xor	dx,dx 
	xor	ax,ax 
	pop	si 
	mov	sp,bp 
	pop	bp 
	retf 
@@L13:	les	bx,dword ptr [bp+006h] 
	mov	ax,[bp-006h] 
	mov	es:[bx],ax 
	mov	ax,[bp-002h] 
	xor	dx,dx 
	mov	cl,0Ah 
	call	far ptr F_LXLSH@ 
	mov	cl,04h 
	call	far ptr F_LXLSH@ 
	pop	si 
	mov	sp,bp 
	pop	bp 
	retf 
@@L12:	xor	dx,dx 
	xor	ax,ax 
	pop	si 
	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_emm_init_handle: 
	push	bp 
	mov	bp,sp 
	push	cs 
	call	__fxvmm_emm_exist 
	mov	_fxvmm_emm_swaphandle,ax 
	or	ax,ax 
	jz	@@L14 
	push	cs 
	call	__fxvmm_emm_address 
	mov	_fxvmm_emm_segment,ax 
	mov	ax,_fxvmm_emm_segment 
	mov	_fxvmm_emm_lowpointer,ax 
	mov	word ptr _fxvmm_emm_pointer,0000h 
	mov	ah,43h 
	mov	bx,0001h 
	int	67h 
	mov	_fxvmm_emm_tmpoff,dx 
	mov	ah,47h 
	mov	dx,_fxvmm_emm_tmpoff 
	int	67h 
@@L14:	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_ems_handle_absread: 
	push	bp 
	mov	bp,sp 
	sub	sp,+00Ch 
	push	si 
	xor	si,si 
	mov	ax,_fxvmm_emm_lowpointer 
	mov	dx,_fxvmm_emm_pointer 
	mov	[bp-002h],ax 
	mov	[bp-004h],dx 
	mov	ax,[bp+008h] 
	mov	dx,[bp+006h] 
	mov	[bp-00Ah],ax 
	mov	[bp-00Ch],dx 
	les	bx,dword ptr [bp+00Ah] 
	mov	ax,es:[bx+019h] 
	mov	dx,es:[bx+017h] 
	add	[bp+00Eh],dx 
	adc	[bp+010h],ax 
	jmp	short @@L16 
@@L17:	inc	si 
	sub	word ptr [bp+00Eh],4000h 
	sbb	word ptr [bp+010h],+000h 
@@L16:	cmp	word ptr [bp+010h],+000h 
	jnbe	@@L17 
	jnz	@@L18 
	cmp	word ptr [bp+00Eh],4000h 
	jnbe	@@L17 
@@L18:	mov	al,00h 
	push	ax 
	push	si 
	les	bx,dword ptr [bp+00Ah] 
	push    word ptr es:[bx+013h] 
	push	cs 
	call	__fxvmm_emm_map_handle 
	add	sp,+006h 
	mov	ax,[bp-002h] 
	mov	dx,[bp-004h] 
	add	dx,[bp+00Eh] 
	mov	[bp-006h],ax 
	mov	[bp-008h],dx 
	cmp	word ptr [bp+014h],+000h 
	jnbe	@@L19 
	jc	@@L20 
	cmp	word ptr [bp+012h],4000h 
	jnc	@@L19 
@@L20:	mov	ax,[bp+012h] 
	jmp	short @@L21 
@@L19:	mov	ax,4000h 
@@L21:	push	ax 
	push    word ptr [bp-00Ch] 
	push    word ptr [bp-00Ah] 
	push    word ptr [bp-008h] 
	push    word ptr [bp-006h] 
	call	far ptr _movedata 
	add	sp,+00Ah 
	cmp	word ptr [bp+014h],+000h 
	jnbe	@@L22 
	jc	@@L23 
	cmp	word ptr [bp+012h],4000h 
	jc	@@L23 
@@L22:	mov	word ptr [bp+010h],0000h 
	mov	word ptr [bp+00Eh],0000h 
	sub	word ptr [bp+012h],4000h 
	sbb	word ptr [bp+014h],+000h 
	xor	cx,cx 
	mov	bx,4000h 
	mov	dx,ss 
	lea	ax,[bp-00Ch] 
	call	far ptr F_PADA@ 
	inc	si 
	jmp	@@L18 
@@L23:	mov	ax,[bp+010h] 
	mov	dx,[bp+00Eh] 
	add	dx,[bp+012h] 
	adc	ax,[bp+014h] 
	les	bx,dword ptr [bp+00Ah] 
	push	dx 
	mov	es:[bx+009h],ax 
	mov	dx,ax 
	pop	ax 
	mov	es:[bx+007h],ax 
	pop	si 
	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_ems_handle_abswrite: 
	push	bp 
	mov	bp,sp 
	sub	sp,+00Ch 
	push	si 
	xor	si,si 
	mov	ax,[bp+010h] 
	mov	dx,[bp+00Eh] 
	mov	[bp-002h],ax 
	mov	[bp-004h],dx 
	mov	ax,_fxvmm_emm_lowpointer 
	mov	dx,_fxvmm_emm_pointer 
	mov	[bp-00Ah],ax 
	mov	[bp-00Ch],dx 
	les	bx,dword ptr [bp+006h] 
	mov	ax,es:[bx+019h] 
	mov	dx,es:[bx+017h] 
	add	[bp+00Ah],dx 
	adc	[bp+00Ch],ax 
	jmp	short @@L24 
@@L25:	inc	si 
	sub	word ptr [bp+00Ah],4000h 
	sbb	word ptr [bp+00Ch],+000h 
@@L24:	cmp	word ptr [bp+00Ch],+000h 
	jnbe	@@L25 
	jnz	@@L26 
	cmp	word ptr [bp+00Ah],4000h 
	jnbe	@@L25 
@@L26:	mov	al,00h 
	push	ax 
	push	si 
	les	bx,dword ptr [bp+006h] 
	push	word ptr es:[bx+013h] 
	push	cs 
	call	__fxvmm_emm_map_handle 
	add	sp,+006h 
	mov	dx,[bp-00Ah] 
	mov	ax,[bp-00Ch] 
	mov	cx,[bp+00Ch] 
	mov	bx,[bp+00Ah] 
	call	far ptr F_PADD@ 
	mov	[bp-006h],dx 
	mov	[bp-008h],ax 
	cmp	word ptr [bp+014h],+000h 
	jnbe	@@L27 
	jc	@@L28 
	cmp	word ptr [bp+012h],4000h 
	jnc	@@L27 
@@L28:	mov	ax,[bp+012h] 
	jmp	short @@L29 
@@L27:	mov	ax,4000h 
@@L29:	push	ax 
	push    word ptr [bp-008h] 
	push    word ptr [bp-006h] 
	push    word ptr [bp-004h] 
	push    word ptr [bp-002h] 
	call	far ptr _movedata 
	add	sp,+00Ah 
	cmp	word ptr [bp+014h],+000h 
	jnbe	@@L30 
	jc	@@L31 
	cmp	word ptr [bp+012h],4000h 
	jc	@@L31 
@@L30:	mov	word ptr [bp+00Ch],0000h 
	mov	word ptr [bp+00Ah],0000h 
	sub	word ptr [bp+012h],4000h 
	sbb	word ptr [bp+014h],+000h 
	xor	cx,cx 
	mov	bx,4000h 
	mov	dx,ss 
	lea	ax,[bp-004h] 
	call	far ptr F_PADA@ 
	inc	si 
	jmp	@@L26 
@@L31:	mov	ax,[bp+00Ch] 
	mov	dx,[bp+00Ah] 
	add	dx,[bp+012h] 
	adc	ax,[bp+014h] 
	les	bx,dword ptr [bp+006h] 
	push	dx 
	mov	es:[bx+009h],ax 
	mov	dx,ax 
	pop	ax 
	mov	es:[bx+007h],ax 
	pop	si 
	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_ems_handle_free: 
	push	bp 
	mov	bp,sp 
	les	bx,dword ptr [bp+006h] 
	push	word ptr es:[bx+013h] 
	push	cs 
	call	__fxvmm_emm_free_handle 
	add	sp,+002h 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_ems_handle_alloc: 
	push	bp 
	mov	bp,sp 
	sub	sp,+004h 
	push    word ptr [bp+008h] 
	push    word ptr [bp+006h] 
	mov	ax,[bp+00Ah] 
	add	ax,0013h 
	push    word ptr [bp+00Ch] 
	push	ax 
	push	cs 
	call	__fxvmm_emm_alloc_handle 
	add	sp,+008h 
	mov	[bp-002h],dx 
	mov	[bp-004h],ax 
 
	or	ax,dx 
	jz	@@L32 
	mov	ax,_fxvmm_global_ems_handle 
	and	ax,007Fh 
	les	bx,dword ptr [bp+00Ah] 
	and	byte ptr es:[bx+002h],80h 
	or	es:[bx+002h],al 
	les	bx,dword ptr [bp+00Ah] 
	mov	ax,[bp-002h] 
	mov	dx,[bp-004h] 
	mov	es:[bx+005h],ax 
	mov	es:[bx+003h],dx 
	les	bx,dword ptr [bp+00Ah] 
	mov	word ptr es:[bx+009h],0000h 
	mov	word ptr es:[bx+007h],0000h 
	les	bx,dword ptr [bp+00Ah] 
	mov	word ptr es:[bx+019h],0000h 
	mov	word ptr es:[bx+017h],0000h 
	mov	ax,0001h 
	mov	sp,bp 
	pop	bp 
	retf 
@@L32:	xor	ax,ax 
	mov	sp,bp 
	pop	bp 
	retf 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
__fxvmm_ems_handle_deinit: 
	push	bp 
	mov	bp,sp 
	push	cs 
	call	__fxvmm_emm_close 
	pop	bp 
	retf 
 
FXEMM_TEXT	ENDS 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
_DATA	SEGMENT 
 
_fxvmm_local_ems_handle	db	001h 
                     	db	000h 
                	dd	FXEMM_TEXT:__fxvmm_ems_handle_alloc 
                    	dd	FXEMM_TEXT:__fxvmm_ems_handle_free 
                  	dd	FXEMM_TEXT:__fxvmm_ems_handle_absread 
                   	dd	FXEMM_TEXT:__fxvmm_ems_handle_abswrite 
                     	dd	FXEMM_TEXT:__fxvmm_ems_handle_deinit 
                 	dd	DGROUP:_fxvmm_global_ems_handle 
_fxvmm_strat_ems_handle	dd	DGROUP:_fxvmm_local_ems_handle 
 
_DATA	ENDS 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°± 
 
_BSS	SEGMENT 
 
_fxvmm_emm_tmpoff	dw	1 dup(?) 
_fxvmm_emm_segment	dw	1 dup(?) 
_fxvmm_emm_swaphandle	dw	1 dup(?) 
_fxvmm_emm_pointer	dw	1 dup(?) 
_fxvmm_emm_lowpointer	dw	1 dup(?) 
 
_BSS	ENDS 
	END 
 
;±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°±°