From 4b848cc7e83ec582ae503df25de4f03c0eacf306 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 31 Aug 2014 10:32:28 +0200 Subject: [PATCH] [Reduction] #409: ems_allocate --- libs/master.lib/ems_allocate.asm | 57 ++++++++++++++++++++++++++++++++ th04_main.asm | 27 ++------------- th05_main.asm | 27 ++------------- 3 files changed, 61 insertions(+), 50 deletions(-) create mode 100644 libs/master.lib/ems_allocate.asm diff --git a/libs/master.lib/ems_allocate.asm b/libs/master.lib/ems_allocate.asm new file mode 100644 index 00000000..44be8e3f --- /dev/null +++ b/libs/master.lib/ems_allocate.asm @@ -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 diff --git a/th04_main.asm b/th04_main.asm index 508e3401..4dea3c56 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -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 diff --git a/th05_main.asm b/th05_main.asm index cb656f9a..12b5f92b 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -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