commit 2c3d61e24dd30e6031979b14f219b9b80776eae9
parent 8bdb3375387459031f6315190c8a0ef2f382d1cb
Author: Christian Ermann <christianermann@gmail.com>
Date: Mon, 2 Dec 2024 16:22:35 -0800
Replace 'postpone' with '^' prefix
Diffstat:
| M | src/forth.s | | | 71 | +++++++++++++++++++++++++++++++++++++++-------------------------------- |
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/src/forth.s b/src/forth.s
@@ -199,9 +199,14 @@ defvar "'", prefix_address, 0x220C8AC6
.int _prefix_binary
.int string_to_address_comma
+defvar "^", prefix_postpone, 0xDB0C1B01
+ .int 0x5E
+ .int _prefix_address
+ .int string_to_postpone
+
defvar "*", prefix_execute, 0x2F0C9F3D
.int 0x2A
- .int _prefix_address
+ .int _prefix_postpone
.int string_to_execute
defvar ":", prefix_define, 0x3F0CB86D
@@ -584,6 +589,39 @@ defword "string>address,", string_to_address_comma, 0x313E6882
_string_to_address_comma_fail:
exit
+defword "string>postpone", string_to_postpone, 0x9EFD2390
+ jal find
+ beqz w, _string_to_postpone_fail
+ addi x, w, flag_offset
+ lb x, 0(x)
+ andi x, x, flag_immediate
+ addi w, w, code_offset
+ lw w, 0(w)
+ beqz x, _string_to_postpone_compile
+_string_to_postpone_execute:
+ # stores `jal-to <xt>` into the current definition
+ jal jal_to
+ jal compile_comma
+ push w
+ li w, -1
+ exit
+_string_to_postpone_compile:
+ # stores `literal<xt> jal-to compile,` into the current definition
+ jal literal
+ push w
+ la w, jal_to
+ jal jal_to
+ jal compile_comma
+ push w
+ la w, compile_comma
+ jal jal_to
+ jal compile_comma
+ push w
+ li w, -1
+ exit
+_string_to_postpone_fail:
+ exit
+
defword "literal", literal, 0xECB9D8E4, flags=flag_immediate
push w
li w, 0xFFC10113 # addi psp, psp, -4
@@ -1475,37 +1513,6 @@ defcode "immediate?", immediate_q, 0x89F23E9F
push w
next
-defword "postpone", postpone, 0x933F531F, flags=flag_immediate
- jal parse_word
- jal find
- addi x, w, flag_offset
- lb x, 0(x)
- andi x, x, flag_immediate
- addi w, w, code_offset
- load_cell w, 0(w)
- beqz x, _postpone_compile
-_postpone_execute:
- # stores "<xt>" into the current definition
- jal jal_to
- jal comma
- exit
-_postpone_compile:
- # stores "lit <xt> ," into the current definition
- push w
- la w, lit
- jal jal_to
- jal comma
- jal comma
- push w
- la w, jal_to
- jal jal_to
- jal comma
- push w
- la w, comma
- jal jal_to
- jal comma
- exit
-
defcode "immediate", immediate, 0xF232267A
la x, _latest
load_cell x, 0(x)