From 6ebf0877f70b6c8aad8404f68095e2683e087730 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 28 Aug 2014 21:54:04 +0200 Subject: [PATCH] [Reduction] #257: xfflush --- libs/BorlandC/xfflush.asm | 45 +++++++++++++++++++++++++++++++++++++ th01_fuuin.asm | 47 +-------------------------------------- th01_op.asm | 47 +-------------------------------------- th01_reiiden.asm | 47 +-------------------------------------- th01_zunsoft.asm | 42 +--------------------------------- th02_main.asm | 47 +-------------------------------------- th02_maine.asm | 47 +-------------------------------------- th02_op.asm | 47 +-------------------------------------- th03_main.asm | 47 +-------------------------------------- th03_mainl.asm | 47 +-------------------------------------- th03_op.asm | 47 +-------------------------------------- th04_main.asm | 47 +-------------------------------------- th04_maine.asm | 47 +-------------------------------------- th04_op.asm | 47 +-------------------------------------- th05_main.asm | 47 +-------------------------------------- th05_maine.asm | 47 +-------------------------------------- th05_op.asm | 47 +-------------------------------------- 17 files changed, 61 insertions(+), 731 deletions(-) create mode 100644 libs/BorlandC/xfflush.asm diff --git a/libs/BorlandC/xfflush.asm b/libs/BorlandC/xfflush.asm new file mode 100644 index 00000000..29a5e450 --- /dev/null +++ b/libs/BorlandC/xfflush.asm @@ -0,0 +1,45 @@ +; void _xfflush(void) +public __xfflush +__xfflush 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], 4 +if LDATA + mov word ptr [bp+@@fp+2], ds +endif + mov word ptr [bp+@@fp], offset _streams + jmp short @@check_i + +@@check_RDWR: + LES_ bx, [bp+@@fp] + test byte ptr ES_[bx+FILE.flags], 3 + jz short @@advance +if LDATA + push word ptr [bp+@@fp+2] +endif + push bx + nopcall _fflush + pop cx +if LDATA + pop cx +endif + +@@advance: + dec [bp+@@i] + add word ptr [bp+@@fp], size FILE + +@@check_i: + cmp [bp+@@i], 0 + jnz short @@check_RDWR + pop di + pop si + mov sp, bp + pop bp + ret +__xfflush endp diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 73b1132a..a6bc36d1 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -9809,52 +9809,7 @@ loc_57BA: retf __xfclose endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 0CAAh - jmp short loc_57FC -; --------------------------------------------------------------------------- - -loc_57E0: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_57F5 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_57F5: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_57FC: - cmp [bp+var_6], 0 - jnz short loc_57E0 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_op.asm b/th01_op.asm index 25a68345..1c55e89f 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -9576,52 +9576,7 @@ loc_5A35: retf __xfclose endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 9FAh - jmp short loc_5A77 -; --------------------------------------------------------------------------- - -loc_5A5B: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_5A70 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_5A70: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5A77: - cmp [bp+var_6], 0 - jnz short loc_5A5B - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 277be9d1..6a773894 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -13439,52 +13439,7 @@ loc_6EA8: retf __xfclose endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 1A56h - jmp short loc_6EEA -; --------------------------------------------------------------------------- - -loc_6ECE: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_6EE3 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_6EE3: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_6EEA: - cmp [bp+var_6], 0 - jnz short loc_6ECE - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th01_zunsoft.asm b/th01_zunsoft.asm index b3145eb3..fc80df3d 100644 --- a/th01_zunsoft.asm +++ b/th01_zunsoft.asm @@ -1527,47 +1527,7 @@ _setvbuf endp include libs/BorlandC/_strlen.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 - -__xfflush proc near - -var_4 = word ptr -4 -stream = word ptr -2 - - push bp - mov bp, sp - sub sp, 4 - push si - push di - mov [bp+var_4], 4 - mov [bp+stream], 2694h - jmp short loc_2151 -; --------------------------------------------------------------------------- - -loc_213C: - mov bx, [bp+stream] - test byte ptr [bx+2], 3 - jz short loc_214A - push bx ; stream - call _fflush - pop cx - -loc_214A: - dec [bp+var_4] - add [bp+stream], 10h - -loc_2151: - cmp [bp+var_4], 0 - jnz short loc_213C - pop di - pop si - mov sp, bp - pop bp - retn -__xfflush endp +include libs/BorlandC/xfflush.asm ; --------------------------------------------------------------------------- db 0 diff --git a/th02_main.asm b/th02_main.asm index c985aae2..10a6f2ed 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -8322,52 +8322,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 1490h - jmp short loc_6DF5 -; --------------------------------------------------------------------------- - -loc_6DD9: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_6DEE - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_6DEE: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_6DF5: - cmp [bp+var_6], 0 - jnz short loc_6DD9 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th02_maine.asm b/th02_maine.asm index 3932fdeb..b0a23cff 100644 --- a/th02_maine.asm +++ b/th02_maine.asm @@ -5009,52 +5009,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 84Ah - jmp short loc_51F5 -; --------------------------------------------------------------------------- - -loc_51D9: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_51EE - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_51EE: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_51F5: - cmp [bp+var_6], 0 - jnz short loc_51D9 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th02_op.asm b/th02_op.asm index 91917d50..11ea5ea3 100644 --- a/th02_op.asm +++ b/th02_op.asm @@ -5288,52 +5288,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 0C60h - jmp short loc_5842 -; --------------------------------------------------------------------------- - -loc_5826: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_583B - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_583B: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5842: - cmp [bp+var_6], 0 - jnz short loc_5826 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th03_main.asm b/th03_main.asm index a7eeb585..3dbead6d 100644 --- a/th03_main.asm +++ b/th03_main.asm @@ -5364,52 +5364,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 0C1Ch - jmp short loc_5377 -; --------------------------------------------------------------------------- - -loc_535B: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_5370 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_5370: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5377: - cmp [bp+var_6], 0 - jnz short loc_535B - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th03_mainl.asm b/th03_mainl.asm index 090be1a0..998eed9f 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -4703,52 +4703,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 0CD4h - jmp short loc_5245 -; --------------------------------------------------------------------------- - -loc_5229: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_523E - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_523E: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5245: - cmp [bp+var_6], 0 - jnz short loc_5229 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th03_op.asm b/th03_op.asm index 212a95c4..825d561b 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -5104,52 +5104,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 0B20h - jmp short loc_5527 -; --------------------------------------------------------------------------- - -loc_550B: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_5520 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_5520: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5527: - cmp [bp+var_6], 0 - jnz short loc_550B - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th04_main.asm b/th04_main.asm index 820e33fd..38e67ce9 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -6454,52 +6454,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 24E8h - jmp short loc_6783 -; --------------------------------------------------------------------------- - -loc_6767: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_677C - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_677C: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_6783: - cmp [bp+var_6], 0 - jnz short loc_6767 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th04_maine.asm b/th04_maine.asm index c7326aee..58cbbe68 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -4733,52 +4733,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 938h - jmp short loc_5CEB -; --------------------------------------------------------------------------- - -loc_5CCF: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_5CE4 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_5CE4: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5CEB: - cmp [bp+var_6], 0 - jnz short loc_5CCF - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th04_op.asm b/th04_op.asm index 7532bb87..d037e9a6 100644 --- a/th04_op.asm +++ b/th04_op.asm @@ -5168,52 +5168,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 14FCh - jmp short loc_63AB -; --------------------------------------------------------------------------- - -loc_638F: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_63A4 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_63A4: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_63AB: - cmp [bp+var_6], 0 - jnz short loc_638F - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th05_main.asm b/th05_main.asm index 421487a4..36e69ec3 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -6635,52 +6635,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 20C6h - jmp short loc_6AAF -; --------------------------------------------------------------------------- - -loc_6A93: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_6AA8 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_6AA8: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_6AAF: - cmp [bp+var_6], 0 - jnz short loc_6A93 - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th05_maine.asm b/th05_maine.asm index ebe17944..bed94865 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -5077,52 +5077,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 1808h - jmp short loc_61D7 -; --------------------------------------------------------------------------- - -loc_61BB: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_61D0 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_61D0: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_61D7: - cmp [bp+var_6], 0 - jnz short loc_61BB - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th05_op.asm b/th05_op.asm index 38dec53d..c9d12860 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -4900,52 +4900,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 - -__xfflush 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], 4 - mov word ptr [bp+stream+2], ds - mov word ptr [bp+stream], 2884h - jmp short loc_5FFB -; --------------------------------------------------------------------------- - -loc_5FDF: - les bx, [bp+stream] - test byte ptr es:[bx+2], 3 - jz short loc_5FF4 - push word ptr [bp+stream+2] - push bx ; stream - nop - call _fflush - pop cx - pop cx - -loc_5FF4: - dec [bp+var_6] - add word ptr [bp+stream], 14h - -loc_5FFB: - cmp [bp+var_6], 0 - jnz short loc_5FDF - pop di - pop si - mov sp, bp - pop bp - retf -__xfflush endp - +include libs/BorlandC/xfflush.asm ; =============== S U B R O U T I N E =======================================