Print the loaded field on screen

This commit is contained in:
2025-09-28 00:42:42 +02:00
parent 1a623be950
commit e26dba93c0

View File

@@ -42,7 +42,8 @@ START: MOVE P,[-PDLLEN,,PDL-1] ;Initialize the stack.
MOVEI A,FNAME1 ;Store the first file name in A MOVEI A,FNAME1 ;Store the first file name in A
MOVEI B,FNAME2 ;Store the second file name in B MOVEI B,FNAME2 ;Store the second file name in B
MOVEI C,FIELD ;Store the address of field in C MOVEI C,FIELD ;Store the address of field in C
PUSHJ P,IMPRTF ;Load the file PUSHJ P,IMPRTF ;Load the file
PUSHJ P,PFIELD ;Print thee loaded field.
JRST DONE ;Jump to the end of the program. JRST DONE ;Jump to the end of the program.
@@ -100,6 +101,37 @@ PUTLN: PUSHJ P,OUTSTR ;Calls the OUTSTR subroutine
.IOT CHTTYO,[^J] ;and a new line .IOT CHTTYO,[^J] ;and a new line
POPJ P, ;before returning. POPJ P, ;before returning.
;Subroutine to that prints the entire play field.
;The contents of the field is expected in FIELD
PFIELD: PUSH P,A ;Save the A register.
PUSH P,B ;Save the contents of register B.
PUSH P,X ;Save the contents of the index register.
PUSH P,Y ;Save the contents of the Y register
MOVE X,[440400,,FIELD] ;Store a bytepointer in X.
PFIELN: .IOT CHTTYO,[^M] ;Print a carriage return.
.IOT CHTTYO,[^J] ;Print a new line.
MOVE A,[BPTR,,HLINE] ;Print a horizontal line.
POPJ P,PUTLN
MOVEI Y,011 ;Load the index register with 9.
MOVEI B,174 ;Print a '|' symbol.
.IOT CHTTYO,B
PFIENO: MOVEi B,020 ;Print a space.
.IOT CHTTYO,B
ILDB B,X ;Load the next field.
JUMPE B,PFIEEX ;Exit, if no more elements are read.
ADDI B,060 ;Convert number into char.
.IOT CHTTYO,B ;Print the number.
.IOT CHTTYO,[ ] ;Print a space.
.IOT CHTTYO,[|] ;Print the vertical line.
SOJE Y,PFIELN ;End the line and start a new one.
JUMPA PFIENO ;Jump back to print the next number.
PFIEEX: POP P,Y ;Restore the Y register.
POP P,X ;Restore the index register.
POP P,B ;Restore the B register.
POP P,A ;Restore the A register.
POPJ P, ;Return from the subroutine.
;Subroutine that reads the contents of the file into the buffer at FIELD ;Subroutine that reads the contents of the file into the buffer at FIELD
IMPRTF: PUSH P,A ;Save the A register. IMPRTF: PUSH P,A ;Save the A register.
PUSH P,X ;Save the index register. PUSH P,X ;Save the index register.
@@ -126,4 +158,5 @@ IMPREX: .CALL [SETZ ? SIXBIT/CLOSE/ ;Close the file, before returning.
DONE: .LOGOUT 2, ;Exit point for the program. DONE: .LOGOUT 2, ;Exit point for the program.
WELCOME:ASCIZ /SUDOKU SOLVER v0.1/ ;Text of the welcome banner. WELCOME:ASCIZ /SUDOKU SOLVER v0.1/ ;Text of the welcome banner.
LOADING:ASCIZ /LOADING / ;Load message. LOADING:ASCIZ /LOADING / ;Load message.
HLINE: ASCIZ /|---|---|---|---|---|---|---|---|---|/ ;A horizontal line.
END START END START