Add bytewise loading of the file.

This commit is contained in:
2025-09-27 23:55:21 +02:00
parent 7e5dea7247
commit 1a623be950

View File

@@ -101,16 +101,27 @@ PUTLN: PUSHJ P,OUTSTR ;Calls the OUTSTR subroutine
POPJ P, ;before returning.
;Subroutine that reads the contents of the file into the buffer at FIELD
IMPRTF: .CALL [SETZ ? SIXBIT/OPEN/
IMPRTF: PUSH P,A ;Save the A register.
PUSH P,X ;Save the index register.
MOVE X,[440400,,FIELD] ;Init a 4-bit byte pointer to FIELD.
.CALL [SETZ ? SIXBIT/OPEN/ ;Open a file descriptor.
[.UAI,,CHDSKI] ? [SIXBIT/DSK/] ;Mode, channel and device name
A ? B ((SETZ))]
.LOSE %LSFIL ;Handle errors after opening the file
.CALL [SETZ ? SIXBIT/SIOT/
[,,CHDSKI] ? [BPTR,,C] ? [,,33] ((SETZ))]
.LOSE %LSFIL
.CALL [SETZ ? SIXBIT/CLOSE/
IMPRD: .IOT CHDSKI,A ;Read an ascii char into A.
JUMPE A,IMPREX ;If there was nothing read, exit.
CAIGE A,060 ;Is A >= '0' then skip,
JUMPA IMPRD ;else read the next char.
CAILE A,071 ;If A <= '9', then skip.
JUMPA IMPRD ;else, read the next char.
SUBI A,060 ;Convert A from the num char into int.
IDPB A,X ;Store the byte and increment.
JUMPA IMPRD ;Jump back to read the next byte.
IMPREX: .CALL [SETZ ? SIXBIT/CLOSE/ ;Close the file, before returning.
[,,CHDSKI] ((SETZ))]
.LOSE %LSFIL
POP P,X ;Restore the X register.
POP P,A ;Restore the A register.
POPJ P ;Return from the input subroutine,
DONE: .LOGOUT 2, ;Exit point for the program.
WELCOME:ASCIZ /SUDOKU SOLVER v0.1/ ;Text of the welcome banner.