Work on the infrastructure for copying, and ignore leader when reading a tape and stop reading at trailer or empty reader
This commit is contained in:
parent
955992988c
commit
62329e91d1
139
gidubba.asm
139
gidubba.asm
|
@ -335,10 +335,123 @@ setmrk: load r0, target
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
;Copy to mark
|
;Copy to mark (under construction)
|
||||||
|
|
||||||
;Placeholder
|
;Find the argument line in the save and store its number
|
||||||
copy: breq r0, r0, cmdp
|
copy: cleq r0, r0, fend
|
||||||
|
|
||||||
|
;Get the save address of the line
|
||||||
|
;High byte
|
||||||
|
load r0, sublod + 1
|
||||||
|
store test1 + 1, r0
|
||||||
|
store testa + 1, r0
|
||||||
|
;Low byte
|
||||||
|
load r0, sublod + 2
|
||||||
|
store test1 + 2, r0
|
||||||
|
store testa + 2, r0
|
||||||
|
|
||||||
|
;Check for the save end
|
||||||
|
testa: load r0, 0
|
||||||
|
load r1, sub
|
||||||
|
breq r0, r1, cmdp
|
||||||
|
|
||||||
|
;Restore the buffer start address
|
||||||
|
;High byte
|
||||||
|
load r0, bfstrt
|
||||||
|
store test2 + 1, r0
|
||||||
|
;Low byte
|
||||||
|
load r0, bfstrt + 1
|
||||||
|
store test2 + 2, r0
|
||||||
|
|
||||||
|
;Initialise the character counter
|
||||||
|
xor r0, r0
|
||||||
|
|
||||||
|
;Read a character
|
||||||
|
test1: load r1, 0
|
||||||
|
|
||||||
|
;Check for save and buffer ends
|
||||||
|
;Save end
|
||||||
|
load r2, sub
|
||||||
|
breq r1, r2, test3
|
||||||
|
;Buffer end
|
||||||
|
load r2, bfsize
|
||||||
|
breq r0, r2, test3
|
||||||
|
|
||||||
|
;Store the character in the buffer
|
||||||
|
test2: store 0, r1
|
||||||
|
|
||||||
|
;Check for line and save ends
|
||||||
|
;Line end
|
||||||
|
load r2, lf
|
||||||
|
breq r1, r2, test4
|
||||||
|
|
||||||
|
;Increment the character counter and store it in r3
|
||||||
|
;Increment
|
||||||
|
load r2, const1
|
||||||
|
cleq r0, r0, sum
|
||||||
|
;Store
|
||||||
|
xor r3, r3
|
||||||
|
xor r3, r0
|
||||||
|
|
||||||
|
;Increment the save address
|
||||||
|
;Low byte
|
||||||
|
load r0, test1 + 2
|
||||||
|
load r2, const1
|
||||||
|
cleq r0, r0, sum
|
||||||
|
store test1 + 2, r0
|
||||||
|
;Add the overflow to the high byte
|
||||||
|
load r0, test1 + 1
|
||||||
|
xor r2, r2
|
||||||
|
xor r2, r1
|
||||||
|
cleq r0, r0, sum
|
||||||
|
store test1 + 1, r0
|
||||||
|
|
||||||
|
;Increment the buffer address
|
||||||
|
;Low byte
|
||||||
|
load r0, test2 + 2
|
||||||
|
load r2, const1
|
||||||
|
cleq r0, r0, sum
|
||||||
|
store test2 + 2, r0
|
||||||
|
;Add the overflow to the high byte
|
||||||
|
load r0, test2 + 1
|
||||||
|
xor r2, r2
|
||||||
|
xor r2, r1
|
||||||
|
cleq r0, r0, sum
|
||||||
|
store test2 + 1, r0
|
||||||
|
|
||||||
|
;Reload the character counter to r0
|
||||||
|
xor r0, r0
|
||||||
|
xor r0, r3
|
||||||
|
|
||||||
|
;Read the next character
|
||||||
|
breq r0, r0, test1
|
||||||
|
|
||||||
|
;Force line end
|
||||||
|
test3: load r1, test2 + 1
|
||||||
|
store test5 ,r1
|
||||||
|
load r1, test2 + 2
|
||||||
|
store test5 ,r1
|
||||||
|
|
||||||
|
;Store the CR of a newline in the buffer
|
||||||
|
load r0, cr
|
||||||
|
test5: store 0, r0
|
||||||
|
|
||||||
|
;Increment the buffer address
|
||||||
|
;Load the address
|
||||||
|
load r0, test2 + 1
|
||||||
|
load r1, test2 + 2
|
||||||
|
;Increment
|
||||||
|
cleq r0, r0, incdw
|
||||||
|
;Store the address
|
||||||
|
store test6 + 1, r0
|
||||||
|
store test6 + 2, r1
|
||||||
|
|
||||||
|
;Store the LF of a newline in the buffer
|
||||||
|
load r0, lf
|
||||||
|
test6: store 0, r0
|
||||||
|
|
||||||
|
;Return to the command prompt
|
||||||
|
test4: breq r0, r0, cmdp
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
|
@ -529,7 +642,7 @@ print: load r0, cstff
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
;Write the text to tape
|
;Write the text to the tape punch
|
||||||
|
|
||||||
;Get the tape punch address
|
;Get the tape punch address
|
||||||
;High byte
|
;High byte
|
||||||
|
@ -551,7 +664,7 @@ write: load r0, cstff
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
;Read the text from tape
|
;Read the text from the tape reader
|
||||||
|
|
||||||
;Get the save start address
|
;Get the save start address
|
||||||
;High byte
|
;High byte
|
||||||
|
@ -561,11 +674,23 @@ read: load r0, svstrt
|
||||||
load r0, svstrt + 1
|
load r0, svstrt + 1
|
||||||
store chrsto + 2, r0
|
store chrsto + 2, r0
|
||||||
|
|
||||||
|
;Ignore the leader
|
||||||
|
iglead: load r1, fffd
|
||||||
|
xor r2, r2
|
||||||
|
breq r1, r2, iglead
|
||||||
|
breq r0, r0, chkend
|
||||||
|
|
||||||
;Read a character
|
;Read a character
|
||||||
chread: load r1, fffd
|
chread: load r1, fffd
|
||||||
|
|
||||||
;Check for empty tape reader
|
;Check for trailer or empty tape reader
|
||||||
xor r2, r2
|
;Trailer
|
||||||
|
chkend: xor r2, r2
|
||||||
|
brneq r1, r2, chkntp
|
||||||
|
load r1, sub
|
||||||
|
breq r0, r0, chrsto
|
||||||
|
;Empty tape reader
|
||||||
|
chkntp: nand r2, r2
|
||||||
brneq r1, r2, chrsto
|
brneq r1, r2, chrsto
|
||||||
load r1, sub
|
load r1, sub
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue