From 12c1e8560fb739d37f2783ba271776cb8decdc6b Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 30 Aug 2014 09:38:09 +0200 Subject: [PATCH] [Reduction] #369: file_write --- libs/master.lib/file_write.asm | 139 +++++++++++++++++++++++++++++++++ th01_reiiden.asm | 104 ++---------------------- th02_main.asm | 96 +---------------------- th02_maine.asm | 96 +---------------------- th02_op.asm | 100 +----------------------- th03_mainl.asm | 96 +---------------------- th03_op.asm | 100 +----------------------- th04_main.asm | 99 +---------------------- th04_maine.asm | 100 +----------------------- th04_op.asm | 102 ++---------------------- th05_maine.asm | 100 +----------------------- th05_op.asm | 102 ++---------------------- 12 files changed, 180 insertions(+), 1054 deletions(-) create mode 100644 libs/master.lib/file_write.asm diff --git a/libs/master.lib/file_write.asm b/libs/master.lib/file_write.asm new file mode 100644 index 00000000..0fd39000 --- /dev/null +++ b/libs/master.lib/file_write.asm @@ -0,0 +1,139 @@ +; master library - MS-DOS +; +; Description: +; ファイルへの書き込み +; +; Function/Procedures: +; int file_write( const char far * buf, unsigned wsize ) ; +; +; Parameters: +; char far * buf 書き込むデータの先頭アドレス +; unsigned wsize 書き込むバイト数(0は禁止) +; +; Returns: +; 1 = 成功 +; 0 = 失敗 +; +; Binding Target: +; Microsoft-C / Turbo-C / Turbo Pascal +; +; Running Target: +; MS-DOS +; +; Requiring Resources: +; CPU: 8086 +; +; Notes: +; +; +; Compiler/Assembler: +; TASM 3.0 +; OPTASM 1.6 +; +; Author: +; 恋塚昭彦 +; +; Revision History: +; 92/11/17 Initial +; 92/11/30 BufferSize = 0 ならば DOS直接に +; 92/12/08 ↑のbugfix +; 94/ 2/10 [0.22a] bugfix, バッファありのときに書き込みポインタが1しか +; 進まなかった +; 94/ 3/12 [M0.23] bugfix, バッファサイズより大きな書き込みをしたときに +; 最後の余りをバッファに書き込んだあとエラーを返していた + +func FILE_WRITE + push BP + mov BP,SP + + push SI + push DI + + cmp file_BufferSize,0 + je short @@DIRECT + + ; 引数 + @@buf = (RETSIZE+2)*2 + @@wsize = (RETSIZE+1)*2 + + mov BX,[BP+@@wsize] ; BX = wsize + mov SI,[BP+@@buf] ; SI = buf +@@WLOOP: + mov CX,file_BufferSize + sub CX,file_BufPtr + sub CX,BX + sbb AX,AX ; AX : file〜が採用されてれば-1 + and CX,AX ; wsizeが採用されてれば 0 + add CX,BX ; CX = writelen + + les DI,file_Buffer + add DI,file_BufPtr + sub BX,CX ; wsize -= writelen + add file_BufPtr,CX ; BufPtr += writelen + + push DS + mov DS,[BP+@@buf+2] ; カークよりエンタープライズへ + shr CX,1 ; はい、チャーリーです + rep movsw ; 転送! + adc CX,CX + rep movsb ; buf += writelen + pop DS + + or AX,AX + jns short @@LOOPEND + + ; file〜が採用されていた、すなわちバッファが満杯になった + + push DS + push BX + mov CX,file_BufferSize + mov BX,file_Handle + lds DX,file_Buffer + mov AH,40h ; ファイルの書き込み + int 21h + pop BX + pop DS + jc short @@WERROR + cmp file_BufferSize,AX + jne short @@WERROR + + mov file_BufPtr,0 ; 書き込んだのでバッファクリア + add WORD PTR file_BufferPos,AX + adc WORD PTR file_BufferPos+2,0 + +@@LOOPEND: + or BX,BX + jne short @@WLOOP + + ; Success + mov AX,1 + jmp short @@DONE + EVEN + +@@DIRECT: ; DOS直接 + push DS + mov CX,[BP+@@wsize] + mov BX,file_Handle + lds DX,[BP+@@buf] + mov AH,40h ; ファイルの書き込み + int 21h + pop DS + jnc short @@EXIT + +@@WERROR: + mov file_ErrorStat,1 + xor AX,AX +@@EXIT: + add WORD PTR file_BufferPos,AX + adc WORD PTR file_BufferPos+2,0 + add AX,-1 + sbb AX,AX ; 0以外なら1にする +@@DONE: + pop DI + pop SI + + mov SP,BP + pop BP + ret 6 + EVEN +endfunc diff --git a/th01_reiiden.asm b/th01_reiiden.asm index f102883a..6042eceb 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -2139,99 +2139,7 @@ include libs/master.lib/file_read.asm include libs/master.lib/file_close.asm include libs/master.lib/file_exist.asm include libs/master.lib/file_ropen.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11AA proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_1220 - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_11BC: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_1216 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_1232 - cmp file_BufferSize, ax - jnz short loc_1232 - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_1216: - or bx, bx - jnz short loc_11BC - mov ax, 1 - jmp short loc_1248 -; --------------------------------------------------------------------------- - nop - -loc_1220: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_123A - -loc_1232: - mov file_ErrorStat, 1 - xor ax, ax - -loc_123A: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_1248: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_11AA endp - +include libs/master.lib/file_write.asm include libs/master.lib/file_create.asm include libs/master.lib/file_seek.asm @@ -31095,7 +31003,7 @@ loc_139BC: jz loc_13A72 push large [bp+var_12] push 7 - call sub_11AA + call file_write mov [bp+var_2], 0Ah mov [bp+var_A], 3E8h xor si, si @@ -31125,7 +31033,7 @@ loc_139FF: loc_13A08: push large [bp+var_E] push 10h - call sub_11AA + call file_write inc si loc_13A14: @@ -31140,7 +31048,7 @@ loc_13A1D: lea ax, [bp+var_A] push ax push 4 - call sub_11AA + call file_write mov eax, [bp+var_A] add eax, 0FFFFFF9Ch mov [bp+var_A], eax @@ -31158,7 +31066,7 @@ loc_13A3F: lea ax, [bp+var_2] push ax push 2 - call sub_11AA + call file_write mov ax, [bp+var_2] dec ax mov [bp+var_2], ax @@ -31174,7 +31082,7 @@ loc_13A53: loc_13A5C: push large [bp+var_6] push 2 - call sub_11AA + call file_write inc si loc_13A68: diff --git a/th02_main.asm b/th02_main.asm index 667d78c4..d25d817c 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -67,99 +67,7 @@ loc_9D9: retf sub_9CE endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_9DC proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_A52 - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_9EE: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_A48 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_A64 - cmp file_BufferSize, ax - jnz short loc_A64 - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_A48: - or bx, bx - jnz short loc_9EE - mov ax, 1 - jmp short loc_A7A -; --------------------------------------------------------------------------- - nop - -loc_A52: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_A6C - -loc_A64: - mov file_ErrorStat, 1 - xor ax, ax - -loc_A6C: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_A7A: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_9DC endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -42489,7 +42397,7 @@ loc_1C9C5: push ds push offset word_252FE push 0B6h ; '' - call sub_9DC + call file_write call file_close pop si pop bp diff --git a/th02_maine.asm b/th02_maine.asm index e0465d3a..2d20222c 100644 --- a/th02_maine.asm +++ b/th02_maine.asm @@ -70,99 +70,7 @@ loc_C25: retf sub_C1A endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C28 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_C9E - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_C3A: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_C94 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_CB0 - cmp file_BufferSize, ax - jnz short loc_CB0 - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_C94: - or bx, bx - jnz short loc_C3A - mov ax, 1 - jmp short loc_CC6 -; --------------------------------------------------------------------------- - nop - -loc_C9E: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_CB8 - -loc_CB0: - mov file_ErrorStat, 1 - xor ax, ax - -loc_CB8: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_CC6: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_C28 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -9729,7 +9637,7 @@ loc_BC65: push ds push offset word_FB16 push 0B6h ; '' - call sub_C28 + call file_write call file_close pop si pop bp diff --git a/th02_op.asm b/th02_op.asm index 136eb77d..1b1665eb 100644 --- a/th02_op.asm +++ b/th02_op.asm @@ -50,99 +50,7 @@ include libs/master.lib/file_exist.asm include libs/master.lib/file_read.asm include libs/master.lib/file_ropen.asm include libs/master.lib/file_seek.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_952 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_9C8 - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_964: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_9BE - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_9DA - cmp file_BufferSize, ax - jnz short loc_9DA - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_9BE: - or bx, bx - jnz short loc_964 - mov ax, 1 - jmp short loc_9F0 -; --------------------------------------------------------------------------- - nop - -loc_9C8: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_9E2 - -loc_9DA: - mov file_ErrorStat, 1 - xor ax, ax - -loc_9E2: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_9F0: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_952 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -5402,16 +5310,16 @@ var_2 = word ptr -2 lea ax, [bp+var_C] push ax push 5 - call sub_952 + call file_write push ds push offset word_E900 push 2 - call sub_952 + call file_write push ss lea ax, [bp+var_5] push ax push 1 - call sub_952 + call file_write call file_close leave retf diff --git a/th03_mainl.asm b/th03_mainl.asm index 01e5a897..b744a77b 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -69,99 +69,7 @@ loc_9EF: retf sub_9E4 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_9F2 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_A68 - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_A04: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_A5E - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_A7A - cmp file_BufferSize, ax - jnz short loc_A7A - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_A5E: - or bx, bx - jnz short loc_A04 - mov ax, 1 - jmp short loc_A90 -; --------------------------------------------------------------------------- - nop - -loc_A68: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_A82 - -loc_A7A: - mov file_ErrorStat, 1 - xor ax, ax - -loc_A82: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_A90: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_9F2 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -7733,7 +7641,7 @@ loc_AF73: push ds push offset word_105DE push 0CEh ; '' - call sub_9F2 + call file_write call file_close pop di pop si diff --git a/th03_op.asm b/th03_op.asm index 44ca7236..00287e68 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -53,99 +53,7 @@ include libs/master.lib/file_exist.asm include libs/master.lib/file_read.asm include libs/master.lib/file_ropen.asm include libs/master.lib/file_seek.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_A26 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_A9C - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_A38: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_A92 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_AAE - cmp file_BufferSize, ax - jnz short loc_AAE - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_A92: - or bx, bx - jnz short loc_A38 - mov ax, 1 - jmp short loc_AC4 -; --------------------------------------------------------------------------- - nop - -loc_A9C: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_AB6 - -loc_AAE: - mov file_ErrorStat, 1 - xor ax, ax - -loc_AB6: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_AC4: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_A26 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -5146,7 +5054,7 @@ var_6 = byte ptr -6 lea ax, [bp+var_8] push ax push 4 - call sub_A26 + call file_write call file_close leave retn @@ -5188,7 +5096,7 @@ var_6 = byte ptr -6 lea ax, [bp+var_8] push ax push 8 - call sub_A26 + call file_write call file_close leave retn @@ -8108,7 +8016,7 @@ loc_B1D4: push ds push offset word_FB84 push 0CEh ; '' - call sub_A26 + call file_write call file_close pop di pop si diff --git a/th04_main.asm b/th04_main.asm index 726e1c98..d2094ece 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -77,100 +77,7 @@ loc_F9D: retf sub_F92 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_FA0 proc far - ; sub_12B1E+47P - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_1016 - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_FB2: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_100C - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_1028 - cmp file_BufferSize, ax - jnz short loc_1028 - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_100C: - or bx, bx - jnz short loc_FB2 - mov ax, 1 - jmp short loc_103E -; --------------------------------------------------------------------------- - nop - -loc_1016: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_1030 - -loc_1028: - mov file_ErrorStat, 1 - xor ax, ax - -loc_1030: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_103E: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_FA0 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -23076,7 +22983,7 @@ loc_12A90: push ds push offset unk_2CF2E push 0C4h ; '' - call sub_FA0 + call file_write push 0BBEEh call sub_C3AA inc si @@ -23172,7 +23079,7 @@ loc_12B5E: push ds push offset unk_2CF2E push 0C4h ; '' - call sub_FA0 + call file_write call file_close pop bp retn diff --git a/th04_maine.asm b/th04_maine.asm index d110eba0..77184c49 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -72,99 +72,7 @@ loc_B11: retf sub_B06 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_B14 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_B8A - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_B26: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_B80 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_B9C - cmp file_BufferSize, ax - jnz short loc_B9C - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_B80: - or bx, bx - jnz short loc_B26 - mov ax, 1 - jmp short loc_BB2 -; --------------------------------------------------------------------------- - nop - -loc_B8A: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_BA4 - -loc_B9C: - mov file_ErrorStat, 1 - xor ax, ax - -loc_BA4: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_BB2: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_B14 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_byteboxfill_x.asm @@ -8492,7 +8400,7 @@ loc_C28C: push ds push offset byte_124F2 push 0C4h ; '' - call sub_B14 + call file_write call sub_C149 inc si @@ -8592,7 +8500,7 @@ loc_C350: push ds push offset byte_124F2 push 0C4h ; '' - call sub_B14 + call file_write xor si, si jmp short loc_C3A5 ; --------------------------------------------------------------------------- @@ -8619,7 +8527,7 @@ loc_C360: push ds push offset byte_124F2 push 0C4h ; '' - call sub_B14 + call file_write inc si loc_C3A5: diff --git a/th04_op.asm b/th04_op.asm index f7a04173..85a1f3a0 100644 --- a/th04_op.asm +++ b/th04_op.asm @@ -56,99 +56,7 @@ include libs/master.lib/file_exist.asm include libs/master.lib/file_read.asm include libs/master.lib/file_ropen.asm include libs/master.lib/file_seek.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_AF8 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_B6E - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_B0A: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_B64 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_B80 - cmp file_BufferSize, ax - jnz short loc_B80 - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_B64: - or bx, bx - jnz short loc_B0A - mov ax, 1 - jmp short loc_B96 -; --------------------------------------------------------------------------- - nop - -loc_B6E: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_B88 - -loc_B80: - mov file_ErrorStat, 1 - xor ax, ax - -loc_B88: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_B96: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_AF8 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -5173,7 +5081,7 @@ var_2 = byte ptr -2 lea ax, [bp+var_8] push ax push 6 - call sub_AF8 + call file_write push large 9 push 0 call file_seek @@ -5188,7 +5096,7 @@ var_2 = byte ptr -2 lea ax, [bp+var_2] push ax push 1 - call sub_AF8 + call file_write call file_close leave retn @@ -5247,7 +5155,7 @@ var_1 = byte ptr -1 lea ax, [bp+var_A] push ax push 0Ah - call sub_AF8 + call file_write call file_close leave retn @@ -8969,7 +8877,7 @@ loc_C712: push ds push offset byte_130F2 push 0C4h ; '' - call sub_AF8 + call file_write call sub_C57A inc si diff --git a/th05_maine.asm b/th05_maine.asm index 89012972..2cf6bd5c 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -71,99 +71,7 @@ loc_AEF: retf sub_AE4 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_AF2 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_B68 - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_B04: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_B5E - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_B7A - cmp file_BufferSize, ax - jnz short loc_B7A - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_B5E: - or bx, bx - jnz short loc_B04 - mov ax, 1 - jmp short loc_B90 -; --------------------------------------------------------------------------- - nop - -loc_B68: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_B82 - -loc_B7A: - mov file_ErrorStat, 1 - xor ax, ax - -loc_B82: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_B90: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_AF2 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_boxfill.asm @@ -7037,7 +6945,7 @@ loc_B624: push ds push offset byte_1501A push 60h ; '`' - call sub_AF2 + call file_write call sub_B4D6 inc [bp+var_2] @@ -7129,7 +7037,7 @@ sub_B6A3 proc near push ds push offset byte_1501A push 60h ; '`' - call sub_AF2 + call file_write xor si, si jmp short loc_B723 ; --------------------------------------------------------------------------- @@ -7156,7 +7064,7 @@ loc_B6E2: push ds push offset byte_1501A push 60h ; '`' - call sub_AF2 + call file_write inc si loc_B723: diff --git a/th05_op.asm b/th05_op.asm index c2ad6c3b..75a2108f 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -55,99 +55,7 @@ include libs/master.lib/file_exist.asm include libs/master.lib/file_read.asm include libs/master.lib/file_ropen.asm include libs/master.lib/file_seek.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_AD6 proc far - -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - push bp - mov bp, sp - push si - push di - cmp file_BufferSize, 0 - jz short loc_B4C - mov bx, [bp+arg_0] - mov si, word ptr [bp+arg_2] - -loc_AE8: - mov cx, file_BufferSize - sub cx, file_BufPtr - sub cx, bx - sbb ax, ax - and cx, ax - add cx, bx - les di, file_Buffer - add di, file_BufPtr - sub bx, cx - add file_BufPtr, cx - push ds - mov ds, word ptr [bp+arg_2+2] - shr cx, 1 - rep movsw - adc cx, cx - rep movsb - pop ds - or ax, ax - jns short loc_B42 - push ds - push bx - mov cx, file_BufferSize - mov bx, file_Handle - lds dx, file_Buffer - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop bx - pop ds - jb short loc_B5E - cmp file_BufferSize, ax - jnz short loc_B5E - mov file_BufPtr, 0 - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - -loc_B42: - or bx, bx - jnz short loc_AE8 - mov ax, 1 - jmp short loc_B74 -; --------------------------------------------------------------------------- - nop - -loc_B4C: - push ds - mov cx, [bp+arg_0] - mov bx, file_Handle - lds dx, [bp+arg_2] - mov ah, 40h - int 21h ; DOS - 2+ - WRITE TO FILE WITH HANDLE - ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer - pop ds - jnb short loc_B66 - -loc_B5E: - mov file_ErrorStat, 1 - xor ax, ax - -loc_B66: - add word ptr file_BufferPos, ax - adc word ptr file_BufferPos+2, 0 - add ax, 0FFFFh - sbb ax, ax - -loc_B74: - pop di - pop si - mov sp, bp - pop bp - retf 6 -sub_AD6 endp - +include libs/master.lib/file_write.asm include libs/master.lib/dos_close.asm include libs/master.lib/dos_ropen.asm include libs/master.lib/grcg_byteboxfill_x.asm @@ -7688,7 +7596,7 @@ var_2 = byte ptr -2 lea ax, [bp+var_8] push ax push 6 - call sub_AD6 + call file_write push large 9 push 0 call file_seek @@ -7703,7 +7611,7 @@ var_2 = byte ptr -2 lea ax, [bp+var_2] push ax push 1 - call sub_AD6 + call file_write call file_close leave retn @@ -7762,7 +7670,7 @@ var_1 = byte ptr -1 lea ax, [bp+var_A] push ax push 0Ah - call sub_AD6 + call file_write call file_close leave retn @@ -9407,7 +9315,7 @@ loc_C999: push ds push offset byte_14040 push 60h ; '`' - call sub_AD6 + call file_write call sub_C7D5 inc si