Skip to content

Commit

Permalink
[Reduction] #537-539: sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlgc committed Oct 14, 2014
1 parent 3457818 commit d6449b2
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 318 deletions.
91 changes: 91 additions & 0 deletions libs/BorlandC/sprintf.asm
@@ -0,0 +1,91 @@
; size_t __pascal __near strputn(char *S, size_t n, char **bufPP)
strputn proc near
@@bufPP = DPTR_ (4)
@@n = word ptr (4 + dPtrSize)
@@S = DPTR_ (4 + dPtrSize + 2)

push bp
mov bp, sp
push si
push di
push [bp+@@n]
push word ptr [bp+@@S+2]
push word ptr [bp+@@S]
LES_ bx, [bp+@@bufPP]
push word ptr ES_[bx+2]
push word ptr ES_[bx]
nopcall _memcpy
add sp, (2 + dPtrSize + dPtrSize)
mov ax, [bp+@@n]
LES_ bx, [bp+@@bufPP]
add ES_[bx], ax
push bx
push es
mov es, word ptr ES_[bx+2]
mov ax, es
pop es
pop bx
mov bx, ES_[bx]
mov es, ax
mov byte ptr ES_[bx], 0
mov ax, [bp+@@n]
pop di
pop si
pop bp
ret (4 + dPtrSize + 2)
strputn endp

; int __far sprintf(char *bufP, const char *fmt, ...)
_sprintf proc DIST
@@bufP = DPTR_ (cPtrSize + 2)
@@fmt = DPTR_ (cPtrSize + 2 + dPtrSize)
@@va = byte ptr (cPtrSize + 2 + dPtrSize + dPtrSize)

push bp
mov bp, sp
push si
push di
LES_ bx, [bp+@@bufP]
mov byte ptr ES_[bx], 0
mov ax, offset strputn
push ax
push ss
lea ax, [bp+@@bufP]
push ax
push word ptr [bp+@@fmt+2]
push word ptr [bp+@@fmt]
lea ax, [bp+@@va]
push ax
call __vprinter
pop di
pop si
pop bp
ret
_sprintf endp

; int __cdecl __far vsprintf(char *@@bufP, const char *@@fmt, va_list @@ap)
_vsprintf proc DIST
@@bufP = DPTR_ (cPtrSize + 2)
@@fmt = DPTR_ (cPtrSize + 2 + dPtrSize)
@@ap = DPTR_ (cPtrSize + 2 + dPtrSize + dPtrSize)

push bp
mov bp, sp
push si
push di
LES_ bx, [bp+@@bufP]
mov byte ptr ES_[bx], 0
mov ax, offset strputn
push ax
push ss
lea ax, [bp+@@bufP]
push ax
push word ptr [bp+@@fmt+2]
push word ptr [bp+@@fmt]
push word ptr [bp+@@ap]
call __vprinter
pop di
pop si
pop bp
ret
_vsprintf endp
111 changes: 1 addition & 110 deletions th01_fuuin.asm
Expand Up @@ -5054,116 +5054,7 @@ j____read endp
include libs/BorlandC/srchenv.asm
include libs/BorlandC/srchstr.asm
include libs/BorlandC/setvbuf.asm

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

; Attributes: bp-based frame

sub_53EC proc near

arg_0 = dword ptr 4
n = word ptr 8
_src = dword ptr 0Ah

push bp
mov bp, sp
push si
push di
push [bp+n] ; n
push word ptr [bp+_src+2]
push word ptr [bp+_src] ; src
les bx, [bp+arg_0]
push word ptr es:[bx+2]
push word ptr es:[bx] ; dest
nopcall _memcpy
add sp, 0Ah
mov ax, [bp+n]
les bx, [bp+arg_0]
add es:[bx], ax
push bx
push es
mov es, word ptr es:[bx+2]
mov ax, es
pop es
pop bx
mov bx, es:[bx]
mov es, ax
mov byte ptr es:[bx], 0
mov ax, [bp+n]
pop di
pop si
pop bp
retn 0Ah
sub_53EC endp


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

; Attributes: library function bp-based frame

