commit 6bc69c7f6e2b45bea9f15ebbc98bdba576999790
parent 13f75d2ef2aab619dd0592f85a80e88444d1e062
Author: Christian Ermann <christianermann@gmail.com>
Date: Mon, 4 Nov 2024 20:20:38 -0800
Add 'abort'
Diffstat:
| M | forth.s | | | 32 | ++++++++++++++++++++++++++++++-- |
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/forth.s b/forth.s
@@ -461,16 +461,20 @@ defcode "okay", 6, 0, 0xBA9EEB49, okay, prompt
defword "quit", 4, 0, 0x47878736, quit, okay
_quit_top:
+ .int rp_top, rp_store
.int prompt
.int refill, drop # TODO: What should happen when 'refill' fails?
.int interpret, okay
.int branch, _quit_top
+defword "abort", 5, 0, 0xA52BCAF9, abort, quit
+ .int sp_top, sp_store, quit
+
# -----------------------------------------------------------------------------
# memory access
# -----------------------------------------------------------------------------
-defcode "!", 1, 0, 0x240C8DEC, store, quit
+defcode "!", 1, 0, 0x240C8DEC, store, abort
pop w # address
pop x # value
store_cell x, 0(w)
@@ -562,7 +566,31 @@ defcode "align", 5, 0, 0xC73174DF, align, char_comma
# stack manipulation
# -----------------------------------------------------------------------------
-defcode "dup", 3, 0, 0xD330F226, dup, align
+defcode "sp0", 3, 0, 0x0C41B8B2, sp_top, align
+ # ( -- addr )
+ la w, __stacktop
+ push w
+ next
+
+defcode "sp!", 3, 0, 0x1D41D375, sp_store, sp_top
+ # ( addr -- )
+ pop w
+ mv psp, w
+ next
+
+defcode "rp0", 3, 0, 0x8AD91EDD, rp_top, sp_store
+ # ( -- addr )
+ la w, __stacktop_ret
+ push w
+ next
+
+defcode "rp!", 3, 0, 0x99D9367A, rp_store, rp_top
+ # ( addr -- )
+ pop w
+ mv rsp, w
+ next
+
+defcode "dup", 3, 0, 0xD330F226, dup, rp_store
load_cell w, 0(psp)
push w
next