forth-riscv

My forth
git clone git://git.electrosoup.com/forth-riscv
Log | Files | Refs

commit e1249db39d27511761e07e0a74b37ebdd8ca3cff
parent b02ede06c26c1f58b0c95016109969f161d80207
Author: Christian Ermann <christianermann@gmail.com>
Date:   Tue, 29 Oct 2024 19:41:33 -0700

Redefine 'refill' as a high-level word

Diffstat:
Mforth.s | 57+++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 18 deletions(-)

diff --git a/forth.s b/forth.s @@ -167,21 +167,18 @@ accept_impl: pop_ret ra ret -defcode "refill", 6, 0, 0x238BAA91, refill, accept - # fill input buffer from the user input device - la x, tib - la w, tib_len - load_cell w, 0(w) - jal accept_impl - # set source to terminal input buffer - la y, _source_len - store_cell w, 0(y) - # set input offset to 0 - la y, _input_offset - store_cell zero, 0(y) - # return true - push_imm -1 - next +defword "refill-tib", 10, 0, 0xC8155C0B, refill_tib, accept + .int tib, accept, dup, q_branch, _refill_tib_failed + .int source_len, store + .int tib, drop, source_addr, store + .int lit, 0, source_offset, store + .int lit, -1 +_refill_tib_failed: + .int exit + +defword "refill", 6, 0, 0x238BAA91, refill, refill_tib + .int refill_tib + .int exit defcode "source", 6, 0, 0x238BAA91, source, refill la w, _source @@ -192,6 +189,30 @@ defcode "source", 6, 0, 0x238BAA91, source, refill push x next +defcode "source-addr", 11, 0, 0x997F9EE8, source_addr, source + la w, _source + push w + next + +defcode "source-len", 10, 0, 0x1B513E8E, source_len, source_addr + la w, _source_len + push w + next + +defcode "source-offset", 13, 0, 0x7F8C1674, source_offset, source_len + la w, _input_offset + push w + next + +defcode "tib", 3, 0, 0xC90B0194, tib, source_len + # ( -- addr len ) + la w, _tib + push w + la w, _tib_len + load_cell w, 0(w) + push w + next + defcode "parse-word", 10, 0, 0xB218226F, parse_word, source la w, _source load_cell w, 0(w) # buff addr @@ -518,13 +539,13 @@ _meta: .int __meta_start _state: .int state_immediate -_source: .int tib +_source: .int _tib _source_len: .int 0 _input_offset: .int 0 -tib: .space 255 -tib_len: .int 255 +_tib: .space 255 +_tib_len: .int 255 .section ".text.boot" start: