diff --git a/libs/BorlandC/fputs.asm b/libs/BorlandC/fputs.asm new file mode 100644 index 00000000..0464429d --- /dev/null +++ b/libs/BorlandC/fputs.asm @@ -0,0 +1,53 @@ +; int __cdecl fputs(const char *s, FILE *fp) +public _fputs +_fputs proc DIST +@@len = word ptr -2 +@@s = DPTR_ dPtrSize + 2 +@@fp = DPTR_ dPtrSize + 2 + dPtrSize + + push bp + mov bp, sp + sub sp, 2 + push si + push di + mov ax, word ptr [bp+@@s] + or ax, word ptr [bp+@@s+2] + jz short @@ret0 + push word ptr [bp+@@s+2] + push word ptr [bp+@@s] + nopcall _strlen + pop cx + pop cx + mov [bp+@@len], ax + or ax, ax + jnz short @@put + +@@ret0: + xor ax, ax + jmp short @@ret + +@@put: + push word ptr [bp+@@s+2] + push word ptr [bp+@@s] + push [bp+@@len] + push word ptr [bp+@@fp+2] + push word ptr [bp+@@fp] + call __FPUTN + or ax, ax + jz short @@retEOF + les bx, [bp+@@s] + add bx, [bp+@@len] + mov al, es:[bx-1] + mov ah, 0 + jmp short @@ret + +@@retEOF: + mov ax, 0FFFFh + +@@ret: + pop di + pop si + mov sp, bp + pop bp + ret +_fputs endp diff --git a/th01_op.asm b/th01_op.asm index 7c7cb636..a1485945 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -7559,69 +7559,7 @@ arg_8 = byte ptr 0Eh retf _fprintf endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: library function bp-based frame - -; int __cdecl fputs(const char *s, FILE *stream) -_fputs proc far - -len = word ptr -2 -buf = dword ptr 6 -stream = dword ptr 0Ah - - push bp - mov bp, sp - sub sp, 2 - push si - push di - mov ax, word ptr [bp+buf] - or ax, word ptr [bp+buf+2] - jz short loc_41BC - push word ptr [bp+buf+2] - push word ptr [bp+buf] ; s - nop - push cs - call near ptr _strlen - pop cx - pop cx - mov [bp+len], ax - or ax, ax - jnz short loc_41C0 - -loc_41BC: - xor ax, ax - jmp short loc_41E7 -; --------------------------------------------------------------------------- - -loc_41C0: - push word ptr [bp+buf+2] - push word ptr [bp+buf] ; buf - push [bp+len] ; len - push word ptr [bp+stream+2] - push word ptr [bp+stream] ; stream - call __FPUTN - or ax, ax - jz short loc_41E4 - les bx, [bp+buf] - add bx, [bp+len] - mov al, es:[bx-1] - mov ah, 0 - jmp short loc_41E7 -; --------------------------------------------------------------------------- - -loc_41E4: - mov ax, 0FFFFh - -loc_41E7: - pop di - pop si - mov sp, bp - pop bp - retf -_fputs endp - +include libs/BorlandC/fputs.asm ; =============== S U B R O U T I N E =======================================