X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=machine.asm;h=7f65bbeb130390cd6f96121a65be3046275e5f6f;hb=e086c1738e84f6952008d1d2efa4e36b31b061b3;hp=357b80718695b4ea3dc56ff09f5c21eb3eccc927;hpb=02ef6e814ef0e6c61348c70bd310ba1f0df2506b;p=rrq%2Frrqforth.git diff --git a/machine.asm b/machine.asm index 357b807..7f65bbe 100644 --- a/machine.asm +++ b/machine.asm @@ -103,10 +103,6 @@ macro DOFORTH label { ENDFORTH } - previous_word = 0 ; Used for chaining the words - - IMMEDIATE = 1 ; optional flag (symbol) - ;;; ======================================== ;;; Macro WORD starts a FORTH word definition in this code. ;;; The layout of a word is as follows: @@ -122,6 +118,8 @@ macro DOFORTH label { ;;; CFA: [8 bytes] pointer to the word's "doer" code ;;; DFA: [? bytes] the word's data field +IMMEDIATE = 1 ; optional flag (symbol) + macro WORD label, name, doer, flags, previous, offset { local pname ;; align 8 @@ -153,7 +151,7 @@ label: dq doforth else if doer in - dq label#_DFA + dq dofasm ; label#_DFA else dq doer end if @@ -196,11 +194,12 @@ macro dfa2tfa reg { sub reg,24 mov reg,qword [reg] } -macro pushpname rg { ; ( reg -- chars* length ) - add rg,8 - push rg - sub rg,8 - push qword [rg] +;;; Code snippet to push a pname string with address and 64-bit length field. +;;; The register is advanced to point at the text part. +macro pushpname reg { + add reg,8 + push reg + push qword [reg-8] } ;;; ======================================== ;;; The BLOCK macro lays out the length for a subsequent block to the @@ -225,3 +224,13 @@ common dataend: } +;;; ======================================== +;;; The BRANCH macro lays out FORTH words BRANCH and 0BRANCH with offset +macro BRANCH zero,label { + if zero in <0> + dq p_zero_branch + else + dq p_branch + end if + dq label - $ - 8 +}