; int sprintf(char *buffer, const char *format, ...)
_sprintf proc far

@@buffer = dword ptr 6
_format = dword ptr 0Ah
arg_8 = byte ptr 0Eh

push bp
mov bp, sp
push si
push di
les bx, [bp+@@buffer]
mov byte ptr es:[bx], 0
mov ax, 53ECh
push ax
push ss
lea ax, [bp+@@buffer]
push ax
push word ptr [bp+_format+2]
push word ptr [bp+_format]
lea ax, [bp+arg_8]
push ax
call __VPRINTER
pop di
pop si
pop bp
retf
_sprintf endp


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

; Attributes: library function bp-based frame

; int __cdecl vsprintf(char *buffer, const char *format, void *arglist)
_vsprintf proc far

@@buffer = dword ptr 6
_format = word ptr 0Ah
arg_6 = word ptr 0Ch
_arglist = word ptr 0Eh

push bp
mov bp, sp
push si
push di
les bx, [bp+@@buffer]
mov byte ptr es:[bx], 0
mov ax, 53ECh
push ax
push ss
lea ax, [bp+@@buffer]
push ax
push [bp+arg_6]
push [bp+_format]
push [bp+_arglist]
call __VPRINTER
pop di
pop si
pop bp
retf
_vsprintf endp

include libs/BorlandC/sprintf.asm
include libs/BorlandC/_strcat.asm
include libs/BorlandC/_strcmp.asm
include libs/BorlandC/_strcpy.asm
Expand Down
100 changes: 1 addition & 99 deletions th01_op.asm
Expand Up @@ -4636,105 +4636,7 @@ include libs/BorlandC/read.asm
include libs/BorlandC/srchenv.asm
include libs/BorlandC/srchstr.asm
include libs/BorlandC/setvbuf.asm

; ---------------------------------------------------------------------------
push bp
mov bp, sp
push si
push di
push word ptr [bp+8]
push word ptr [bp+0Ch]
push word ptr [bp+0Ah]
les bx, [bp+4]
push word ptr es:[bx+2]
push word ptr es:[bx]
nopcall _memcpy
add sp, 0Ah
mov ax, [bp+8]
les bx, [bp+4]
add es:[bx], ax
push bx
push es
mov es, word ptr es:[bx+2]
mov ax, es
pop es
pop bx
mov bx, es:[bx]
mov es, ax
mov byte ptr es:[bx], 0
mov ax, [bp+8]
pop di
pop si
pop bp
retn 0Ah

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

; Attributes: library function bp-based frame

; int sprintf(char *buffer, const char *format, ...)
_sprintf proc far

@@buffer = dword ptr 6
_format = dword ptr 0Ah
arg_8 = byte ptr 0Eh

push bp
mov bp, sp
push si
push di
les bx, [bp+@@buffer]
mov byte ptr es:[bx], 0
mov ax, 566Ah
push ax
push ss
lea ax, [bp+@@buffer]
push ax
push word ptr [bp+_format+2]
push word ptr [bp+_format]
lea ax, [bp+arg_8]
push ax
call __VPRINTER
pop di
pop si
pop bp
retf
_sprintf endp


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

; Attributes: library function bp-based frame

; int __cdecl vsprintf(char *buffer, const char *format, void *arglist)
_vsprintf proc far

@@buffer = dword ptr 6
_format = word ptr 0Ah
arg_6 = word ptr 0Ch
arglist = word ptr 0Eh

push bp
mov bp, sp
push si
push di
les bx, [bp+@@buffer]
mov byte ptr es:[bx], 0
mov ax, 566Ah
push ax
push ss
lea ax, [bp+@@buffer]
push ax
push [bp+arg_6]
push [bp+_format]
push [bp+arglist]
call __VPRINTER
pop di
pop si
pop bp
retf
_vsprintf endp

include libs/BorlandC/sprintf.asm
include libs/BorlandC/_strcat.asm
include libs/BorlandC/_strcmp.asm
include libs/BorlandC/_strcpy.asm
Expand Down

0 comments on commit d6449b2

Please sign in to comment.