Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore single-line comments in assembly. See #4 #9

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion derzforth.asm
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,17 @@ tib_init:
li TLEN, 0 # set TLEN to 0
li TPOS, 0 # set TPOS to 0

# TODO: ignore single-line comments (backslash til newline)
# TODO: ignore bounded comments (lparen til rparen)
# TODO: bounds check on TBUF (error or overwrite last char?)
interpreter_repl:
# read and echo a single char
call serial_getc
call serial_putc

# check for single-line comment
li t0, '\\' # comments start with \ char
beq a0, t0, interpreter_skip_comment # skip the comment if \ is found

# check for backspace
li t0, '\b'
bne a0, t0, interpreter_repl_char
Expand All @@ -311,6 +314,16 @@ interpreter_repl:

j interpreter_repl

interpreter_skip_comment:
# read and echo a single char
call serial_getc
call serial_putc

# skip char until newline is found
li t0, '\n' # newlines start with \n
bne a0, t0, interpreter_skip_comment # loop back to SKIP comment unless newline
j interpreter_repl

interpreter_repl_char:
add t0, TBUF, TLEN # t0 = dest addr for this char in TBUF
sb a0, 0(t0) # write char into TBUF
Expand Down