537796de252a2c12db2f3597825afb3a1614f4ea
[rrq/jonasforth.git] / main.asm
1 format ELF64 executable
2
3 ;; The code in this macro is placed at the end of each Forth word. When we are
4 ;; executing a definition, this code is what causes execution to resume at the
5 ;; next word in that definition.
6 macro next {
7     ;; RSI points to the address of the definition of the next word to execute.
8     lodsq                   ; Load value at RSI into RAX and increment RSI
9     ;; Now RAX contains the location of the next word to execute. The first 8
10     ;; bytes of this word is the address of the codeword, which is what we want
11     ;; to execute.
12     jmp qword [rax]         ; Jump to the codeword of the current word
13 }
14
15 segment readable executable
16
17 start:
18     jmp $
19
20 segment readable