Split OUTSTR and PUTLN into two subroutines.
This commit is contained in:
@@ -15,21 +15,31 @@ PDL: BLOCK PDLLEN ;Reserve the stack memory
|
|||||||
BPTR==440700 ;Define a byte pointer.
|
BPTR==440700 ;Define a byte pointer.
|
||||||
|
|
||||||
CHTTYO==1 ;Define a channel for TTY output.
|
CHTTYO==1 ;Define a channel for TTY output.
|
||||||
|
CHTTYI==2 ;Define a channel for TTY input.
|
||||||
|
|
||||||
START: MOVE P,[-PDLLEN,,PDL-1] ;Initialize the stack.
|
START: MOVE P,[-PDLLEN,,PDL-1] ;Initialize the stack.
|
||||||
.OPEN CHTTYO,[.UAO,,'TTY] ;Open an output channel on the TTY.
|
.OPEN CHTTYO,[.UAO,,'TTY] ;Open an output channel on the TTY.
|
||||||
.LOSE %LSFIL ;Gobble up any errors.
|
.LOSE %LSFIL ;Gobble up any errors.
|
||||||
MOVE A,[BPTR,,HELLO] ;Load A with a byte pointer to HELLO.
|
MOVE A,[BPTR,,HELLO] ;Load A with a byte pointer to HELLO.
|
||||||
PUSHJ P,OUTSTR ;Print the out string.
|
PUSHJ P,PUTLN ;Print the out string.
|
||||||
JRST DONE ;Jump to the end of the program.
|
JRST DONE ;Jump to the end of the program.
|
||||||
|
|
||||||
|
;Subroutine to print a string of text on the output.
|
||||||
|
; Clobbers A and B.
|
||||||
OUTSTR: HRLI A,BPTR ;Ensure, A is a byte pointer.
|
OUTSTR: HRLI A,BPTR ;Ensure, A is a byte pointer.
|
||||||
OUT: ILDB B,A ;Load the next byte from A.
|
OUT: ILDB B,A ;Load the next byte from A.
|
||||||
JUMPE B,OUTEX ;Exit the routine, if all bytes are done.
|
JUMPE B,OUTEX ;Exit the routine, if all bytes are done.
|
||||||
.IOT CHTTYO,B ;Print a character.
|
.IOT CHTTYO,B ;Print a character.
|
||||||
JRST OUT ;Jump back to print the next character.
|
JRST OUT ;Jump back to print the next character.
|
||||||
OUTEX: .IOT CHTTYO,[^M] ;Print carriage return and
|
OUTEX: POPJ P, ;Return from the output routine.
|
||||||
.IOT CHTTYO,[^J] ;newline characters.
|
|
||||||
POPJ P, ;Return from the subroutine.
|
;Subroutine to print an entire line of text, including a line break.
|
||||||
|
;Clobbers A and B.
|
||||||
|
PUTLN: PUSHJ P,OUTSTR ;Calls the OUTSTR subroutine
|
||||||
|
.IOT CHTTYO,[^M] ;Print a carriage return
|
||||||
|
.IOT CHTTYO,[^J] ;and a new line
|
||||||
|
POPJ P, ;before returning.
|
||||||
|
|
||||||
DONE: .LOGOUT 2, ;Exit point for the program.
|
DONE: .LOGOUT 2, ;Exit point for the program.
|
||||||
HELLO: ASCIZ /HELLO WORLD/ ;Define example string.
|
HELLO: ASCIZ /HELLO WORLD/ ;Define example string.
|
||||||
END START
|
END START
|
||||||
|
|||||||
Reference in New Issue
Block a user