From 14b2adad93709df99aebc927cc8a20d5a40e22eb Mon Sep 17 00:00:00 2001 From: Jali Date: Thu, 18 Dec 2025 18:41:02 +0100 Subject: [PATCH] Refactor the print output. --- src/sudoku.s | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/sudoku.s b/src/sudoku.s index f9069a3..2606893 100644 --- a/src/sudoku.s +++ b/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.