Parse data

This commit is contained in:
2025-08-05 22:17:19 +02:00
parent 58b2147e44
commit 7eb8cbf0a8

View File

@@ -10,7 +10,7 @@ X=10 ;X and Y are used for indexing
Y=11 ;loops etc.
P=17 ;Define P as the stack pointer.
PDLLEN==20 ;Set the size of the stack to 20 words.
PDLLEN==30 ;Set the size of the stack to 30 words.
PDL: BLOCK PDLLEN ;Reserve the stack memory
BPTR==440700 ;Define a byte pointer.
@@ -21,34 +21,48 @@ FNAME1: BLOCK 15 ;The first part of the file name.
FNAME2: BLOCK 15 ;The second file name.
START: MOVE P,[-PDLLEN,,PDL-1] ;Initialize the stack.
SETZM JCL ;Zero out the JCL
MOVE A,[JCL,,JCL+30]
BLT A,JCL+30
.OPEN CHTTYO,[.UAO,,'TTY] ;Open an output channel on the TTY.
.LOSE %LSFIL ;Gobble up any errors.
PUSHJ P,GETJCL ;Read the command line.
MOVE A,[BPTR,,HELLO] ;Load A with a byte pointer to HELLO.
PUSHJ P,OUTSTR ;Print the out string.
MOVE A,[BPTR,,JCL] ;Read the parameter.
PUSHJ P,PUTLN ;Print the rest of the line.
MOVE A,[BPTR,,FNAME1] ;Read the parameter.
PUSHJ P,PUTLN ;Print the file name
MOVE A,[BPTR,,FNAME2] ;Print the second file name.
PUSHJ P,PUTLN
JRST DONE ;Jump to the end of the program.
;Subroutine to read the JCL from DDT and get the command line parameters.
;Clobbers B, C and D.
GETJCL: .BREAK 12,[..RJCL,,JCL] ;Get the JCL
MOVE B,[BPTR,,JCL] ;Load the command parameters.
MOVE C,[BPTR,,FNAME1] ;Set a pointer to store the first parameter.
JCLL1: ILDB D,B ;Load the next character.
JUMPE D,FN2 ;Exit the loop, if null.
CAIN D,30 ;Jump to next parameter word, if
CAIL D,140 ;Check, if the char is > 96.
SUBI D,40 ;Make sure that the code is always < 96
SUBI D,40 ;Convert the char to SIXBIT.
IDBP D,C ;Deposit the converter value in FNAME1.
JRST JCLL1 ;Loop back to read the next character.
FN2: MOVE C,[BPTR,,FNAME2] ;Load a pointer to FNAME2 into C.
GETJCL: PUSH P,A ;Save the register A.
PUSH P,B ;Save the register B.
SETZM JCL ;Zero out the JCL
MOVE A,[JCL,,JCL+30]
BLT A,JCL+30
.BREAK 12,[..RJCL,,JCL] ;Request the JCL.
MOVE A,[BPTR,,JCL] ;Load the command parameters into A.
MOVE B,[BPTR,,FNAME1] ;Pointer to the first file name.
PUSHJ TOSIXBIT ;Transfer the first word into FNAME1
MOVE B,[BPTR,,FNAME2] ;Pointer to the second file name.
PUSHJ TOSIXBIT ;Transfer the second word into FNAME2
POP P,B ;Restore the B register.
POP P,A ;Restore the A register.
POPJ P, ;Return from routine.
;Subroutine to convert an ASCII string into SIXBIT. Takes a byte
;pointer in A and B, where A is the source and B is the destination.
TOSIXBT:PUSH P,D ;Store the contents of register D.
TOSIXBL:ILDB D,A ;Load the next character from A.
JUMPE D,TOSIXEN ;Exit the loop, if charachter is null.
CAIN D,40 ;If the character is a whitespace,
JUMPA TOSIXEN ;exit the loop.
CAIL D,140 ;If the character is > 96,
SUBI D,40 ;then cut it down, so it's in range.
SUBI D,40 ;Convert 32..95 to 0..63
IDBP D,B ;Deposit the character in the destination.
JRST TOSIXBL ;Repeat with next character.
TOSIXEN:POP P,D ;Restore the D register.
POPJ P, ;Return from function.
;Subroutine to print a string of text on the output.
; Clobbers A and B.
OUTSTR: HRLI A,BPTR ;Ensure, A is a byte pointer.