Add the copy ability

This commit is contained in:
CrazyEttin 2022-08-23 18:31:36 +03:00
parent 807e67c800
commit b91f86f1b6
2 changed files with 153 additions and 44 deletions

View File

@ -250,9 +250,9 @@ onearg: load r1, uci
load r1, lci
breq r0, r1, insln
;Set a mark
load r1, ucs
load r1, ucm
breq r0, r1, setmrk
load r1, lcs
load r1, lcm
breq r0, r1, setmrk
;Branch to error
breq r0, r0, cmderr
@ -334,55 +334,60 @@ setmrk: load r0, target
;***
;Copy to mark (under construction)
;Copy to mark
;Check the counter
copy: xor r0, r0
load r1, count
breq r0, r1, cmdp
;Find the argument line in the save and store its number
copy: cleq r0, r0, fend
cleq r0, r0, fend
;Get the save address of the line
;High byte
load r0, eoflod + 1
store test1 + 1, r0
store testa + 1, r0
store readch + 1, r0
store chsend + 1, r0
;Low byte
load r0, eoflod + 2
store test1 + 2, r0
store testa + 2, r0
store readch + 2, r0
store chsend + 2, r0
;Check for the save end
testa: load r0, 0
chsend: load r0, 0
load r1, eof
breq r0, r1, cmdp
;Restore the buffer start address
;High byte
load r0, bfstrt
store test2 + 1, r0
store stoch + 1, r0
;Low byte
load r0, bfstrt + 1
store test2 + 2, r0
store stoch + 2, r0
;Initialise the character counter
xor r0, r0
;Read a character
test1: load r1, 0
readch: load r1, 0
;Check for save and buffer ends
;Save end
load r2, eof
breq r1, r2, test3
breq r1, r2, feol
;Buffer end
load r2, bfsize
breq r0, r2, test3
breq r0, r2, feol
;Store the character in the buffer
test2: store 0, r1
stoch: store 0, r1
;Check for line and save ends
;Line end
load r2, lf
breq r1, r2, test4
breq r1, r2, incsz
;Increment the character counter and store it in r3
;Increment
@ -394,63 +399,165 @@ test2: store 0, r1
;Increment the save address
;Low byte
load r0, test1 + 2
load r0, readch + 2
load r2, const1
cleq r0, r0, sum
store test1 + 2, r0
store readch + 2, r0
;Add the overflow to the high byte
load r0, test1 + 1
load r0, readch + 1
xor r2, r2
xor r2, r1
cleq r0, r0, sum
store test1 + 1, r0
store readch + 1, r0
;Increment the buffer address
;Low byte
load r0, test2 + 2
load r0, stoch + 2
load r2, const1
cleq r0, r0, sum
store test2 + 2, r0
store stoch + 2, r0
;Add the overflow to the high byte
load r0, test2 + 1
load r0, stoch + 1
xor r2, r2
xor r2, r1
cleq r0, r0, sum
store test2 + 1, r0
store stoch + 1, r0
;Reload the character counter to r0
xor r0, r0
xor r0, r3
;Read the next character
breq r0, r0, test1
breq r0, r0, readch
;Increment and store the string size
feol: load r2, const2
cleq r0, r0, sum
store strsz, r0
;Force line end
test3: load r1, test2 + 1
store test5 + 1 ,r1
load r1, test2 + 2
store test5 + 2 ,r1
load r1, stoch + 1
store stocr + 1 ,r1
load r1, stoch + 2
store stocr + 2 ,r1
;Store the CR of a newline in the buffer
load r0, cr
test5: store 0, r0
stocr: store 0, r0
;Increment the buffer address
;Load the address
load r0, test2 + 1
load r1, test2 + 2
load r0, stoch + 1
load r1, stoch + 2
;Increment
cleq r0, r0, incdw
;Store the address
store test6 + 1, r0
store test6 + 2, r1
store stolf + 1, r0
store stolf + 2, r1
;Store the LF of a newline in the buffer
load r0, lf
test6: store 0, r0
stolf: store 0, r0
;Return to the command prompt
test4: breq r0, r0, cmdp
;Jump to saving
breq r0, r0, svtarg
;Increment and store the string size
incsz: load r2, const1
cleq r0, r0, sum
store strsz, r0
;Save the target at tmp
svtarg: load r0, target
store tmp, r0
load r0, target + 1
store tmp + 1, r0
;Load the mark to target
load r0, mark
store target, r0
load r0, mark + 1
store target + 1, r0
;Find the marked line in the save and store its number
cleq r0, r0, fend
;Store the save address
;High byte
load r3, eoflod + 1
store eofchk + 1, r3
store cmpadr, r3
;Low byte
load r0, eoflod + 2
store eofchk + 2, r0
store cmpadr + 1, r0
;Save the marked line
cleq r0, r0, eofchk
;Loop
;Decrement the counter
load r0, count
load r2, cstff
cleq r0, r0, sum
store count, r0
;Check if the mark is a hash
load r2, cstff
load r0, target
brneq r0, r2, incmrk
load r1, target + 1
breq r1, r2, incln
;Increment the mark
incmrk: load r1, target + 1
cleq r0, r0, incdw
store mark, r0
store mark + 1, r1
;Increment the line number
incln: load r0, tmp
load r1, tmp + 1
cleq r0, r0, incdw
store target, r0
store target + 1, r1
;Check if the mark is less than the line number
;Negate the mark and store in tmp
load r0, mark
nand r0, r0
load r1, mark + 1
nand r1, r1
cleq r0, r0, incdw
store tmp, r0
store tmp + 1, r1
;Add the high bytes
load r0, target
load r2, tmp
cleq r0, r0, sum
store tmp, r0
;Store the overflow in r3
xor r3, r3
xor r3, r1
;Add the low bytes
load r0, target + 1
load r2, tmp + 1
cleq r0, r0, sum
;Add the overflow to the high byte
load r0, tmp
xor r2, r2
xor r2, r1
cleq r0, r0, sum
;Check
xor r1, r3
xor r3, r3
breq r1, r3, cpend
;Re-increment the mark
load r0, target
load r1, target + 1
cleq r0, r0, incdw
store target, r0
store target + 1, r1
;Loop
cpend: breq r0, r0, copy
;***
@ -1586,9 +1693,9 @@ ucf: data 46
uch: data 48
uci: data 49
ucl: data 4c
ucm: data 4d
ucp: data 50
ucr: data 52
ucs: data 53
ucw: data 57
bslash: data 5c
uscore: data 5f
@ -1601,9 +1708,9 @@ lcf: data 66
lch: data 68
lci: data 69
lcl: data 6c
lcm: data 6d
lcp: data 70
lcr: data 72
lcs: data 73
lcw: data 77
del: data 7f

View File

@ -20,20 +20,22 @@ Usage
The commands are individual letters that can be followed by one or two
arguments separated by a comma, all case-insensitive. The first argument
is a line number between 0 and FFFF and the second a range of lines
between 0 and FF. To append lines, insert them to any line number after
the text or to the shortcut hash (#); in other commands line numbers or
parts of a range after the text are ignored. Instead of a predetermined
range a prompt to insert the next line appears automatically after the
previous one has been committed.
between 0 and FF. To append lines, insert or copy them to any line
number after the text or to the shortcut hash (#); in other commands
line numbers or parts of a range after the text are ignored. Instead of
a predetermined range a prompt to insert the next line appears
automatically after the previous one has been committed.
Commands with a single argument:
* I: Insert lines
Commands with two arguments:
* C: Copy to the mark
* D: Delete lines
* L: List lines
Commands with no arguments:
* M: Set a mark
* P: Print
* R: Read from the tape reader or casette drive
* W: Write to the tape punch or casette drive