forth-riscv

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

commit 46778b08a87e3a4fdf6b51d9cebd88ba3774ec06
parent 80594583cf6f4ef673ad841d171c21ceced988d3
Author: Christian Ermann <christianermann@gmail.com>
Date:   Wed, 13 Nov 2024 12:31:49 -0800

Add ';does'

Diffstat:
Mforth.s | 38++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+), 0 deletions(-)

diff --git a/forth.s b/forth.s @@ -152,6 +152,13 @@ docon: push w next +dodoes: + push_ret ip # save old ip + addi w, w, cell # make w point to parameter field + push w # push w onto param. stack + mv ip, ra # set new ip + next + defcode "exit", exit, 0xCDED1A85 pop_ret ip next @@ -957,6 +964,37 @@ defword "constant", constant, 0x0691EA25 .int comma # initialize to value on stack .int exit +defcode "jal-dodoes", jal_dodoes, 0x4F82E787 + pop w + la x, dodoes + sub x, x, w + li y, 0x000FF000 # imm[19:12] + and w, x, y + li y, 0x00100000 # imm[20] + and y, x, y + slli y, y, 11 + add w, w, y + li y, 0x00000800 # imm[11] + and y, x, y + slli y, y, 9 + add w, w, y + andi y, x, 0x000007FE # imm[10:1] + slli y, y, 20 + add w, w, y + addi w, w, 0x000000EF # jal ra, imm + push w + next + +defword ";does", does, 0xF5BCD777, flags=flag_immediate + .int lit, does_internal, comma + .int here, jal_dodoes, comma + .int exit + +defword "(;does)", does_internal, 0xED4B7678 + .int from_ret + .int latest, fetch, lit, code_offset, plus, store + .int exit + defcode "read-char", read_char, 0xF07E2044 jal _read_char_impl push w