Reserve null and FF for indicating tape leaders and trailers and an empty tape reader respectively, add the ability to read and convert non-native newlines, and reword the readme
This commit is contained in:
parent
92b1c81162
commit
b388acc7b4
130
gidubba.asm
130
gidubba.asm
|
@ -889,20 +889,9 @@ iglead: load r1, fffd
|
|||
;Check for the RAM limit
|
||||
load r0, chrsto + 1
|
||||
load r1, chrsto + 2
|
||||
chkram: load r2, limit
|
||||
load r3, limit + 1
|
||||
brneq r0, r2, chread
|
||||
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
|
||||
chkram: cleq r0, r0, ramchk
|
||||
xor r2, r2
|
||||
brneq r1, r2, cmdp
|
||||
|
||||
;Read a character
|
||||
chread: load r1, fffd
|
||||
|
@ -915,12 +904,28 @@ chkend: xor r2, r2
|
|||
breq r0, r0, chrsto
|
||||
;Empty tape reader
|
||||
chkntp: nand r2, r2
|
||||
brneq r1, r2, chrsto
|
||||
brneq r1, r2, chklf
|
||||
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
|
||||
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
|
||||
load r2, #1a
|
||||
breq r1, r2, redend
|
||||
|
@ -938,6 +943,22 @@ chrsto: store buffer + 100, r1
|
|||
;Read the next character
|
||||
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
|
||||
redend: breq r0, r0, cmdp
|
||||
|
||||
|
@ -1311,6 +1332,12 @@ input: load r0, bfstrt
|
|||
inloop: load r1, ffff
|
||||
|
||||
;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
|
||||
load r2, #7f
|
||||
breq r1, r2, delbr
|
||||
|
@ -1804,6 +1831,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
|
||||
|
||||
;Variables
|
||||
|
|
10
readme.md
10
readme.md
|
@ -19,9 +19,13 @@ Format
|
|||
------
|
||||
|
||||
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
|
||||
that the input buffer can store at most 256 characters, including the
|
||||
newline.
|
||||
newline of a carriage return (^M) followed by a line feed (^J) (CRLF).
|
||||
Gidubba is able to read texts without an end-of-file or with different
|
||||
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
|
||||
-----
|
||||
|
|
Loading…
Reference in New Issue