You can now run:
make main && ./main
To run the interpreter without needing to boot up a virtual machine.
Note that this mode uses per-line buffering by default, so you may have to press
enter where you would normally only need a space.
.start:
}
-os_code_section
-
include "impl.asm" ; Misc. subroutines
include "bootstrap.asm" ; Forth words encoded in Assembly
+os_code_section
+
main:
cld ; Clear direction flag so LODSQ does the right thing.
mov rbp, return_stack_top ; Initialize return stack
format ELF64 executable
+entry main
macro os_code_section {
segment readable executable
segment readable writable
}
+os_code_section
+
os_initialize:
ret
os_print_string:
+ push rsi
+ mov rax, 1
+ mov rdi, 1
+ mov rsi, rcx
+ syscall
+ pop rsi
ret
os_read_char:
+ push rsi
+ mov rax, 0
+ mov rdi, 0
+ mov rsi, .buffer
+ mov rdx, 1
+ syscall
+ pop rsi
+ movzx rax, byte [.buffer]
ret
os_terminate:
- ret
+ mov rdi, rax
+ mov rax, $3C
+ syscall
+
+os_data_section
+
+os_read_char.buffer db ?