[Reduction] #415: ems_write

This commit is contained in:
nmlgc 2014-08-31 11:02:40 +02:00
parent 2c16f56bb1
commit 5261b79d12
3 changed files with 111 additions and 140 deletions

View File

@ -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

View File

@ -1827,71 +1827,7 @@ include libs/master.lib/ems_exist.asm
include libs/master.lib/ems_free.asm include libs/master.lib/ems_free.asm
include libs/master.lib/ems_movememoryregion.asm include libs/master.lib/ems_movememoryregion.asm
include libs/master.lib/ems_setname.asm include libs/master.lib/ems_setname.asm
include libs/master.lib/ems_write.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
; =============== S U B R O U T I N E ======================================= ; =============== S U B R O U T I N E =======================================
@ -5760,7 +5696,7 @@ loc_B4AF:
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_41F6 call ems_write
push 1Fh push 1Fh
call sub_13A58 call sub_13A58
@ -5800,7 +5736,7 @@ var_4 = dword ptr -4
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_41F6 call ems_write
cmp byte_266D8, 0 cmp byte_266D8, 0
jnz short loc_B58D jnz short loc_B58D
push 2 push 2
@ -5831,7 +5767,7 @@ loc_B5A9:
push 0 push 0
movzx eax, di movzx eax, di
push eax push eax
call sub_41F6 call ems_write
movzx eax, di movzx eax, di
add [bp+var_4], eax add [bp+var_4], eax
push word_266DE push word_266DE
@ -5844,7 +5780,7 @@ loc_B5A9:
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_41F6 call ems_write
mov ax, di mov ax, di
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax

View File

@ -1313,71 +1313,7 @@ include libs/master.lib/ems_exist.asm
include libs/master.lib/ems_free.asm include libs/master.lib/ems_free.asm
include libs/master.lib/ems_movememoryregion.asm include libs/master.lib/ems_movememoryregion.asm
include libs/master.lib/ems_setname.asm include libs/master.lib/ems_setname.asm
include libs/master.lib/ems_write.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
; =============== S U B R O U T I N E ======================================= ; =============== S U B R O U T I N E =======================================
@ -5885,7 +5821,7 @@ loc_B84E:
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_406C call ems_write
push 1Fh push 1Fh
call sub_15244 call sub_15244
@ -5925,7 +5861,7 @@ var_4 = dword ptr -4
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_406C call ems_write
mov al, byte_25FEF mov al, byte_25FEF
mov ah, 0 mov ah, 0
mov bx, ax mov bx, ax
@ -5979,7 +5915,7 @@ loc_B957:
push 0 push 0
movzx eax, di movzx eax, di
push eax push eax
call sub_406C call ems_write
movzx eax, di movzx eax, di
add [bp+var_4], eax add [bp+var_4], eax
push word_25FF0 push word_25FF0
@ -5992,7 +5928,7 @@ loc_B957:
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_406C call ems_write
mov ax, di mov ax, di
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
@ -6053,7 +5989,7 @@ loc_B9F7:
push 0 push 0
movzx eax, di movzx eax, di
push eax push eax
call sub_406C call ems_write
movzx eax, di movzx eax, di
add [bp+var_4], eax add [bp+var_4], eax
push word_25FF0 push word_25FF0
@ -6066,7 +6002,7 @@ loc_B9F7:
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax
push eax push eax
call sub_406C call ems_write
mov ax, di mov ax, di
shl ax, 2 shl ax, 2
movzx eax, ax movzx eax, ax