Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
CrazyEttin | e734757ee4 | |
CrazyEttin | 79fc294506 | |
CrazyEttin | 5da4ffa1b1 | |
CrazyEttin | d5af5d98b8 | |
CrazyEttin | 8485fa75cb | |
CrazyEttin | 8c37a1a871 | |
CrazyEttin | e6c0ca0937 | |
CrazyEttin | b388acc7b4 | |
CrazyEttin | 92b1c81162 |
281
gidubba.asm
281
gidubba.asm
|
@ -189,10 +189,7 @@ getarg: load r0, arg1
|
||||||
breq r0, r1, cmderr
|
breq r0, r1, cmderr
|
||||||
xor r2, r2
|
xor r2, r2
|
||||||
xor r2, r0
|
xor r2, r0
|
||||||
shl r2
|
shl r2, 4
|
||||||
shl r2
|
|
||||||
shl r2
|
|
||||||
shl r2
|
|
||||||
;Second digit
|
;Second digit
|
||||||
load r0, arg1 + 1
|
load r0, arg1 + 1
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
|
@ -208,10 +205,7 @@ getarg: load r0, arg1
|
||||||
breq r0, r1, cmderr
|
breq r0, r1, cmderr
|
||||||
xor r2, r2
|
xor r2, r2
|
||||||
xor r2, r0
|
xor r2, r0
|
||||||
shl r2
|
shl r2, 4
|
||||||
shl r2
|
|
||||||
shl r2
|
|
||||||
shl r2
|
|
||||||
;Fourth digit
|
;Fourth digit
|
||||||
load r0, arg1 + 3
|
load r0, arg1 + 3
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
|
@ -229,10 +223,7 @@ getarg: load r0, arg1
|
||||||
breq r0, r1, cmderr
|
breq r0, r1, cmderr
|
||||||
xor r2, r2
|
xor r2, r2
|
||||||
xor r2, r0
|
xor r2, r0
|
||||||
shl r2
|
shl r2, 4
|
||||||
shl r2
|
|
||||||
shl r2
|
|
||||||
shl r2
|
|
||||||
;Second digit
|
;Second digit
|
||||||
load r0, arg2 + 1
|
load r0, arg2 + 1
|
||||||
cleq r0, r0, hex2n
|
cleq r0, r0, hex2n
|
||||||
|
@ -368,11 +359,54 @@ inline: cleq r0, r0, input
|
||||||
xor r0, r0
|
xor r0, r0
|
||||||
brneq r0, r1, cmdp
|
brneq r0, r1, cmdp
|
||||||
|
|
||||||
;Save the line
|
;Restore the buffer start address
|
||||||
cleq r0, r0, save
|
;High byte
|
||||||
|
load r0, bfstrt
|
||||||
|
store chload + 1, r0
|
||||||
|
;Low byte
|
||||||
|
load r0, bfstrt + 1
|
||||||
|
store chload + 2, r0
|
||||||
|
|
||||||
;Insert the next line
|
;Store the save address
|
||||||
breq r0, r0, nextln
|
;High byte
|
||||||
|
load r0, eoflod + 1
|
||||||
|
store chsave + 1, r0
|
||||||
|
;Low byte
|
||||||
|
load r0, eoflod + 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, #a
|
||||||
|
breq r1, r2, nextln
|
||||||
|
|
||||||
|
;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
|
||||||
|
|
||||||
inesc: load r0, #20
|
inesc: load r0, #20
|
||||||
store ffff, r0
|
store ffff, r0
|
||||||
|
@ -870,10 +904,6 @@ write: load r0, #ff
|
||||||
;Write
|
;Write
|
||||||
cleq r0, r0, prwr
|
cleq r0, r0, prwr
|
||||||
|
|
||||||
;Write an end-of-file
|
|
||||||
load r0, #1a
|
|
||||||
store fffd, r0
|
|
||||||
|
|
||||||
;Return to the command prompt
|
;Return to the command prompt
|
||||||
breq r0, r0, cmdp
|
breq r0, r0, cmdp
|
||||||
|
|
||||||
|
@ -898,20 +928,9 @@ iglead: load r1, fffd
|
||||||
;Check for the RAM limit
|
;Check for the RAM limit
|
||||||
load r0, chrsto + 1
|
load r0, chrsto + 1
|
||||||
load r1, chrsto + 2
|
load r1, chrsto + 2
|
||||||
chkram: load r2, limit
|
chkram: cleq r0, r0, ramchk
|
||||||
load r3, limit + 1
|
xor r2, r2
|
||||||
brneq r0, r2, chread
|
brneq r1, r2, cmdp
|
||||||
brneq r1, r3, chread
|
|
||||||
|
|
||||||
;Save an end-of-file at the start address
|
|
||||||
load r0, #1a
|
|
||||||
store buffer + 100, r0
|
|
||||||
|
|
||||||
;Print an error and return to the command prompt
|
|
||||||
load r0, #21
|
|
||||||
store ffff, r0
|
|
||||||
cleq r0, r0, newln
|
|
||||||
breq r0, r0, cmdp
|
|
||||||
|
|
||||||
;Read a character
|
;Read a character
|
||||||
chread: load r1, fffd
|
chread: load r1, fffd
|
||||||
|
@ -924,12 +943,28 @@ chkend: xor r2, r2
|
||||||
breq r0, r0, chrsto
|
breq r0, r0, chrsto
|
||||||
;Empty tape reader
|
;Empty tape reader
|
||||||
chkntp: nand r2, r2
|
chkntp: nand r2, r2
|
||||||
brneq r1, r2, chrsto
|
brneq r1, r2, chklf
|
||||||
load r1, #1a
|
load r1, #1a
|
||||||
|
breq r0, r0, chrsto
|
||||||
|
|
||||||
|
;Check for a line feed
|
||||||
|
chklf: load r2, #a
|
||||||
|
load r3, #0
|
||||||
|
brneq r1, r2, chrsto
|
||||||
|
load r1, #d
|
||||||
|
load r3, #a
|
||||||
|
|
||||||
;Store a character
|
;Store a character
|
||||||
chrsto: store buffer + 100, r1
|
chrsto: store buffer + 100, r1
|
||||||
|
|
||||||
|
;Check for a newline
|
||||||
|
;Line feed
|
||||||
|
load r2, #a
|
||||||
|
breq r2, r3, readlf
|
||||||
|
;Carriage return
|
||||||
|
load r2, #d
|
||||||
|
breq r1, r2, readcr
|
||||||
|
|
||||||
;Check for the save end
|
;Check for the save end
|
||||||
load r2, #1a
|
load r2, #1a
|
||||||
breq r1, r2, redend
|
breq r1, r2, redend
|
||||||
|
@ -947,6 +982,22 @@ chrsto: store buffer + 100, r1
|
||||||
;Read the next character
|
;Read the next character
|
||||||
breq r0, r0, chkram
|
breq r0, r0, chkram
|
||||||
|
|
||||||
|
;Read a newline beginning with a carriage return
|
||||||
|
readcr: cleq r0, r0, readnl
|
||||||
|
|
||||||
|
;Check for a line feed
|
||||||
|
load r2, #a
|
||||||
|
breq r1, r2, chread
|
||||||
|
breq r0, r0, chkend
|
||||||
|
|
||||||
|
;Read a newline beginning with a line feed
|
||||||
|
readlf: cleq r0, r0, readnl
|
||||||
|
|
||||||
|
;Check for a carriage return
|
||||||
|
load r2, #d
|
||||||
|
breq r1, r2, chread
|
||||||
|
breq r0, r0, chkend
|
||||||
|
|
||||||
;Return to the command prompt
|
;Return to the command prompt
|
||||||
redend: breq r0, r0, cmdp
|
redend: breq r0, r0, cmdp
|
||||||
|
|
||||||
|
@ -985,11 +1036,11 @@ sumlop: xor r1, r1
|
||||||
xor r1, r1
|
xor r1, r1
|
||||||
xor r1, r2
|
xor r1, r2
|
||||||
;Shift the carry
|
;Shift the carry
|
||||||
shl r2
|
shl r2, 1
|
||||||
|
|
||||||
;Check for and store overflow if any
|
;Check for and store overflow if any
|
||||||
;Check
|
;Check
|
||||||
rol r1
|
rol r1, 1
|
||||||
breq r1, r2, nvrflw
|
breq r1, r2, nvrflw
|
||||||
;Store
|
;Store
|
||||||
load r1, #1
|
load r1, #1
|
||||||
|
@ -1291,10 +1342,7 @@ bt2hex: xor r2, r2
|
||||||
xor r2, r1
|
xor r2, r1
|
||||||
|
|
||||||
;Convert the high nibble to a digit
|
;Convert the high nibble to a digit
|
||||||
ror r0
|
ror r0, 4
|
||||||
ror r0
|
|
||||||
ror r0
|
|
||||||
ror r0
|
|
||||||
cleq r0, r0, n2hex
|
cleq r0, r0, n2hex
|
||||||
|
|
||||||
;Load the digit of the low nibble to r1
|
;Load the digit of the low nibble to r1
|
||||||
|
@ -1323,6 +1371,12 @@ input: load r0, bfstrt
|
||||||
inloop: load r1, ffff
|
inloop: load r1, ffff
|
||||||
|
|
||||||
;Check for control characters and the buffer end
|
;Check for control characters and the buffer end
|
||||||
|
;Null
|
||||||
|
load r2, #0
|
||||||
|
breq r1, r2, inloop
|
||||||
|
;FF
|
||||||
|
load r2, #ff
|
||||||
|
breq r1, r2, inloop
|
||||||
;Delete
|
;Delete
|
||||||
load r2, #7f
|
load r2, #7f
|
||||||
breq r1, r2, delbr
|
breq r1, r2, delbr
|
||||||
|
@ -1342,8 +1396,8 @@ inloop: load r1, ffff
|
||||||
load r2, bfsize
|
load r2, bfsize
|
||||||
brneq r0, r2, chstor
|
brneq r0, r2, chstor
|
||||||
|
|
||||||
;Backtrack if at the buffer end
|
;Ignore the input and print an underscore if at the buffer end
|
||||||
load r2, #8
|
load r2, #5f
|
||||||
store ffff, r2
|
store ffff, r2
|
||||||
breq r0, r0, inloop
|
breq r0, r0, inloop
|
||||||
|
|
||||||
|
@ -1429,13 +1483,13 @@ escbr: load r0, #20
|
||||||
cleq r0, r0, newln
|
cleq r0, r0, newln
|
||||||
|
|
||||||
;Return with escape in r2
|
;Return with escape in r2
|
||||||
breq r0, r0, inend
|
ret
|
||||||
|
|
||||||
;Print a newline
|
;Print a newline
|
||||||
eofbr: cleq r0, r0, newln
|
eofbr: cleq r0, r0, newln
|
||||||
|
|
||||||
;Return with End-of-file at r2
|
;Return with End-of-file at r2
|
||||||
breq r0, r0, inend
|
ret
|
||||||
|
|
||||||
;Print a line feed
|
;Print a line feed
|
||||||
crbr: load r1, #a
|
crbr: load r1, #a
|
||||||
|
@ -1480,7 +1534,7 @@ endcr: store 0, r0
|
||||||
endlf: store 0, r0
|
endlf: store 0, r0
|
||||||
|
|
||||||
;Return
|
;Return
|
||||||
inend: ret
|
ret
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
|
@ -1625,62 +1679,6 @@ lmterr: load r0, #21
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
;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, eoflod + 1
|
|
||||||
store chsave + 1, r0
|
|
||||||
;Low byte
|
|
||||||
load r0, eoflod + 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, #a
|
|
||||||
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
|
||||||
|
|
||||||
;Check for the argument
|
;Check for the argument
|
||||||
|
@ -1791,13 +1789,13 @@ prwr: load r0, svstrt
|
||||||
;Load a character from the save
|
;Load a character from the save
|
||||||
chprwr: load r1, buffer + 100
|
chprwr: load r1, buffer + 100
|
||||||
|
|
||||||
|
;Print the character
|
||||||
|
prwrch: store fffe, r1
|
||||||
|
|
||||||
;Check for the save end
|
;Check for the save end
|
||||||
load r2, #1a
|
load r2, #1a
|
||||||
breq r1, r2, pwend
|
breq r1, r2, pwend
|
||||||
|
|
||||||
;Print the character
|
|
||||||
prwrch: store fffe, r1
|
|
||||||
|
|
||||||
;Increment the save address
|
;Increment the save address
|
||||||
;Load the address
|
;Load the address
|
||||||
load r0, chprwr + 1
|
load r0, chprwr + 1
|
||||||
|
@ -1816,6 +1814,79 @@ pwend: ret
|
||||||
|
|
||||||
;***
|
;***
|
||||||
|
|
||||||
|
;Check for the RAM limit
|
||||||
|
|
||||||
|
;Check
|
||||||
|
ramchk: load r2, limit
|
||||||
|
load r3, limit + 1
|
||||||
|
brneq r0, r2, ramend
|
||||||
|
brneq r1, r3, ramend
|
||||||
|
|
||||||
|
;Save an end-of-file at the start address
|
||||||
|
load r0, #1a
|
||||||
|
store buffer + 100, r0
|
||||||
|
|
||||||
|
;Print an error
|
||||||
|
load r0, #21
|
||||||
|
store ffff, r0
|
||||||
|
cleq r0, r0, newln
|
||||||
|
|
||||||
|
;Return with an exclamation mark at r1
|
||||||
|
load r1, #21
|
||||||
|
ret
|
||||||
|
|
||||||
|
;Return with a null at r1
|
||||||
|
ramend: load r1, #0
|
||||||
|
ret
|
||||||
|
|
||||||
|
;***
|
||||||
|
|
||||||
|
;Read a newline
|
||||||
|
|
||||||
|
;Increment the save address
|
||||||
|
;Load the address
|
||||||
|
readnl: load r0, chrsto + 1
|
||||||
|
load r1, chrsto + 2
|
||||||
|
;Increment
|
||||||
|
cleq r0, r0, incdw
|
||||||
|
;Store the address
|
||||||
|
store chrsto + 1, r0
|
||||||
|
store lfstor + 1, r0
|
||||||
|
store chrsto + 2, r1
|
||||||
|
store lfstor + 2, r1
|
||||||
|
|
||||||
|
;Check for the RAM limit
|
||||||
|
cleq r0, r0, ramchk
|
||||||
|
xor r2, r2
|
||||||
|
brneq r1, r2, cmdp
|
||||||
|
|
||||||
|
;Store a line feed
|
||||||
|
load r1, #a
|
||||||
|
lfstor: store 0, r1
|
||||||
|
|
||||||
|
;Increment the save address
|
||||||
|
;Load the address
|
||||||
|
load r0, chrsto + 1
|
||||||
|
load r1, chrsto + 2
|
||||||
|
;Increment
|
||||||
|
cleq r0, r0, incdw
|
||||||
|
;Store the address
|
||||||
|
store chrsto + 1, r0
|
||||||
|
store chrsto + 2, r1
|
||||||
|
|
||||||
|
;Check for the RAM limit
|
||||||
|
cleq r0, r0, ramchk
|
||||||
|
xor r2, r2
|
||||||
|
brneq r1, r2, cmdp
|
||||||
|
|
||||||
|
;Read a character
|
||||||
|
load r1, fffd
|
||||||
|
|
||||||
|
;Return
|
||||||
|
ret
|
||||||
|
|
||||||
|
;***
|
||||||
|
|
||||||
;Data
|
;Data
|
||||||
|
|
||||||
;Variables
|
;Variables
|
||||||
|
|
49
readme.md
49
readme.md
|
@ -1,27 +1,31 @@
|
||||||
Gidubba v1.0
|
Gidubba v1.1
|
||||||
============
|
============
|
||||||
|
|
||||||
Gidubba (Sumerian for 'stylus') is a simple line editor for the
|
Gidubba (Sumerian for 'stylus') v1.1 is a simple line editor for the
|
||||||
Thingamajig computer architecture. Its git repository can be found at
|
Thingamajig v2.x computer architecture. Its git repository can be found
|
||||||
https://ahti.space/git/crazyettin/Gidubba and that of Thingamajig at
|
at https://ahti.space/git/crazyettin/Gidubba and that of Thingamajig at
|
||||||
https://ahti.space/git/crazyettin/Thingamajig.
|
https://ahti.space/git/crazyettin/Thingamajig.
|
||||||
|
|
||||||
System requirements
|
System Requirements
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Gidubba requires at least 4 KiB of RAM. It uses a terminal with local
|
Gidubba requires at least 4 KiB of RAM. It uses an ASCII-compatible
|
||||||
echo at address FFFF, and optionally a character printer at address FFFE
|
terminal with local echo at address FFFF, and optionally a character
|
||||||
and a punched tape reader and punch or a casette drive at FFFD. Do not
|
printer at address FFFE and a paper tape reader and punch or a cassette
|
||||||
be afraid to modify the code yourself if your setup requires it! (And if
|
deck at FFFD. Do not be afraid to modify the code yourself if your setup
|
||||||
you do, apologies for the spaghetti.)
|
requires it! (And if you do, apologies for the spaghetti.)
|
||||||
|
|
||||||
Format
|
Format
|
||||||
------
|
------
|
||||||
|
|
||||||
Texts are terminated by an end-of-file (^Z) and lines within them by a
|
Texts are terminated by an end-of-file (^Z) and lines within them by a
|
||||||
newline of a carriage return (^M) followed by a line feed (^J). Note
|
newline of a carriage return (^M) followed by a line feed (^J) (CRLF).
|
||||||
that the input buffer can store at most 256 characters, including the
|
Gidubba is able to read texts without an end-of-file or with different
|
||||||
newline.
|
newline formatting (CR, LF, or LFCR) and convert them to its native
|
||||||
|
format. The characters null (^@) and FF are reserved for indicating tape
|
||||||
|
leaders and trailers and an empty tape reader respectively and cannot
|
||||||
|
occur within a text. Note that the input buffer can store at most 256
|
||||||
|
characters, including the newline.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
@ -47,8 +51,8 @@ Commands with two arguments:
|
||||||
|
|
||||||
Commands with no arguments:
|
Commands with no arguments:
|
||||||
* P: Print
|
* P: Print
|
||||||
* R: Read from the tape reader or casette drive
|
* R: Read from the tape reader or cassette deck
|
||||||
* W: Write to the tape punch or casette drive
|
* W: Write to the tape punch or cassette deck
|
||||||
|
|
||||||
A delete (^?) discards the preceding character and outputs an underscore
|
A delete (^?) discards the preceding character and outputs an underscore
|
||||||
to the terminal. An escape (^[) discards the contents of the current
|
to the terminal. An escape (^[) discards the contents of the current
|
||||||
|
@ -56,8 +60,21 @@ command or line and outputs a backslash and a newline to the terminal. A
|
||||||
carriage return (^M) or a line feed (^J) inputs a newline and commits
|
carriage return (^M) or a line feed (^J) inputs a newline and commits
|
||||||
the current command or line. An end-of-file (^Z) discards the current
|
the current command or line. An end-of-file (^Z) discards the current
|
||||||
command and halts the computer or discards the current line and returns
|
command and halts the computer or discards the current line and returns
|
||||||
to the command prompt.
|
to the command prompt. At the end of the input buffer any input other
|
||||||
|
than those described in this paragraph is ignored and an underscore is
|
||||||
|
output to the terminal.
|
||||||
|
|
||||||
There are two kinds of error messages: a question mark (?) for an
|
There are two kinds of error messages: a question mark (?) for an
|
||||||
erroneous command and an exclamation mark (!) for lack of RAM.
|
erroneous command and an exclamation mark (!) for lack of RAM.
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
---------
|
||||||
|
|
||||||
|
v1.1
|
||||||
|
* Upgraded for Thingamajig v2.x architecture
|
||||||
|
* Disallowed the use of characters null (^@) and FF in texts
|
||||||
|
* Added the ability to read and convert non-native newline formats
|
||||||
|
|
||||||
|
v1.0
|
||||||
|
* Initial release
|
||||||
|
|
Loading…
Reference in New Issue