Skip to content

Commit

Permalink
[Reduction] #91: stpcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlgc committed Aug 20, 2014
1 parent d3aaca7 commit 9d23be1
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 814 deletions.
38 changes: 38 additions & 0 deletions libs/BorlandC/stpcpy.asm
@@ -0,0 +1,38 @@
; char *_stpcpy(char *to, const char *from)
public _stpcpy
_stpcpy proc DIST

@@len = word ptr -2
@@to = dword ptr 6
@@from = dword ptr 0Ah

push bp
mov bp, sp
sub sp, 2
push si
push di
push word ptr [bp+@@from+2]
push word ptr [bp+@@from] ; s
nop
call _strlen
pop cx
pop cx
mov [bp+@@len], ax
inc ax
push ax ; n
push word ptr [bp+@@from+2]
push word ptr [bp+@@from] ; src
push word ptr [bp+@@to+2]
push word ptr [bp+@@to] ; dest
nop
call _memcpy
add sp, 0Ah
mov dx, word ptr [bp+@@to+2]
mov ax, word ptr [bp+@@to]
add ax, [bp+@@len]
pop di
pop si
mov sp, bp
pop bp
ret
_stpcpy endp
61 changes: 6 additions & 55 deletions th01_fuuin.asm
Expand Up @@ -4355,51 +4355,7 @@ var_2 = word ptr -2
sub_1B5B endp

include libs/BorlandC/__abort.asm

; =============== S U B R O U T I N E =======================================

; Attributes: library function bp-based frame

; char *__cdecl stpcpy(char *dest, const char *src)
_stpcpy proc far

var_2 = word ptr -2
dest = dword ptr 6
_s = dword ptr 0Ah

push bp
mov bp, sp
sub sp, 2
push si
push di
push word ptr [bp+_s+2]
push word ptr [bp+_s] ; s
nop
push cs
call near ptr _strlen
pop cx
pop cx
mov [bp+var_2], ax
inc ax
push ax ; n
push word ptr [bp+_s+2]
push word ptr [bp+_s] ; src
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _memcpy
add sp, 0Ah
mov dx, word ptr [bp+dest+2]
mov ax, word ptr [bp+dest]
add ax, [bp+var_2]
pop di
pop si
mov sp, bp
pop bp
retf
_stpcpy endp

include libs/BorlandC/stpcpy.asm

; =============== S U B R O U T I N E =======================================

Expand Down Expand Up @@ -4599,8 +4555,7 @@ loc_1D17:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down Expand Up @@ -4639,8 +4594,7 @@ loc_1D64:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down Expand Up @@ -5412,8 +5366,7 @@ loc_2238:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
push dx
push ax
Expand Down Expand Up @@ -20409,8 +20362,7 @@ loc_8FAA:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand All @@ -20436,8 +20388,7 @@ loc_9003:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down
62 changes: 6 additions & 56 deletions th01_op.asm
Expand Up @@ -4288,52 +4288,7 @@ var_2 = word ptr -2
sub_1C1B endp

include libs/BorlandC/__abort.asm

; =============== S U B R O U T I N E =======================================

; Attributes: library function bp-based frame

; char *__cdecl stpcpy(char *dest, const char *src)
_stpcpy proc far
; __DOSENV+140p ...

var_2 = word ptr -2
dest = dword ptr 6
_s = dword ptr 0Ah

push bp
mov bp, sp
sub sp, 2
push si
push di
push word ptr [bp+_s+2]
push word ptr [bp+_s] ; s
nop
push cs
call near ptr _strlen
pop cx
pop cx
mov [bp+var_2], ax
inc ax
push ax ; n
push word ptr [bp+_s+2]
push word ptr [bp+_s] ; src
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _memcpy
add sp, 0Ah
mov dx, word ptr [bp+dest+2]
mov ax, word ptr [bp+dest]
add ax, [bp+var_2]
pop di
pop si
mov sp, bp
pop bp
retf
_stpcpy endp

include libs/BorlandC/stpcpy.asm

; =============== S U B R O U T I N E =======================================

Expand Down Expand Up @@ -4536,8 +4491,7 @@ loc_1DD7:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down Expand Up @@ -4577,8 +4531,7 @@ loc_1E24:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down Expand Up @@ -5256,8 +5209,7 @@ loc_22A0:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
push dx
push ax
Expand Down Expand Up @@ -20578,8 +20530,7 @@ loc_9225:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand All @@ -20605,8 +20556,7 @@ loc_927E:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down
61 changes: 6 additions & 55 deletions th01_reiiden.asm
Expand Up @@ -6109,51 +6109,7 @@ var_2 = word ptr -2
sub_2395 endp

include libs/BorlandC/__abort.asm

; =============== S U B R O U T I N E =======================================

; Attributes: library function bp-based frame

; char *__cdecl stpcpy(char *dest, const char *src)
_stpcpy proc far

var_2 = word ptr -2
dest = dword ptr 6
_s = dword ptr 0Ah

push bp
mov bp, sp
sub sp, 2
push si
push di
push word ptr [bp+_s+2]
push word ptr [bp+_s] ; s
nop
push cs
call near ptr _strlen
pop cx
pop cx
mov [bp+var_2], ax
inc ax
push ax ; n
push word ptr [bp+_s+2]
push word ptr [bp+_s] ; src
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _memcpy
add sp, 0Ah
mov dx, word ptr [bp+dest+2]
mov ax, word ptr [bp+dest]
add ax, [bp+var_2]
pop di
pop si
mov sp, bp
pop bp
retf
_stpcpy endp

include libs/BorlandC/stpcpy.asm

; =============== S U B R O U T I N E =======================================

Expand Down Expand Up @@ -6353,8 +6309,7 @@ loc_2551:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down Expand Up @@ -6393,8 +6348,7 @@ loc_259E:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down Expand Up @@ -7256,8 +7210,7 @@ loc_2B22:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
push dx
push ax
Expand Down Expand Up @@ -24167,8 +24120,7 @@ loc_A698:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand All @@ -24194,8 +24146,7 @@ loc_A6F1:
push word ptr [bp+dest+2]
push word ptr [bp+dest] ; dest
nop
push cs
call near ptr _stpcpy
call _stpcpy
add sp, 8
mov word ptr [bp+dest+2], dx
mov word ptr [bp+dest], ax
Expand Down

0 comments on commit 9d23be1

Please sign in to comment.