From 5261b79d12cda24e63c71928192ebf4e0fdc4bbf Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 31 Aug 2014 11:02:40 +0200 Subject: [PATCH] [Reduction] #415: ems_write --- libs/master.lib/ems_write.asm | 99 +++++++++++++++++++++++++++++++++++ th04_main.asm | 74 ++------------------------ th05_main.asm | 78 +++------------------------ 3 files changed, 111 insertions(+), 140 deletions(-) create mode 100644 libs/master.lib/ems_write.asm diff --git a/libs/master.lib/ems_write.asm b/libs/master.lib/ems_write.asm new file mode 100644 index 00000000..1dce76f1 --- /dev/null +++ b/libs/master.lib/ems_write.asm @@ -0,0 +1,99 @@ +; master library - PC98 - MSDOS - EMS +; +; Description: +; EMSメモリにデータを書き込む (Level 2) +; +; Function/Procedures: +; int ems_write( unsigned handle, long offs, void far * mem, long len ) ; +; +; Parameters: +; unsigned handle EMSハンドル +; long offs EMSメモリ内のオフセットアドレス +; void far * mem 書き込むデータの先頭アドレス +; long len 書き込むデータの長さ(バイト数) +; +; Returns: +; 0 ........... success +; 80h〜 ....... failure(EMS エラーコード) +; +; Binding Target: +; Microsoft-C / Turbo-C / Turbo Pascal +; +; Running Target: +; PC-9801 +; +; Requiring Resources: +; CPU: 8086 +; EMS: LIM EMS 4.0 +; +; Notes: +; +; +; Compiler/Assembler: +; TASM 3.0 +; OPTASM 1.6 +; +; Author: +; 恋塚昭彦 +; +; Revision History: +; 92/11/16 Initial +; 93/ 2/24 bugfix (large data model) + +func EMS_WRITE + push BP + mov BP,SP + sub SP,18 + + ; 引数 + @@handle = (RETSIZE+7)*2 + @@offs = (RETSIZE+5)*2 + @@mem = (RETSIZE+3)*2 + @@len = (RETSIZE+1)*2 + + @@block = -18 + + mov AX,[BP+@@len] + mov DX,[BP+@@len+2] + mov [BP+@@block],AX ;block + mov [BP+@@block+2],DX + mov BYTE PTR [BP+@@block+4],0 ; Main Memory + mov WORD PTR [BP+@@block+5],0 + + mov AX,[BP+@@mem] + mov [BP+@@block+7],AX + + mov AX,[BP+@@mem+2] + mov [BP+@@block+9],AX + + mov BYTE PTR [BP+@@block+11],1 ; EMS + + mov AX,[BP+@@handle] + mov [BP+@@block+12],AX + + mov AX,[BP+@@offs] + mov DX,AX + and DH,3Fh + mov [BP+@@block+14],DX + mov DX,[BP+@@offs+2] + shl AX,1 + rcl DX,1 + shl AX,1 + rcl DX,1 + mov [BP+@@block+16],DX + + _push SS + lea AX,WORD PTR [BP+@@block] + push AX + _call EMS_MOVEMEMORYREGION + push AX ; push result + + sub AX,AX + push AX + _call EMS_ENABLEPAGEFRAME + + pop AX ; pop result + mov SP,BP + pop BP + ret 14 +endfunc diff --git a/th04_main.asm b/th04_main.asm index 8efeb4d4..742489f0 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -1827,71 +1827,7 @@ include libs/master.lib/ems_exist.asm include libs/master.lib/ems_free.asm include libs/master.lib/ems_movememoryregion.asm include libs/master.lib/ems_setname.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_41F6 proc far - -var_12 = word ptr -12h -var_10 = word ptr -10h -var_E = byte ptr -0Eh -var_D = word ptr -0Dh -var_B = word ptr -0Bh -var_9 = word ptr -9 -var_7 = byte ptr -7 -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah -arg_6 = word ptr 0Ch -arg_8 = word ptr 0Eh -arg_A = word ptr 10h -arg_C = word ptr 12h - - push bp - mov bp, sp - sub sp, 12h - mov ax, [bp+arg_0] - mov dx, [bp+arg_2] - mov [bp+var_12], ax - mov [bp+var_10], dx - mov [bp+var_E], 0 - mov [bp+var_D], 0 - mov ax, [bp+arg_4] - mov [bp+var_B], ax - mov ax, [bp+arg_6] - mov [bp+var_9], ax - mov [bp+var_7], 1 - mov ax, [bp+arg_C] - mov [bp+var_6], ax - mov ax, [bp+arg_8] - mov dx, ax - and dh, 3Fh - mov [bp+var_4], dx - mov dx, [bp+arg_A] - shl ax, 1 - rcl dx, 1 - shl ax, 1 - rcl dx, 1 - mov [bp+var_2], dx - push ss - lea ax, [bp+var_12] - push ax - call ems_movememoryregion - push ax - sub ax, ax - push ax - call ems_enablepageframe - pop ax - mov sp, bp - pop bp - retf 0Eh -sub_41F6 endp - +include libs/master.lib/ems_write.asm ; =============== S U B R O U T I N E ======================================= @@ -5760,7 +5696,7 @@ loc_B4AF: shl ax, 2 movzx eax, ax push eax - call sub_41F6 + call ems_write push 1Fh call sub_13A58 @@ -5800,7 +5736,7 @@ var_4 = dword ptr -4 shl ax, 2 movzx eax, ax push eax - call sub_41F6 + call ems_write cmp byte_266D8, 0 jnz short loc_B58D push 2 @@ -5831,7 +5767,7 @@ loc_B5A9: push 0 movzx eax, di push eax - call sub_41F6 + call ems_write movzx eax, di add [bp+var_4], eax push word_266DE @@ -5844,7 +5780,7 @@ loc_B5A9: shl ax, 2 movzx eax, ax push eax - call sub_41F6 + call ems_write mov ax, di shl ax, 2 movzx eax, ax diff --git a/th05_main.asm b/th05_main.asm index 38fd0e42..e89c4172 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -1313,71 +1313,7 @@ include libs/master.lib/ems_exist.asm include libs/master.lib/ems_free.asm include libs/master.lib/ems_movememoryregion.asm include libs/master.lib/ems_setname.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_406C proc far - -var_12 = word ptr -12h -var_10 = word ptr -10h -var_E = byte ptr -0Eh -var_D = word ptr -0Dh -var_B = word ptr -0Bh -var_9 = word ptr -9 -var_7 = byte ptr -7 -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = word ptr 0Ah -arg_6 = word ptr 0Ch -arg_8 = word ptr 0Eh -arg_A = word ptr 10h -arg_C = word ptr 12h - - push bp - mov bp, sp - sub sp, 12h - mov ax, [bp+arg_0] - mov dx, [bp+arg_2] - mov [bp+var_12], ax - mov [bp+var_10], dx - mov [bp+var_E], 0 - mov [bp+var_D], 0 - mov ax, [bp+arg_4] - mov [bp+var_B], ax - mov ax, [bp+arg_6] - mov [bp+var_9], ax - mov [bp+var_7], 1 - mov ax, [bp+arg_C] - mov [bp+var_6], ax - mov ax, [bp+arg_8] - mov dx, ax - and dh, 3Fh - mov [bp+var_4], dx - mov dx, [bp+arg_A] - shl ax, 1 - rcl dx, 1 - shl ax, 1 - rcl dx, 1 - mov [bp+var_2], dx - push ss - lea ax, [bp+var_12] - push ax - call ems_movememoryregion - push ax - sub ax, ax - push ax - call ems_enablepageframe - pop ax - mov sp, bp - pop bp - retf 0Eh -sub_406C endp - +include libs/master.lib/ems_write.asm ; =============== S U B R O U T I N E ======================================= @@ -5885,7 +5821,7 @@ loc_B84E: shl ax, 2 movzx eax, ax push eax - call sub_406C + call ems_write push 1Fh call sub_15244 @@ -5925,7 +5861,7 @@ var_4 = dword ptr -4 shl ax, 2 movzx eax, ax push eax - call sub_406C + call ems_write mov al, byte_25FEF mov ah, 0 mov bx, ax @@ -5979,7 +5915,7 @@ loc_B957: push 0 movzx eax, di push eax - call sub_406C + call ems_write movzx eax, di add [bp+var_4], eax push word_25FF0 @@ -5992,7 +5928,7 @@ loc_B957: shl ax, 2 movzx eax, ax push eax - call sub_406C + call ems_write mov ax, di shl ax, 2 movzx eax, ax @@ -6053,7 +5989,7 @@ loc_B9F7: push 0 movzx eax, di push eax - call sub_406C + call ems_write movzx eax, di add [bp+var_4], eax push word_25FF0 @@ -6066,7 +6002,7 @@ loc_B9F7: shl ax, 2 movzx eax, ax push eax - call sub_406C + call ems_write mov ax, di shl ax, 2 movzx eax, ax