Implement infrastructure for copying and correct some terminology

This commit is contained in:
CrazyEttin 2022-08-15 12:29:38 +03:00
parent c6c1c5567f
commit ec3cf94c06
2 changed files with 197 additions and 154 deletions

View File

@ -147,8 +147,8 @@ hsharg: load r0, buffer + 2
;Save FFFF ;Save FFFF
xor r0, r0 xor r0, r0
nand r0, r0 nand r0, r0
store line, r0 store target, r0
store line + 1, r0 store target + 1, r0
breq r0, r0, chkcmd breq r0, r0, chkcmd
;Get the value of the first argument ;Get the value of the first argument
@ -170,7 +170,7 @@ getarg: load r0, arg1
breq r0, r1, cmderr breq r0, r1, cmderr
;Combine and store the first and second digits ;Combine and store the first and second digits
or r0, r2 or r0, r2
store line, r0 store target, r0
;Third digit ;Third digit
load r0, arg1 + 2 load r0, arg1 + 2
cleq r0, r0, hex2n cleq r0, r0, hex2n
@ -189,7 +189,7 @@ getarg: load r0, arg1
breq r0, r1, cmderr breq r0, r1, cmderr
;Combine and store the third and fourth digits ;Combine and store the third and fourth digits
or r0, r2 or r0, r2
store line + 1, r0 store target + 1, r0
;Get the value of the second argument ;Get the value of the second argument
;First digit ;First digit
@ -223,6 +223,11 @@ chkcmd: load r0, cmd
load r2, argf2 load r2, argf2
xor r3, r3 xor r3, r3
breq r2, r3, onearg breq r2, r3, onearg
;Copy to mark
load r1, ucc
breq r0, r1, copy
load r1, lcc
breq r0, r1, copy
;Delete ;Delete
load r1, ucd load r1, ucd
breq r0, r1, delete breq r0, r1, delete
@ -240,6 +245,11 @@ onearg: load r1, uci
breq r0, r1, insln breq r0, r1, insln
load r1, lci load r1, lci
breq r0, r1, insln breq r0, r1, insln
;Set a mark
load r1, ucs
breq r0, r1, setmrk
load r1, lcs
breq r0, r1, setmrk
;Branch to error ;Branch to error
breq r0, r0, cmderr breq r0, r0, cmderr
;Print ;Print
@ -295,12 +305,8 @@ instrt: cleq r0, r0, prnln
;Increment ;Increment
cleq r0, r0, incdw cleq r0, r0, incdw
;Store the number ;Store the number
store line, r0 store target, r0
store line + 1, r1 store target + 1, r1
;***
;Make room for the line
;Store the save address ;Store the save address
;High byte ;High byte
@ -312,139 +318,27 @@ instrt: cleq r0, r0, prnln
store subchk + 2, r0 store subchk + 2, r0
store cmpadr + 1, r0 store cmpadr + 1, r0
;Find the end of the save address ;Save the line
;Check for a substitute cleq r0, r0, subchk
subchk: load r0, 0
load r1, sub
breq r0, r1, endfnd
;Load the address
load r0, subchk + 1
load r1, subchk + 2
;Increment
cleq r0, r0, incdw
;Store the address
store subchk + 1, r0
store subchk + 2, r1
;Check the next character
breq r0, r0, subchk
;Store the end of the save address ;Insert the next line
;High byte breq r0, r0, insln
endfnd: load r3, subchk + 1
store movlod + 1, r3
;Low byte
load r0, subchk + 2
store movlod + 2, r0
;Calculate the new end of the save
;Increment the low byte
load r2, strsz
cleq r0, r0, sum
;Move the high byte to r2
xor r2, r2
xor r2, r3
;Store the low byte to r3
xor r3, r3
xor r3, r0
;Load the high byte to r0
xor r0, r0
xor r0, r2
;Add the overflow to the high byte
xor r2, r2
xor r2, r1
cleq r0, r0, sum
;Store the new end of the save
store movsto + 1, r0
store movsto + 2, r3
;Move the substitute
movlod: load r0, 0
movsto: store 0, r0
;Check for the address of the new line
load r0, cmpadr
load r1, movlod + 1
brneq r0, r1, decsav
load r0, cmpadr + 1
load r1, movlod + 2
brneq r0, r1, decsav
breq r0, r1, save
;Decrement the old save address
;load the address
decsav: load r0, movlod + 1
load r1, movlod + 2
;Decrement
cleq r0, r0, decdw
;Store the address
store movlod + 1, r0
store movlod + 2, r1
;Decrement the new save address
;load the address
load r0, movsto + 1
load r1, movsto + 2
;Decrement
cleq r0, r0, decdw
;Store the address
store movsto + 1, r0
store movsto + 2, r1
;Move the next character
breq r0, r0, movlod
;*** ;***
;Save the line ;Set a mark for copying
setmrk: load r0, target
store mark, r0
load r0, target + 1
store mark + 1, r0
breq r0, r0, cmdp
;Restore the buffer start address ;***
;High byte
save: load r0, bfstrt
store chload + 1, r0
;Low byte
load r0, bfstrt + 1
store chload + 2, r0
;Store the save address ;Copy to mark
;High byte
load r0, sublod + 1
store chsave + 1, r0
;Low byte
load r0, sublod + 2
store chsave + 2, r0
;Load and save a character from the buffer ;Placeholder
;Load copy: breq r0, r0, cmdp
chload: load r1, buffer
;Save
chsave: store buffer + 100, r1
;Check for line end
load r2, lf
breq r1, r2, insln
;Increment the buffer address
;Load the address
load r0, chload + 1
load r1, chload + 2
;Increment
cleq r0, r0, incdw
;Store the address
store chload + 1, r0
store chload + 2, r1
;Increment the save address
;Load the address
load r0, chsave + 1
load r1, chsave + 2
;Increment
cleq r0, r0, incdw
;Store the address
store chsave + 1, r0
store chsave + 2, r1
;Load and save the next character
breq r0, r0, chload
;*** ;***
@ -475,13 +369,13 @@ dchend: load r0, 0
;Increment the line number ;Increment the line number
;Load the number ;Load the number
load r0, line load r0, target
load r1, line + 1 load r1, target + 1
;Increment ;Increment
cleq r0, r0, incdw cleq r0, r0, incdw
;Store the number ;Store the number
store line, r0 store target, r0
store line + 1, r1 store target + 1, r1
;Find the next line in the save and store its number ;Find the next line in the save and store its number
cleq r0, r0, fend cleq r0, r0, fend
@ -532,11 +426,11 @@ delend: load r0, count
cleq r0, r0, sum cleq r0, r0, sum
store count, r0 store count, r0
;Decrement the line number ;Decrement the line number
load r0, line load r0, target
load r1, line + 1 load r1, target + 1
cleq r0, r0, decdw cleq r0, r0, decdw
store line, r0 store target, r0
store line + 1, r1 store target + 1, r1
;Loop ;Loop
breq r0, r0, delete breq r0, r0, delete
@ -607,11 +501,11 @@ lstend: load r0, count
cleq r0, r0, sum cleq r0, r0, sum
store count, r0 store count, r0
;Increment the line number ;Increment the line number
load r0, line load r0, target
load r1, line + 1 load r1, target + 1
cleq r0, r0, incdw cleq r0, r0, incdw
store line, r0 store target, r0
store line + 1, r1 store target + 1, r1
;Loop ;Loop
breq r0, r0, list breq r0, r0, list
@ -637,7 +531,7 @@ print: load r0, cstff
;Write the text to tape ;Write the text to tape
;Get the keypunch address ;Get the tape punch address
;High byte ;High byte
write: load r0, cstff write: load r0, cstff
store prwrch + 1, r0 store prwrch + 1, r0
@ -1176,6 +1070,147 @@ inend: ret
;*** ;***
;Make room for the line
;Find the end of the save address
;Check for a substitute
subchk: load r0, 0
load r1, sub
breq r0, r1, endfnd
;Load the address
load r0, subchk + 1
load r1, subchk + 2
;Increment
cleq r0, r0, incdw
;Store the address
store subchk + 1, r0
store subchk + 2, r1
;Check the next character
breq r0, r0, subchk
;Store the end of the save address
;High byte
endfnd: load r3, subchk + 1
store movlod + 1, r3
;Low byte
load r0, subchk + 2
store movlod + 2, r0
;Calculate the new end of the save
;Increment the low byte
load r2, strsz
cleq r0, r0, sum
;Move the high byte to r2
xor r2, r2
xor r2, r3
;Store the low byte to r3
xor r3, r3
xor r3, r0
;Load the high byte to r0
xor r0, r0
xor r0, r2
;Add the overflow to the high byte
xor r2, r2
xor r2, r1
cleq r0, r0, sum
;Store the new end of the save
store movsto + 1, r0
store movsto + 2, r3
;Move the substitute
movlod: load r0, 0
movsto: store 0, r0
;Check for the address of the new line
load r0, cmpadr
load r1, movlod + 1
brneq r0, r1, decsav
load r0, cmpadr + 1
load r1, movlod + 2
brneq r0, r1, decsav
breq r0, r1, save
;Decrement the old save address
;load the address
decsav: load r0, movlod + 1
load r1, movlod + 2
;Decrement
cleq r0, r0, decdw
;Store the address
store movlod + 1, r0
store movlod + 2, r1
;Decrement the new save address
;load the address
load r0, movsto + 1
load r1, movsto + 2
;Decrement
cleq r0, r0, decdw
;Store the address
store movsto + 1, r0
store movsto + 2, r1
;Move the next character
breq r0, r0, movlod
;***
;Save the line
;Restore the buffer start address
;High byte
save: load r0, bfstrt
store chload + 1, r0
;Low byte
load r0, bfstrt + 1
store chload + 2, r0
;Store the save address
;High byte
load r0, sublod + 1
store chsave + 1, r0
;Low byte
load r0, sublod + 2
store chsave + 2, r0
;Load and save a character from the buffer
;Load
chload: load r1, buffer
;Save
chsave: store buffer + 100, r1
;Check for line end
load r2, lf
breq r1, r2, savend
;Increment the buffer address
;Load the address
load r0, chload + 1
load r1, chload + 2
;Increment
cleq r0, r0, incdw
;Store the address
store chload + 1, r0
store chload + 2, r1
;Increment the save address
;Load the address
load r0, chsave + 1
load r1, chsave + 2
;Increment
cleq r0, r0, incdw
;Store the address
store chsave + 1, r0
store chsave + 2, r1
;Load and save the next character
breq r0, r0, chload
;Return
savend: ret
;***
;Find the argument line in the save and store its number ;Find the argument line in the save and store its number
;Reset the line number ;Reset the line number
@ -1192,10 +1227,10 @@ fend: xor r0, r0
store sublod + 2, r0 store sublod + 2, r0
;Check for the argument ;Check for the argument
charg: load r0, line charg: load r0, target
load r1, lnnum load r1, lnnum
brneq r0, r1, fsub brneq r0, r1, fsub
load r0, line + 1 load r0, target + 1
load r1, lnnum + 1 load r1, lnnum + 1
breq r0, r1, fendnd breq r0, r1, fendnd
@ -1381,6 +1416,7 @@ uci: data 49
ucl: data 4c ucl: data 4c
ucp: data 50 ucp: data 50
ucr: data 52 ucr: data 52
ucs: data 53
ucw: data 57 ucw: data 57
bslash: data 5c bslash: data 5c
lca: data 61 lca: data 61
@ -1394,6 +1430,7 @@ lci: data 69
lcl: data 6c lcl: data 6c
lcp: data 70 lcp: data 70
lcr: data 72 lcr: data 72
lcs: data 73
lcw: data 77 lcw: data 77
;Variables ;Variables
@ -1412,11 +1449,17 @@ argf1: data 0
arg2: data 30 arg2: data 30
data 30 data 30
argf2: data 0 argf2: data 0
line: data 0 target: data 0
data 0 data 0
count: data 0 count: data 0
mark: data 0
data 0
mrkadr: data 0
data 0
cmpadr: data 0 cmpadr: data 0
data 0 data 0
tmp: data 0
data 0
;Buffer and save ;Buffer and save
bfstrt: addr buffer bfstrt: addr buffer

View File

@ -11,7 +11,7 @@ System requirements
Gidubba requires a terminal with local echo at address FFFF and Gidubba requires a terminal with local echo at address FFFF and
optionally a line printer at address FFFE and a punched tape reader and optionally a line printer at address FFFE and a punched tape reader and
keypunch at FFFD. If your setup differs from this you may have to modify punch at FFFD. If your setup differs from this you may have to modify
the code yourself. the code yourself.
Usage Usage
@ -33,7 +33,7 @@ Commands with two arguments:
Commands with no argument: Commands with no argument:
* P: Print (requires a printer) * P: Print (requires a printer)
* W: Writes to tape (requires a keypunch) * W: Writes to tape (requires a tape punch)
* R: Reads from tape (requires a tape reader) * R: Reads from tape (requires a tape reader)
* H: Halt * H: Halt