commit 5c4325e5be52464ae22613fe540e6fd5202de959
parent c59a8073517db071a7a6f33026abafe5834b5c3e
Author: Christian Ermann <christianermann@gmail.com>
Date: Mon, 28 Oct 2024 23:38:26 -0700
Shorten 'word' and 'find' definitions
Diffstat:
| M | forth.s | | | 28 | +++++++--------------------- |
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/forth.s b/forth.s
@@ -140,16 +140,9 @@ defcode "key", 3, 0, 0x6815C86C, key, emit
next
defcode "word", 4, 0, 0x6A98E9FD, word, key
- jal word_impl
- push w
- push x
- next
-
-word_impl:
li s3, 0x20 # space
li s4, 0x0A # new line
li s5, 0x0D # carriage return
- addi s6, ra, 0
_skip_whitespace:
jal uart_get_char
beq w, s3, _skip_whitespace
@@ -167,21 +160,14 @@ _next_char:
_word_end:
la w, word_buffer
sub x, x, w
- addi ra, s6, 0
- ret
-
-defcode "find", 4, 0, 0xBDF0855A, find, word
- pop x
- pop w
- jal find_impl # w = word address or 0, if not found
push w
+ push x
next
-find_impl:
- # w = word name address
- # x = word name length
- push_ret ra
- jal hash_impl # w = word hash
+defcode "find", 4, 0, 0xBDF0855A, find, word
+ pop x # length
+ pop w # address
+ jal hash_impl
la s3, _latest
load_cell s3, 0(s3)
_check_word_hidden:
@@ -196,8 +182,8 @@ _next_word:
bnez s3, _check_word_hidden
_found_or_out_of_words:
mv w, s3
- pop_ret ra
- ret
+ push w
+ next
defcode ">cfa", 4, 0, 0x8CAC3233, to_cfa, find
pop w