summaryrefslogtreecommitdiff
path: root/jefs.s
diff options
context:
space:
mode:
Diffstat (limited to 'jefs.s')
-rw-r--r--jefs.s29
1 files changed, 28 insertions, 1 deletions
diff --git a/jefs.s b/jefs.s
index 3d9fa1c..f3900f8 100644
--- a/jefs.s
+++ b/jefs.s
@@ -6,9 +6,18 @@
mov qword [r14], %1
%endmacro
+; this feels like Too much code and probably Too slow to have for every pspop.
+; we'll see
+; clobbers r8 (which isn't actually used anywhere here)
%macro pspop 1
mov %1, qword [r14]
lea r14, [r14+8]
+ cmp r14, wstack
+ jle %%ok
+ mov qword [error], 1
+ mov r8, qword [handler]
+ call r8
+ %%ok:
%endmacro
;;; dictionary macros {{{
@@ -62,7 +71,7 @@
section .bss exec
wstack_b: resq 2047
-wstack: resq 1
+wstack: resq 2
umem: resb 0x9c400
umem_e:
@@ -174,11 +183,13 @@ defword "c,", c_comma, 0
ret
defword "cmove", _cmove, 0 ; ( a1 a2 u -- )
+ call heredump
pspop rcx
pspop rdi
pspop rsi
rep movsb
+ call heredump
ret
defword "cmove,", _cmove_comma, 0 ; ( c-addr u -- )
@@ -242,6 +253,8 @@ defword "parse", parse, 0
pspush r11 ; u
ret
+; segfault issue is in here i think?
+; on second go around only one value is returned?
defword "cparse", cparse, 0
pspop r15 ; c
mov r13, qword [to_in]
@@ -1023,6 +1036,18 @@ defword "0branch", zerobranch, 0
mov qword [here], r12
ret
+; rudimentary error handler
+; this word may be called when the stack is fucked,
+; so instead we take the error from a variable called error.
+; this word is intended to be called as an xt from the HANDLER variable,
+; so better error handling can be given from forth.
+defword "(handler)", brac_handler, 0
+ mov r11, [error]
+ mov rdi, r11
+ mov rax, __NR_exit
+ syscall
+ ret
+
; TEMPORARY HORRIBLE DEBUGGING BULLSHIT {{{
; debugging word; outputs raw bytes so needs to be piped through `x(x)d`
; terrible and awful
@@ -1100,6 +1125,8 @@ defvar "s0", s0, 0, wstack
defvar "h0", h0, 0, umem ; beginning of user memory area
defvar "hend", hend, 0, umem_e ; ending of user memory area
defvar "base", base, 0, 10
+defvar "error", error, 0, 0
+defvar "handler", handler, 0, brac_handler
defvar "latest", latest, 0, lfa_latest
initfile: