[Reduction] #409: ems_allocate

This commit is contained in:
nmlgc 2014-08-31 10:32:28 +02:00
parent e9e6d14ab6
commit 4b848cc7e8
3 changed files with 61 additions and 50 deletions

View File

@ -0,0 +1,57 @@
; master library - PC98 - MSDOS - EMS
;
; Description:
; EMSメモリの確保
;
; Function/Procedures:
; unsigned ems_allocate( unsigned long size ) ;
;
;
; Parameters:
; unsigned long size 確保するバイト数。
;
; Returns:
; int 0 ... 失敗
; else EMSハンドル
;
; Binding Target:
; Microsoft-C / Turbo-C / Turbo Pascal
;
; Running Target:
; PC-9801
;
; Requiring Resources:
; CPU: 8086
; EMS: LIM EMS 3.2
;
; Notes:
;
;
; Compiler/Assembler:
; TASM 3.0
; OPTASM 1.6
;
; Author:
; 恋塚昭彦
;
; Revision History:
; 92/11/16 Initial
; 92/12/15 計算をちょいと改良
func EMS_ALLOCATE
mov BX,SP
mov CX,SS:[BX+(RETSIZE)*2] ; lo
mov BX,SS:[BX+(RETSIZE)*2+2] ; hi
shl CX,1
rcl BX,1
shl CX,1
rcl BX,1
cmp CX,1
sbb BX,-1
mov AH,43h ; function: Allocate Pages
int 67h ; call EMM
sub AH,1
sbb AX,AX
and AX,DX
ret 4
endfunc

View File

@ -1823,30 +1823,7 @@ arg_C = word ptr 12h
retf 0Eh
sub_40F4 endp
; =============== S U B R O U T I N E =======================================
sub_4156 proc far
mov bx, sp
mov cx, ss:[bx+4]
mov bx, ss:[bx+6]
shl cx, 1
rcl bx, 1
shl cx, 1
rcl bx, 1
cmp cx, 1
sbb bx, 0FFFFh
mov ah, 43h ; 'C'
int 67h ; - LIM EMS - GET HANDLE AND ALLOCATE MEMORY
; BX = number of logical pages to allocate
; Return: AH = status
sub ah, 1
sbb ax, ax
and ax, dx
retf 4
sub_4156 endp
include libs/master.lib/ems_allocate.asm
; =============== S U B R O U T I N E =======================================
@ -5868,7 +5845,7 @@ loc_B4AF:
cmp eax, 2BF20h
jb short loc_B52E
push large 2BF20h
call sub_4156
call ems_allocate
mov word_266DE, ax
cmp word_266DE, 0
jz short loc_B52E

View File

@ -1309,30 +1309,7 @@ arg_C = word ptr 12h
retf 0Eh
sub_3F6A endp
; =============== S U B R O U T I N E =======================================
sub_3FCC proc far
mov bx, sp
mov cx, ss:[bx+4]
mov bx, ss:[bx+6]
shl cx, 1
rcl bx, 1
shl cx, 1
rcl bx, 1
cmp cx, 1
sbb bx, 0FFFFh
mov ah, 43h ; 'C'
int 67h ; - LIM EMS - GET HANDLE AND ALLOCATE MEMORY
; BX = number of logical pages to allocate
; Return: AH = status
sub ah, 1
sbb ax, ax
and ax, dx
retf 4
sub_3FCC endp
include libs/master.lib/ems_allocate.asm
; =============== S U B R O U T I N E =======================================
@ -5992,7 +5969,7 @@ loc_B84E:
cmp eax, 4E200h
jb short loc_B8C0
push large 4E200h
call sub_3FCC
call ems_allocate
mov word_25FF0, ax
cmp word_25FF0, 0
jz short loc_B8C0