Refactor the print output.
This commit is contained in:
18
src/sudoku.s
18
src/sudoku.s
@@ -21,25 +21,14 @@ FNAME1: BLOCK 15 ;The first part of the file name.
|
||||
FNAME2: BLOCK 15 ;The second file name.
|
||||
FIELD: BLOCK 9 ;Reserve 9 words to store the grid.
|
||||
|
||||
;Print flags
|
||||
;Allows to change the beavihour of the OUTSTR and PUTLN subroutines.
|
||||
;The different bits in the word have different meanings.
|
||||
;Flags:
|
||||
; 001 - SIXBIT: Prints the next character as a SIXBIT char, instead of ASCII, if set.
|
||||
PFLAGS: BLOCK 1
|
||||
|
||||
START: MOVE P,[-PDLLEN,,PDL-1] ;Initialize the stack.
|
||||
.OPEN CHTTYO,[.UAO,,'TTY] ;Open an output channel on the TTY.
|
||||
.LOSE %LSFIL ;Gobble up any errors.
|
||||
MOVEI A,000 ;Initialize the print flag
|
||||
MOVEM A,PFLAGS ;to print ASCII
|
||||
MOVE A,[440700,,WELCOME] ;Print the welcome message
|
||||
PUSHJ P,PUTLN
|
||||
PUSHJ P,GETJCL ;Read the command line.
|
||||
MOVE A,[440700,,LOADING] ;Print the loading message
|
||||
PUSHJ P,OUTSTR
|
||||
MOVEI A,001 ;Pretend the field name is SIXBIT
|
||||
MOVEM A,PFLAGS ;Store flags in PFLAGS
|
||||
MOVE A,[440600,,FNAME1] ;Load FNAME1 into the A
|
||||
PUSHJ P,OUTSTR ;Print the name in a single line
|
||||
MOVE A,[440600,,FNAME2] ;Now repeat with FNAME2
|
||||
@@ -99,15 +88,14 @@ TOSEN: POP P,D ;Restore the D register.
|
||||
;Subroutine to print a string of text on the output.
|
||||
;Clobbers A.
|
||||
OUTSTR: PUSH P,B ;Save register B.
|
||||
PUSH P,D ;Save register D.
|
||||
PUSH P,F ;Save register F.
|
||||
OUT: ILDB B,A ;Load the next byte from A.
|
||||
JUMPE B,OUTEX ;Exit the routine, if all bytes are done.
|
||||
MOVE D,PFLAGS ;Load the print flags.
|
||||
TRNE D,001 ;Test, if the SIXBIT flag is set.
|
||||
TLNN A,000100 ;Test, if the SIXBIT flag is set.
|
||||
ADDI B,40 ;Convert SIXBIT to ASCII.
|
||||
.IOT CHTTYO,B ;Print a character.
|
||||
JRST OUT ;Jump back to print the next character.
|
||||
OUTEX: POP P,D ;Restore D to its original value.
|
||||
OUTEX: POP P,F ;Restore D to its original value.
|
||||
POP P,B ;Restore B to its original value.
|
||||
POPJ P, ;Return from the output routine.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user