From daabf257d14763ba19d8d2628ddbac37cf4fd1ed Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 30 Aug 2014 04:26:12 +0200 Subject: [PATCH] [Reduction] #357: C++ new[] operator --- libs/BorlandC/newarray.asm | 17 ++++++ th01_fuuin.asm | 35 +++---------- th01_op.asm | 55 ++++++-------------- th01_reiiden.asm | 103 ++++++++++++++----------------------- th01_reiiden_2.inc | 22 ++++---- 5 files changed, 89 insertions(+), 143 deletions(-) create mode 100644 libs/BorlandC/newarray.asm diff --git a/libs/BorlandC/newarray.asm b/libs/BorlandC/newarray.asm new file mode 100644 index 00000000..773fc2c0 --- /dev/null +++ b/libs/BorlandC/newarray.asm @@ -0,0 +1,17 @@ +; operator new[](unsigned int) + public @$bnwa$qui +@$bnwa$qui proc DIST +@@size = word ptr 2 + dPtrSize + + push bp + mov bp, sp + push si + push di + push [bp+@@size] + nopcall @$bnew$qui ; operator new(uint) + pop cx + pop di + pop si + pop bp + ret +@$bnwa$qui endp diff --git a/th01_fuuin.asm b/th01_fuuin.asm index d7fbabda..7a56a371 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -4345,30 +4345,7 @@ loc_228F: __TMPNAM endp include libs/BorlandC/new.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_25B9 proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - push [bp+arg_0] - nop - push cs - call near ptr @$bnew$qui ; operator new(uint) - pop cx - pop di - pop si - pop bp - retf -sub_25B9 endp - +include libs/BorlandC/newarray.asm include libs/BorlandC/N_LXMUL.ASM include libs/BorlandC/N_PCMP.ASM include libs/BorlandC/reada.asm @@ -11731,22 +11708,22 @@ loc_A6DE: loc_A6E4: push 0A0h ; ' ' - call sub_25B9 + call @$bnwa$qui pop cx mov word ptr font+2, dx mov word ptr font, ax push 14h - call sub_25B9 + call @$bnwa$qui pop cx mov word ptr off_1402C+2, dx mov word ptr off_1402C, ax push 14h - call sub_25B9 + call @$bnwa$qui pop cx mov word ptr off_14028+2, dx mov word ptr off_14028, ax push 28h ; '(' - call sub_25B9 + call @$bnwa$qui pop cx mov word ptr off_14034+2, dx mov word ptr off_14034, ax @@ -21368,7 +21345,7 @@ arg_2 = word ptr 8 push si xor si, si push 4000h - call sub_25B9 + call @$bnwa$qui pop cx mov word_1464C, dx mov off_1464A, ax diff --git a/th01_op.asm b/th01_op.asm index 0d2ad20c..64b014f8 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -4185,30 +4185,7 @@ loc_22F7: __TMPNAM endp include libs/BorlandC/new.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_2621 proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - push [bp+arg_0] - nop - push cs - call near ptr @$bnew$qui ; operator new(uint) - pop cx - pop di - pop si - pop bp - retf -sub_2621 endp - +include libs/BorlandC/newarray.asm include libs/BorlandC/N_LXMUL.ASM include libs/BorlandC/N_PCMP.ASM include libs/BorlandC/reada.asm @@ -10506,7 +10483,7 @@ seg001 segment byte public 'CODE' use16 loc_A1CE: push 190h - call sub_2621 + call @$bnwa$qui pop cx mov bx, si shl bx, 2 @@ -17557,7 +17534,7 @@ loc_D677: mov ax, [bp+var_4] imul ax, 281h push ax - call sub_2621 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -17679,7 +17656,7 @@ loc_D78B: mov ax, [bp+8] imul ax, 281h push ax - call sub_2621 + call @$bnwa$qui pop cx mov bx, si shl bx, 2 @@ -18099,7 +18076,7 @@ arg_0 = dword ptr 6 push si xor si, si push 4000h - call sub_2621 + call @$bnwa$qui pop cx mov word ptr font+2, dx mov word ptr font, ax @@ -18497,7 +18474,7 @@ sub_DC1B endp or ax, ax jz loc_DEEF push 64h ; 'd' - call sub_2621 + call @$bnwa$qui pop cx mov [bp-6], dx mov [bp-8], ax @@ -18547,7 +18524,7 @@ loc_DE53: loc_DE82: push word ptr [bp-2] - call sub_2621 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -18581,7 +18558,7 @@ loc_DEAA: loc_DEC8: push word ptr [bp-4] - call sub_2621 + call @$bnwa$qui pop cx mov bx, di shl bx, 6 @@ -18656,7 +18633,7 @@ loc_DF5C: or ax, ax jz loc_DFFF push 64h ; 'd' - call sub_2621 + call @$bnwa$qui pop cx mov [bp-2], dx mov [bp-4], ax @@ -18702,7 +18679,7 @@ loc_DFBD: loc_DFE2: push di - call sub_2621 + call @$bnwa$qui pop cx mov bx, si shl bx, 2 @@ -18814,7 +18791,7 @@ sub_E02B endp or ax, ax jz loc_E213 push 64h ; 'd' - call sub_2621 + call @$bnwa$qui pop cx mov [bp-6], dx mov [bp-8], ax @@ -18896,7 +18873,7 @@ loc_E170: loc_E1A7: push word ptr [bp-2] - call sub_2621 + call @$bnwa$qui pop cx mov bx, [bp+6] shl bx, 2 @@ -18929,7 +18906,7 @@ loc_E1CD: loc_E1EC: push word ptr [bp-4] - call sub_2621 + call @$bnwa$qui pop cx mov bx, [bp+6] shl bx, 6 @@ -19460,7 +19437,7 @@ seg012 segment byte public 'CODE' use16 push si push di push 800h - call sub_2621 + call @$bnwa$qui pop cx mov word ptr dword_13EEA+2, dx mov word ptr dword_13EEA, ax @@ -19817,14 +19794,14 @@ loc_E80B: mov word_13F0D, 0 les bx, dword_13EEE push word ptr es:[bx+14h] - call sub_2621 + call @$bnwa$qui pop cx mov word ptr off_13EF8+2, dx mov word ptr off_13EF8, ax cmp byte_13EF6, 0 jz short loc_E85D push 100h - call sub_2621 + call @$bnwa$qui pop cx mov word ptr off_13EFC+2, dx mov word ptr off_13EFC, ax diff --git a/th01_reiiden.asm b/th01_reiiden.asm index d01ddfdb..90f92c34 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -6072,30 +6072,7 @@ loc_2B79: __TMPNAM endp include libs/BorlandC/new.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_2EA3 proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - push [bp+arg_0] - nop - push cs - call near ptr @$bnew$qui ; operator new(uint) - pop cx - pop di - pop si - pop bp - retf -sub_2EA3 endp - +include libs/BorlandC/newarray.asm ; =============== S U B R O U T I N E ======================================= @@ -7643,9 +7620,7 @@ loc_3899: loc_38C3: push [bp+var_1C] - nop - push cs - call near ptr sub_2EA3 + nopcall @$bnwa$qui pop cx mov word ptr [bp+arg_0+2], dx mov word ptr [bp+arg_0], ax @@ -24974,7 +24949,7 @@ loc_10739: mov ax, [bp+var_4] imul ax, 281h push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -25105,7 +25080,7 @@ loc_1084D: mov ax, [bp+arg_2] imul ax, 281h push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, si shl bx, 2 @@ -25598,7 +25573,7 @@ arg_0 = dword ptr 6 push si xor si, si push 4000h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_38E28+2, dx mov word ptr off_38E28, ax @@ -26040,7 +26015,7 @@ arg_2 = dword ptr 8 or ax, ax jz loc_10FB1 push 64h ; 'd' - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr [bp+_font+2], dx mov word ptr [bp+_font], ax @@ -26090,7 +26065,7 @@ loc_10F15: loc_10F44: push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -26124,7 +26099,7 @@ loc_10F6C: loc_10F8A: push [bp+var_4] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 6 @@ -26211,7 +26186,7 @@ arg_2 = dword ptr 8 or ax, ax jz loc_110C1 push 64h ; 'd' - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr [bp+_font+2], dx mov word ptr [bp+_font], ax @@ -26257,7 +26232,7 @@ loc_1107F: loc_110A4: push di - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, si shl bx, 2 @@ -26386,7 +26361,7 @@ arg_6 = word ptr 0Ch or ax, ax jz loc_112D5 push 64h ; 'd' - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr [bp+s1+2], dx mov word ptr [bp+s1], ax @@ -26468,7 +26443,7 @@ loc_11232: loc_11269: push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_0] shl bx, 2 @@ -26501,7 +26476,7 @@ loc_1128F: loc_112AE: push [bp+var_4] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_0] shl bx, 6 @@ -30097,12 +30072,12 @@ _font = dword ptr -4 mov [bp+var_A], 0 mov [bp+var_10], 1 push 320h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr [bp+_font+2], dx mov word ptr [bp+_font], ax push 320h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr [bp+var_8+2], dx mov word ptr [bp+var_8], ax @@ -31646,22 +31621,22 @@ loc_13B01: loc_13B07: push 0A0h ; ' ' - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39452+2, dx mov word ptr off_39452, ax push 14h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_3945A+2, dx mov word ptr off_3945A, ax push 14h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39456+2, dx mov word ptr off_39456, ax push 28h ; '(' - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39462+2, dx mov word ptr off_39462, ax @@ -33800,7 +33775,7 @@ loc_14BF4: loc_14C45: push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -33809,7 +33784,7 @@ loc_14C45: mov es:[si+2], dx mov es:[si], ax push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -33818,7 +33793,7 @@ loc_14C45: mov es:[si+82h], dx mov es:[si+80h], ax push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -33827,7 +33802,7 @@ loc_14C45: mov es:[si+102h], dx mov es:[si+100h], ax push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -33836,7 +33811,7 @@ loc_14C45: mov es:[si+182h], dx mov es:[si+180h], ax push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di shl bx, 2 @@ -34993,7 +34968,7 @@ loc_156F5: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -35008,7 +34983,7 @@ loc_156F5: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -35023,7 +34998,7 @@ loc_156F5: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -35038,7 +35013,7 @@ loc_156F5: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -35053,7 +35028,7 @@ loc_156F5: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -37494,7 +37469,7 @@ loc_16BBA: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -37509,7 +37484,7 @@ loc_16BBA: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -37524,7 +37499,7 @@ loc_16BBA: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -37539,7 +37514,7 @@ loc_16BBA: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -37554,7 +37529,7 @@ loc_16BBA: sar ax, 1 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, [bp+arg_8] imul bx, 0A0h @@ -38061,7 +38036,7 @@ arg_0 = dword ptr 6 push si push di push 800h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39A34+2, dx mov word ptr off_39A34, ax @@ -38427,14 +38402,14 @@ loc_1735E: mov word_39A57, 0 les bx, dword_39A38 push word ptr es:[bx+14h] - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39A42+2, dx mov word ptr off_39A42, ax cmp byte_39A40, 0 jz short loc_173B0 push 100h - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39A46+2, dx mov word ptr off_39A46, ax @@ -38647,7 +38622,7 @@ loc_174C8: loc_174F9: push [bp+var_2] - call sub_2EA3 + call @$bnwa$qui pop cx mov bx, di imul bx, 26h @@ -41827,7 +41802,7 @@ arg_0 = dword ptr 6 mov si, [bp+var_38] mov word_39DA2, si push si - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr node+2, dx mov word ptr node, ax diff --git a/th01_reiiden_2.inc b/th01_reiiden_2.inc index 3b704e1b..573f946d 100644 --- a/th01_reiiden_2.inc +++ b/th01_reiiden_2.inc @@ -9913,38 +9913,38 @@ loc_2099C: mov ax, word_39E90 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr font+2, dx mov word ptr font, ax mov ax, word_39E90 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39E88+2, dx mov word ptr off_39E88, ax push word_39E90 - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39E8C+2, dx mov word ptr off_39E8C, ax mov ax, word_39E90 add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39E92+2, dx mov word ptr off_39E92, ax push word_39E90 - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39E96+2, dx mov word ptr off_39E96, ax mov ax, word_39E90 shl ax, 2 push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39EAC+2, dx mov word ptr off_39EAC, ax @@ -9956,26 +9956,26 @@ loc_20A27: mov ax, word_39EAA add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39E9A+2, dx mov word ptr off_39E9A, ax mov ax, word_39EAA add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39E9E+2, dx mov word ptr off_39E9E, ax push word_39EAA - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39EA2+2, dx mov word ptr off_39EA2, ax mov ax, word_39EAA add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39EA6+2, dx mov word ptr off_39EA6, ax @@ -11125,7 +11125,7 @@ loc_2132D: mov ax, word_39EAA add ax, ax push ax - call sub_2EA3 + call @$bnwa$qui pop cx mov word ptr off_39EB3+2, dx mov word ptr off_39EB3, ax