Implement the infrastructure for multiple arguments and improve argument checking
This commit is contained in:
parent
e0c4c6bbcf
commit
d78deb4616
153
gidubba.asm
153
gidubba.asm
|
@ -24,14 +24,19 @@ cmdp: load r0, prompt
|
||||||
;Initialise the command and argument
|
;Initialise the command and argument
|
||||||
xor r0, r0
|
xor r0, r0
|
||||||
store cmd, r0
|
store cmd, r0
|
||||||
|
store argf1, r0
|
||||||
|
store argf2, r0
|
||||||
load r0, zero
|
load r0, zero
|
||||||
store arg, r0
|
store arg1, r0
|
||||||
store arg + 1, r0
|
store arg1 + 1, r0
|
||||||
store arg + 2, r0
|
store arg1 + 2, r0
|
||||||
store arg + 3, r0
|
store arg1 + 3, r0
|
||||||
load r0, qmark
|
store arg2, r0
|
||||||
store argval, r0
|
store arg2 + 1, r0
|
||||||
store argval + 1, r0
|
|
||||||
|
;Temporary
|
||||||
|
load r0, const1
|
||||||
|
store count, r0
|
||||||
|
|
||||||
;Parse the command and its argument if any
|
;Parse the command and its argument if any
|
||||||
;Command
|
;Command
|
||||||
|
@ -45,32 +50,34 @@ cmdp: load r0, prompt
|
||||||
;First digit
|
;First digit
|
||||||
load r0, buffer + 1
|
load r0, buffer + 1
|
||||||
breq r0, r1, chkcmd
|
breq r0, r1, chkcmd
|
||||||
|
load r3, const1
|
||||||
|
store argf1, r3
|
||||||
breq r0, r2, hsharg
|
breq r0, r2, hsharg
|
||||||
store arg + 3, r0
|
store arg1 + 3, r0
|
||||||
;Second digit
|
;Second digit
|
||||||
load r0, buffer + 2
|
load r0, buffer + 2
|
||||||
breq r0, r1, getarg
|
breq r0, r1, getarg
|
||||||
load r2, arg + 3
|
load r2, arg1 + 3
|
||||||
store arg + 2, r2
|
store arg1 + 2, r2
|
||||||
store arg + 3, r0
|
store arg1 + 3, r0
|
||||||
;Third digit
|
;Third digit
|
||||||
load r0, buffer + 3
|
load r0, buffer + 3
|
||||||
breq r0, r1, getarg
|
breq r0, r1, getarg
|
||||||
load r2, arg + 2
|
load r2, arg1 + 2
|
||||||
store arg + 1, r2
|
store arg1 + 1, r2
|
||||||
load r2, arg + 3
|
load r2, arg1 + 3
|
||||||
store arg + 2, r2
|
store arg1 + 2, r2
|
||||||
store arg + 3, r0
|
store arg1 + 3, r0
|
||||||
;Fourth digit
|
;Fourth digit
|
||||||
load r0, buffer + 4
|
load r0, buffer + 4
|
||||||
breq r0, r1, getarg
|
breq r0, r1, getarg
|
||||||
load r2, arg + 1
|
load r2, arg1 + 1
|
||||||
store arg, r2
|
store arg1, r2
|
||||||
load r2, arg + 2
|
load r2, arg1 + 2
|
||||||
store arg + 1, r2
|
store arg1 + 1, r2
|
||||||
load r2, arg + 3
|
load r2, arg1 + 3
|
||||||
store arg + 2, r2
|
store arg1 + 2, r2
|
||||||
store arg + 3, r0
|
store arg1 + 3, r0
|
||||||
;Check for command end
|
;Check for command end
|
||||||
load r0, buffer + 5
|
load r0, buffer + 5
|
||||||
breq r0, r1, getarg
|
breq r0, r1, getarg
|
||||||
|
@ -83,13 +90,13 @@ hsharg: load r0, buffer + 2
|
||||||
;Save FFFF
|
;Save FFFF
|
||||||
xor r0, r0
|
xor r0, r0
|
||||||
nand r0, r0
|
nand r0, r0
|
||||||
store argval, r0
|
store line, r0
|
||||||
store argval + 1, r0
|
store line + 1, r0
|
||||||
breq r0, r0, chkcmd
|
breq r0, r0, chkcmd
|
||||||
|
|
||||||
;Get the value of the argument
|
;Get the value of the first argument
|
||||||
;First digit
|
;First digit
|
||||||
getarg: load r0, arg
|
getarg: load r0, arg1
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
load r1, qmark
|
load r1, qmark
|
||||||
breq r0, r1, cmderr
|
breq r0, r1, cmderr
|
||||||
|
@ -100,15 +107,15 @@ getarg: load r0, arg
|
||||||
shl r2
|
shl r2
|
||||||
shl r2
|
shl r2
|
||||||
;Second digit
|
;Second digit
|
||||||
load r0, arg + 1
|
load r0, arg1 + 1
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
load r1, qmark
|
load r1, qmark
|
||||||
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 argval, r0
|
store line, r0
|
||||||
;Third digit
|
;Third digit
|
||||||
load r0, arg + 2
|
load r0, arg1 + 2
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
load r1, qmark
|
load r1, qmark
|
||||||
breq r0, r1, cmderr
|
breq r0, r1, cmderr
|
||||||
|
@ -119,20 +126,20 @@ getarg: load r0, arg
|
||||||
shl r2
|
shl r2
|
||||||
shl r2
|
shl r2
|
||||||
;Fourth digit
|
;Fourth digit
|
||||||
load r0, arg + 3
|
load r0, arg1 + 3
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
load r1, qmark
|
load r1, qmark
|
||||||
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 argval + 1, r0
|
store line + 1, r0
|
||||||
|
|
||||||
;Check for commands
|
;Check for commands
|
||||||
;Load the command
|
;Load the command
|
||||||
chkcmd: load r0, cmd
|
chkcmd: load r0, cmd
|
||||||
;Check for no argument
|
;Check for no argument
|
||||||
load r2, argval
|
load r2, argf1
|
||||||
load r3, qmark
|
xor r3, r3
|
||||||
breq r2, r3, cnarg
|
breq r2, r3, cnarg
|
||||||
;Insert
|
;Insert
|
||||||
load r1, uci
|
load r1, uci
|
||||||
|
@ -194,8 +201,8 @@ instrt: cleq r0, r0, prnln
|
||||||
;Increment
|
;Increment
|
||||||
cleq r0, r0, incdw
|
cleq r0, r0, incdw
|
||||||
;Store the number
|
;Store the number
|
||||||
store argval, r0
|
store line, r0
|
||||||
store argval + 1, r1
|
store line + 1, r1
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
|
@ -349,8 +356,13 @@ chsave: store buffer + 100, r1
|
||||||
|
|
||||||
;Delete a line
|
;Delete a line
|
||||||
|
|
||||||
|
;Check the counter
|
||||||
|
delete: xor r0, r0
|
||||||
|
load r1, count
|
||||||
|
breq r0, r1, cmdp
|
||||||
|
|
||||||
;Find the argument line in the save and store its number
|
;Find the argument line in the save and store its number
|
||||||
delete: cleq r0, r0, fend
|
cleq r0, r0, fend
|
||||||
|
|
||||||
;Get the save address of the line
|
;Get the save address of the line
|
||||||
;High byte
|
;High byte
|
||||||
|
@ -369,13 +381,13 @@ chsend: load r0, 0
|
||||||
|
|
||||||
;Increment the line number
|
;Increment the line number
|
||||||
;Load the number
|
;Load the number
|
||||||
load r0, argval
|
load r0, line
|
||||||
load r1, argval + 1
|
load r1, line + 1
|
||||||
;Increment
|
;Increment
|
||||||
cleq r0, r0, incdw
|
cleq r0, r0, incdw
|
||||||
;Store the number
|
;Store the number
|
||||||
store argval, r0
|
store line, r0
|
||||||
store argval + 1, r1
|
store line + 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
|
||||||
|
@ -419,15 +431,32 @@ stomov: store 0, r0
|
||||||
;Move the next character
|
;Move the next character
|
||||||
breq r0, r0, lodmov
|
breq r0, r0, lodmov
|
||||||
|
|
||||||
;Return to the command prompt
|
;Loop
|
||||||
delend: breq r0, r0, cmdp
|
;Decrement the counter
|
||||||
|
delend: load r0, count
|
||||||
|
load r2, cstff
|
||||||
|
cleq r0, r0, sum
|
||||||
|
store count, r0
|
||||||
|
;Decrement the line number
|
||||||
|
load r0, line
|
||||||
|
load r1, line + 1
|
||||||
|
cleq r0, r0, decdw
|
||||||
|
store line, r0
|
||||||
|
store line + 1, r1
|
||||||
|
;Loop
|
||||||
|
breq r0, r0, delete
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
;List a line
|
;List a line
|
||||||
|
|
||||||
|
;Check the counter
|
||||||
|
list: xor r0, r0
|
||||||
|
load r1, count
|
||||||
|
breq r0, r1, cmdp
|
||||||
|
|
||||||
;Find the argument line in the save and store its number
|
;Find the argument line in the save and store its number
|
||||||
list: cleq r0, r0, fend
|
cleq r0, r0, fend
|
||||||
|
|
||||||
;Print a line number prompt
|
;Print a line number prompt
|
||||||
cleq r0, r0, prnln
|
cleq r0, r0, prnln
|
||||||
|
@ -470,8 +499,20 @@ chlist: load r1, 0
|
||||||
;Print a newline
|
;Print a newline
|
||||||
prnwln: cleq r0, r0, newln
|
prnwln: cleq r0, r0, newln
|
||||||
|
|
||||||
;Return to the command prompt
|
;Loop
|
||||||
lstend: breq r0, r0, cmdp
|
;Decrement the counter
|
||||||
|
lstend: load r0, count
|
||||||
|
load r2, cstff
|
||||||
|
cleq r0, r0, sum
|
||||||
|
store count, r0
|
||||||
|
;Increment the line number
|
||||||
|
load r0, line
|
||||||
|
load r1, line + 1
|
||||||
|
cleq r0, r0, incdw
|
||||||
|
store line, r0
|
||||||
|
store line + 1, r1
|
||||||
|
;Loop
|
||||||
|
breq r0, r0, list
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
|
@ -1012,10 +1053,10 @@ fend: xor r0, r0
|
||||||
store sublod + 2, r0
|
store sublod + 2, r0
|
||||||
|
|
||||||
;Check for the argument
|
;Check for the argument
|
||||||
charg: load r0, argval
|
charg: load r0, line
|
||||||
load r1, lnnum
|
load r1, lnnum
|
||||||
brneq r0, r1, fsub
|
brneq r0, r1, fsub
|
||||||
load r0, argval + 1
|
load r0, line + 1
|
||||||
load r1, lnnum + 1
|
load r1, lnnum + 1
|
||||||
breq r0, r1, fendnd
|
breq r0, r1, fendnd
|
||||||
|
|
||||||
|
@ -1136,6 +1177,7 @@ sub: data 1a
|
||||||
esc: data 1b
|
esc: data 1b
|
||||||
space: data 20
|
space: data 20
|
||||||
hash: data 23
|
hash: data 23
|
||||||
|
comma: data 2c
|
||||||
zero: data 30
|
zero: data 30
|
||||||
one: data 31
|
one: data 31
|
||||||
two: data 32
|
two: data 32
|
||||||
|
@ -1176,16 +1218,27 @@ ovrflw: data 0
|
||||||
lnnum: data 0
|
lnnum: data 0
|
||||||
data 0
|
data 0
|
||||||
strsz: data 0
|
strsz: data 0
|
||||||
|
dgtcnt: data 0
|
||||||
|
dgtadr: addr buffer + 2
|
||||||
cmd: data 0
|
cmd: data 0
|
||||||
arg: data 30
|
arg1: data 30
|
||||||
data 30
|
data 30
|
||||||
data 30
|
data 30
|
||||||
data 30
|
data 30
|
||||||
argval: data 0
|
argf1: data 0
|
||||||
|
arg2: data 30
|
||||||
|
data 30
|
||||||
|
argf2: data 0
|
||||||
|
line: data 0
|
||||||
data 0
|
data 0
|
||||||
|
count: data 0
|
||||||
cmpadr: data 0
|
cmpadr: data 0
|
||||||
data 0
|
data 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;Buffer and save
|
;Buffer and save
|
||||||
bfstrt: addr buffer
|
bfstrt: addr buffer
|
||||||
bfsize: data fe
|
bfsize: data fe
|
||||||
|
|
Loading…
Reference in New Issue