From 8cc3df1eb13df4a810322f10530795f952ba8bfe Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 27 Sep 2014 22:51:10 +0200 Subject: [PATCH] [Reduction] #512: xfclose --- libs/BorlandC/xfclose.asm | 42 ++++++++++++++++++++++++++++++++ th01_fuuin.asm | 51 +++------------------------------------ th01_op.asm | 51 +++------------------------------------ th01_reiiden.asm | 51 +++------------------------------------ 4 files changed, 51 insertions(+), 144 deletions(-) create mode 100644 libs/BorlandC/xfclose.asm diff --git a/libs/BorlandC/xfclose.asm b/libs/BorlandC/xfclose.asm new file mode 100644 index 00000000..221dc9c2 --- /dev/null +++ b/libs/BorlandC/xfclose.asm @@ -0,0 +1,42 @@ +__xfclose proc DIST +@@i = word ptr -(dPtrSize + 2) +@@fp = DPTR_ -(dPtrSize) + + push bp + mov bp, sp + sub sp, dPtrSize + 2 + push si + push di + mov [bp+@@i], 0 +if LDATA + mov word ptr [bp+@@fp+2], ds +endif + mov word ptr [bp+@@fp], offset _streams + jmp short @@check + +@@loop: + LES_ bx, [bp+@@fp] + test byte ptr ES_[bx+FILE.flags], 3 + jz short @@next + push word ptr [bp+@@fp+2] + push bx + nopcall _fclose +if LDATA + pop cx +endif + pop cx + +@@next: + add word ptr [bp+@@fp], size FILE + inc [bp+@@i] + +@@check: + mov ax, [bp+@@i] + cmp ax, __nfile + jb short @@loop + pop di + pop si + mov sp, bp + pop bp + ret +__xfclose endp diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 0d0e14c7..2e489e68 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -4753,8 +4753,8 @@ loc_3F1E: or [bp+var_4], 40h loc_3F22: - mov word ptr _exitfopen+2, seg seg000 - mov word ptr _exitfopen, 5787h + mov word ptr _exitfopen+2, seg __xfclose + mov word ptr _exitfopen, offset __xfclose les bx, [bp+arg_4] mov es:[bx], dx les bx, [bp+arg_0] @@ -5975,52 +5975,7 @@ j____write proc far jmp near ptr ___write j____write endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -__xfclose proc far - -var_6 = word ptr -6 -stream = dword ptr -4 - - push bp - mov bp, sp - sub sp, 6 - push si - push di - mov [bp+var_6], 0 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 0CAAh - jmp short loc_57BA -; --------------------------------------------------------------------------- - -loc_579E: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_57B3 - push word ptr [bp+stream+2] - push bx ; stream - nopcall _fclose - pop cx - pop cx - -loc_57B3: - add word ptr [bp+stream], 14h - inc [bp+var_6] - -loc_57BA: - mov ax, [bp+var_6] - cmp ax, __nfile - jb short loc_579E - pop di - pop si - mov sp, bp - pop bp - retf -__xfclose endp - +include libs/BorlandC/xfclose.asm include libs/BorlandC/xfflush.asm include libs/BorlandC/xalloc.asm include libs/BorlandC/xmsg.asm diff --git a/th01_op.asm b/th01_op.asm index 0ba8bdf9..ef93fda5 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -4532,8 +4532,8 @@ loc_3FF6: or [bp+var_4], 40h loc_3FFA: - mov word ptr _exitfopen+2, seg seg000 - mov word ptr _exitfopen, 5A02h + mov word ptr _exitfopen+2, seg __xfclose + mov word ptr _exitfopen, offset __xfclose les bx, [bp+arg_4] mov es:[bx], dx les bx, [bp+arg_0] @@ -5635,52 +5635,7 @@ include libs/BorlandC/_strlen.asm include libs/BorlandC/strrchr.asm include libs/BorlandC/write.asm include libs/BorlandC/writea.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -__xfclose proc far - -var_6 = word ptr -6 -stream = dword ptr -4 - - push bp - mov bp, sp - sub sp, 6 - push si - push di - mov [bp+var_6], 0 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 9FAh - jmp short loc_5A35 -; --------------------------------------------------------------------------- - -loc_5A19: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_5A2E - push word ptr [bp+stream+2] - push bx ; stream - nopcall _fclose - pop cx - pop cx - -loc_5A2E: - add word ptr [bp+stream], 14h - inc [bp+var_6] - -loc_5A35: - mov ax, [bp+var_6] - cmp ax, __nfile - jb short loc_5A19 - pop di - pop si - mov sp, bp - pop bp - retf -__xfclose endp - +include libs/BorlandC/xfclose.asm include libs/BorlandC/xfflush.asm include libs/BorlandC/xalloc.asm include libs/BorlandC/xmsg.asm diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 12ac9255..8aec1aac 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -7813,8 +7813,8 @@ loc_5576: or [bp+var_4], 40h loc_557A: - mov word ptr _exitfopen+2, seg seg000 - mov word ptr _exitfopen, 6E75h + mov word ptr _exitfopen+2, seg __xfclose + mov word ptr _exitfopen, offset __xfclose les bx, [bp+arg_4] mov es:[bx], dx les bx, [bp+arg_0] @@ -9119,52 +9119,7 @@ j____write proc far jmp near ptr ___write j____write endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -__xfclose proc far - -var_6 = word ptr -6 -stream = dword ptr -4 - - push bp - mov bp, sp - sub sp, 6 - push si - push di - mov [bp+var_6], 0 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 1A56h - jmp short loc_6EA8 -; --------------------------------------------------------------------------- - -loc_6E8C: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_6EA1 - push word ptr [bp+stream+2] - push bx ; stream - nopcall _fclose - pop cx - pop cx - -loc_6EA1: - add word ptr [bp+stream], 14h - inc [bp+var_6] - -loc_6EA8: - mov ax, [bp+var_6] - cmp ax, __nfile - jb short loc_6E8C - pop di - pop si - mov sp, bp - pop bp - retf -__xfclose endp - +include libs/BorlandC/xfclose.asm include libs/BorlandC/xfflush.asm include libs/BorlandC/xalloc.asm include libs/BorlandC/xmsg.asm