summaryrefslogtreecommitdiff
path: root/jefs.s
diff options
context:
space:
mode:
Diffstat (limited to 'jefs.s')
-rw-r--r--jefs.s69
1 files changed, 69 insertions, 0 deletions
diff --git a/jefs.s b/jefs.s
index a53b8d4..c0b1b82 100644
--- a/jefs.s
+++ b/jefs.s
@@ -68,18 +68,87 @@ _start:
mov rax, __NR_exit
syscall
+defword "bye", bye, 0
+ mov rdi, 0
+ mov rax, __NR_exit
+ syscall
+ ret ; will not be reached
+
defword "@", fetch, 0
pspop r11
mov r12, qword [r11]
pspush r12
ret
+defword "c@", cfetch, 0
+ pspop r11
+ xor r12, r12
+ mov r12b, [r11]
+ pspush r12
+ ret
+
defword "!", store, 0
pspop r11
pspop r12
mov qword [r11], r12
ret
+defword "c!", cstore, 0
+ pspop r11
+ pspop r12
+ mov [r11], r12b
+ ret
+
+; stage 1 parser. very rudimentary, does not recognise numbers,
+; only recognises newlines and spaces as whitespace.
+; since it will only parse a little bit of the init file
+; there won't be any error checking either.
+defword "parse", parse, 0
+ mov r13, qword [to_in]
+ add r13, initfile
+ mov r12b, byte [r13]
+
+.wsloop: ; skip initial ws
+ cmp r12b, 0x20
+ je .wsloop_cont
+ cmp r12b, 0x0a
+ jne .wordloop_start
+.wsloop_cont:
+ inc r13
+ mov r12b, byte [r13]
+ jmp .wsloop
+
+.wordloop_start:
+ push r13 ; keep start address of this word for later
+ mov r11, 1 ; W: word length count
+.wordloop:
+ cmp r12b, 0x20
+ je .wordloop_end
+ cmp r12b, 0x0a
+ je .wordloop_end
+
+ inc r11
+ inc r13
+ mov r12b, byte [r13]
+ jmp .wordloop
+
+.wordloop_end:
+ sub r13, initfile
+ mov qword [to_in], r13
+ pop r13
+ pspush r13 ; c-addr
+ pspush r11 ; u
+ ret
+
+defword "find", find, 0
+ ret
+
+; stage 1 interpreter, just reads from initfile
+defword "interpret", interpret, 0
+ ret
+
+defvar ">in", to_in, 0, initfile
+
initfile:
incbin "jefs.fs"
initlen equ $ - initfile