Add bytewise loading of the file.
This commit is contained in:
21
src/sudoku.s
21
src/sudoku.s
@@ -101,16 +101,27 @@ PUTLN: PUSHJ P,OUTSTR ;Calls the OUTSTR subroutine
|
|||||||
POPJ P, ;before returning.
|
POPJ P, ;before returning.
|
||||||
|
|
||||||
;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: .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
|
[.UAI,,CHDSKI] ? [SIXBIT/DSK/] ;Mode, channel and device name
|
||||||
A ? B ((SETZ))]
|
A ? B ((SETZ))]
|
||||||
.LOSE %LSFIL ;Handle errors after opening the file
|
.LOSE %LSFIL ;Handle errors after opening the file
|
||||||
.CALL [SETZ ? SIXBIT/SIOT/
|
IMPRD: .IOT CHDSKI,A ;Read an ascii char into A.
|
||||||
[,,CHDSKI] ? [BPTR,,C] ? [,,33] ((SETZ))]
|
JUMPE A,IMPREX ;If there was nothing read, exit.
|
||||||
.LOSE %LSFIL
|
CAIGE A,060 ;Is A >= '0' then skip,
|
||||||
.CALL [SETZ ? SIXBIT/CLOSE/
|
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))]
|
[,,CHDSKI] ((SETZ))]
|
||||||
.LOSE %LSFIL
|
.LOSE %LSFIL
|
||||||
|
POP P,X ;Restore the X register.
|
||||||
|
POP P,A ;Restore the A register.
|
||||||
POPJ P ;Return from the input subroutine,
|
POPJ P ;Return from the input subroutine,
|
||||||
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user