home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUILLET
/
STRWRT.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-10-07
|
2KB
|
71 lines
;─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
;Msg : 343 of 374
;From : Wilbert van Leijen 2:281/256.14 26 Jun 93 19:36
;To : BRIAN PAPE
;Subj : WriteString routine (asm)
;────────────────────────────────────────────────────────────────────────────────
;21 Jun 93, BRIAN PAPE writes to ALL:
;
; BP> Ok, I was writing a little program that I was trying to make as small as
; BP> possible, so I wrote this little WriteString function.
;
;Beat this (32 bytes):
;
LOCALS
MODEL SMALL
.DATA
CrLf DB 13, 10, '$'
.CODE
Public STRWRITE, STRWRITELN
; Turbo Pascal declaration:
; Procedure StrWrite(s : PChar); Near; External;
; Procedure StrWriteLn(s : PChar); Near; External;
; C small model declaration:
; extern void near pascal STRWRITE(char far *s);
; extern void near pascal STRWRITELN(char far *s);
STRWRITELN PROC
STC
JMP Short @@1
STRWRITE: CLC
@@1: MOV BX, SP
PUSH DI DS
PUSHF
LES DI, SS:[BX+2]
LDS DX, SS:[BX+2]
; Scan up to 64 kByte for null byte
MOV CX, -1
MOV AX, 0900h
CLD
REPNE SCASB
DEC DI
; Put end of string marker, display string
MOV Byte Ptr [DI], '$'
INT 21h
; Restore null byte
SUB Byte Ptr [DI], '$'
; Write out new line if carry flag is set
POPF
POP DS
JNC @@2
LEA DX, CrLf
INT 21h
@@2: POP DI
RETN 4
STRWRITELN ENDP
END