+
+;;; ========================================
+;;; These are the core "execution semantics" words, which are placed
+;;; first so as to remain at the same binary address at successive
+;;; compilations, which is helful for declaring special debugging gdb
+;;; aliases.
+;;;
+;;; The DO* words are declared as "variables" to provide their
+;;; assembled address when used in FORTH.
+;;;
+;;; The register context at entry to an "execution semantcs" code
+;;; snippets is:
+;;; rax = cfa* of word to execute
+;;; rsi = cell* in the calling definition, after calling cell
+;;; rsp = data stack pointer
+;;; rbp = return stack pointer
+;;;
+
+previous_word = 0 ; Used for chaining the words
+
+ WORD p_dofasm,'doFASM',dovariable
+ ;; Execution semantics for assembly words.
+dofasm:
+ add rax,8
+ jmp rax
+
+ WORD p_doforth,'doFORTH',dovariable ;
+ ;; Execution semantics for FORTH defition word.
+doforth:
+ pushr rsi
+ lea rsi, [rax+8] ; rsi = the DFA of the rax word
+ next
+
+ WORD p_dodoes,'doDOES',dovariable
+ ;; Execution semantics for DOES>
+ ;; [cfa-8] holds the adjustment offset ("does offset")
+dodoes:
+ pushr rsi
+ lea rsi, [rax+8] ; rsi = the DFA of the rax word
+ add rsi,qword [rax-8] ; adjust rsi by the "does offset'
+ next
+
+ WORD p_dovariable,'doVARIABLE',dovariable
+ ;; Execution semantics for a variable ( -- addr )
+ ;; rax points to CFA field
+dovariable:
+ lea rax, [rax+8] ; rsi = the DFA of the rax word
+ push rax
+ next
+
+ WORD p_dovalue,'doVALUE',dovariable
+ ;; Execution semantics for a value constant ( -- v )
+ ;; rax points to CFA field
+dovalue:
+ lea rax, [rax+8] ; rsi = the DFA of the rax word
+ push qword [rax]
+ next
+
+ WORD p_dostring,'doSTRING',dovariable
+ ;; Execution semantics for a string constant ( -- addr n )
+ ;; rax points to CFA field
+dostring:
+ lea rax, [rax+8] ; rsi = the DFA of the rax word
+ pushpname rax
+ next
+
+ WORD p_calltrace,'[calltrace]',dovalue
+ ;; Common call point for debugging
+ ;; rax = cfa of called word
+ ;; rsi = cell* of next forth word
+ ;; [$rsp] = from where the call was
+ ret
+
+include 'syscalls.asm'
+
+;;; ========================================
+;;; The stacks are placed here.
+
+ ;segment readable writable