From 39bf07ac61e42d798e810c5c8ade8ace2416b250 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Wed, 27 Aug 2014 07:05:29 +0200 Subject: [PATCH] [Reduction] #219: memcmp --- libs/BorlandC/memcmp.asm | 36 ++++++++++++++++++++++++++++++++ th01_fuuin.asm | 43 ++------------------------------------- th01_op.asm | 44 ++-------------------------------------- th01_reiiden.asm | 43 ++------------------------------------- th02_main.asm | 43 ++------------------------------------- th02_maine.asm | 43 ++------------------------------------- th02_op.asm | 43 ++------------------------------------- th03_main.asm | 43 ++------------------------------------- th03_mainl.asm | 43 ++------------------------------------- th03_op.asm | 43 ++------------------------------------- th04_main.asm | 43 ++------------------------------------- th04_maine.asm | 43 ++------------------------------------- th04_op.asm | 43 ++------------------------------------- th05_main.asm | 43 ++------------------------------------- th05_maine.asm | 43 ++------------------------------------- th05_op.asm | 43 ++------------------------------------- 16 files changed, 66 insertions(+), 616 deletions(-) create mode 100644 libs/BorlandC/memcmp.asm diff --git a/libs/BorlandC/memcmp.asm b/libs/BorlandC/memcmp.asm new file mode 100644 index 00000000..c64634b9 --- /dev/null +++ b/libs/BorlandC/memcmp.asm @@ -0,0 +1,36 @@ +; int __cdecl memcmp(const void *s1, const void *s2, size_t n) +public _memcmp +_memcmp proc DIST +@@s1 = DPTR_ 2 + dPtrSize +@@s2 = DPTR_ 2 + (dPtrSize * 2) +@@n = word ptr 2 + (dPtrSize * 3) + + push bp + mov bp, sp + push si + push di + push ds + mov ax, [bp+@@n] + mov cx, ax + jcxz short @@mcm_end + LDS_ si, [bp+@@s1] + LES_ di, [bp+@@s2] +ife LDATA + mov ax, ds + mov es, ax +endif + cld + repe cmpsb + mov al, [si-1] + xor ah, ah + mov cl, ES_ [di-1] + xor ch, ch + +@@mcm_end: + popDS_ + sub ax, cx + pop di + pop si + pop bp + ret +_memcmp endp diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 44e7a062..fce85db3 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -8804,44 +8804,7 @@ loc_48DA: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_4901 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_4901: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -16507,9 +16470,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_8893 diff --git a/th01_op.asm b/th01_op.asm index 9e5ab6cc..34a5f8df 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -8683,45 +8683,7 @@ loc_4BBC: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - ; sub_A240+4EP ... - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_4BE3 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_4BE3: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -16355,9 +16317,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_8B0E diff --git a/th01_reiiden.asm b/th01_reiiden.asm index f33c5e39..912158e9 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -12390,44 +12390,7 @@ loc_5F32: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -_s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_5F59 - lds si, [bp+s1] - les di, [bp+_s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_5F59: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -20177,9 +20140,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_9F81 diff --git a/th02_main.asm b/th02_main.asm index 08195265..ad131902 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -9268,44 +9268,7 @@ loc_66FF: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_6726 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_6726: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -16370,9 +16333,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_9E8C diff --git a/th02_maine.asm b/th02_maine.asm index 52c33aca..0c7bff56 100644 --- a/th02_maine.asm +++ b/th02_maine.asm @@ -5228,44 +5228,7 @@ loc_4AFF: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_4B26 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_4B26: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -12279,9 +12242,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_828C diff --git a/th02_op.asm b/th02_op.asm index b676067c..5344b4d4 100644 --- a/th02_op.asm +++ b/th02_op.asm @@ -5311,44 +5311,7 @@ loc_514C: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_5173 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_5173: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -12372,9 +12335,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_88D9 diff --git a/th03_main.asm b/th03_main.asm index ea389bec..ccfc5a2f 100644 --- a/th03_main.asm +++ b/th03_main.asm @@ -5557,44 +5557,7 @@ loc_4C81: retf sub_4C4C endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_4CA8 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_4CA8: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -12617,9 +12580,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_840E diff --git a/th03_mainl.asm b/th03_mainl.asm index 669da84d..af71f97a 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -4771,44 +4771,7 @@ loc_4B4F: retf sub_4B43 endp ; sp-analysis failed - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_4B76 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_4B76: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -11877,9 +11840,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_82DC diff --git a/th03_op.asm b/th03_op.asm index 7bbaf6ab..ddce765e 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -5190,44 +5190,7 @@ loc_4E31: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_4E58 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_4E58: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -12292,9 +12255,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_85BE diff --git a/th04_main.asm b/th04_main.asm index fae9785f..aa3419c9 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -7800,44 +7800,7 @@ loc_608D: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_60B4 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_60B4: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -14905,9 +14868,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_981A diff --git a/th04_maine.asm b/th04_maine.asm index 034b1221..ded1fb2b 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -4683,44 +4683,7 @@ loc_55F5: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_561C - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_561C: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -11739,9 +11702,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_8D82 diff --git a/th04_op.asm b/th04_op.asm index 231ca281..119a1323 100644 --- a/th04_op.asm +++ b/th04_op.asm @@ -5296,44 +5296,7 @@ loc_5CB5: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_5CDC - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_5CDC: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -12399,9 +12362,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_9442 diff --git a/th05_main.asm b/th05_main.asm index af525de8..3aa43e58 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -8186,44 +8186,7 @@ loc_63B9: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_63E0 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_63E0: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -15239,9 +15202,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_9B46 diff --git a/th05_maine.asm b/th05_maine.asm index 3f8a59fd..36a756b4 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -5462,44 +5462,7 @@ loc_5AE1: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_5B08 - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_5B08: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -12516,9 +12479,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_926E diff --git a/th05_op.asm b/th05_op.asm index 2d8f51b0..6311bd3d 100644 --- a/th05_op.asm +++ b/th05_op.asm @@ -4978,44 +4978,7 @@ loc_5905: retf _getenv endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl memcmp(const void *s1, const void *s2, size_t n) -_memcmp proc far - -s1 = dword ptr 6 -s2 = dword ptr 0Ah -n = word ptr 0Eh - - push bp - mov bp, sp - push si - push di - push ds - mov ax, [bp+n] - mov cx, ax - jcxz short loc_592C - lds si, [bp+s1] - les di, [bp+s2] - cld - repe cmpsb - mov al, [si-1] - xor ah, ah - mov cl, es:[di-1] - xor ch, ch - -loc_592C: - pop ds - sub ax, cx - pop di - pop si - pop bp - retf -_memcmp endp - +include libs/BorlandC/memcmp.asm ; =============== S U B R O U T I N E ======================================= @@ -11985,9 +11948,7 @@ arg_6 = word ptr 0Ch push ax ; s2 push word ptr [bp+s1+2] push word ptr [bp+s1] ; s1 - nop - push cs - call near ptr _memcmp + nopcall _memcmp add sp, 0Ah or ax, ax jz short loc_9092