Files
Digital-Research-Source-Code/CONTRIBUTIONS/cpm-handbook/cpmsrc/FIG5-6.ASM
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

46 lines
1.0 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; Figure 5-6
;
; WL$PUN
; Write Line to Punch device. Output terminates
; when a 00H byte is encountered.
; A Carriage Return is output when a Line Feed is
; encountered.
;
; Calling sequence
;
; LXI H,BUFFER
; CALL WL$PUN
;
; Exit Parameters
;
; HL -> 00H byte terminator
;
B$PUNOUT EQU 4
BDOS EQU 5
;
CR EQU 0DH ;Carriage Return
LF EQU 0AH ;Line Feed
;
WL$PUN:
PUSH H ;Save Buffer pointer
MOV A,M ;Get next character
ORA A ;Check if 00H
JZ WL$PUNX ;Yes, exit
CPI LF ;Check if Line Feed
CZ WL$PUNLF ;Yes, O/P CR
MOV E,A ;Character to be output
MVI C,B$PUNOUT ;Function Code
CALL BDOS ;Output character
POP H ;Recover Buffer pointer
INX H ;Update to next char.
JMP WL$PUN ;Output next char
WL$PUNLF: ;Line Feed encountered
MVI C,B$PUNOUT ;Function Code
MVI E,CR ;Output a CR
CALL BDOS
MVI A,LF ;Recreate Line Feed
RET ;Output LF
WL$PUNX: ;Exit
POP H ;Balance the stack
RET