X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=machine.asm;h=86b1e7f1aac47f5276c6a3019dcb917b02f9febf;hb=9b8fcf87eaed58b6dfabcf885f8eef5484643de6;hp=8da016a7854214740c82e0957facbba3b3636520;hpb=86231a519d2f4966c99091d4aa532b2c4e05b1fa;p=rrq%2Frrqforth.git diff --git a/machine.asm b/machine.asm index 8da016a..86b1e7f 100644 --- a/machine.asm +++ b/machine.asm @@ -74,6 +74,7 @@ macro popr x { macro next { lodsq ; mov rax, [rsi] + add rsi,8 + call p_calltrace_DFA jmp qword [rax] ; goto code of that FORTH word (64 bit jump) } @@ -97,16 +98,15 @@ macro ENDFORTH { ;;; ======================================== ;;; The DOFORTH lays out a single FORTH call -macro DOFORTH label { +macro DOFORTH [label] { +common FORTH +forward dq label +common 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 +122,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 +155,7 @@ label: dq doforth else if doer in - dq label#_DFA + dq dofasm ; label#_DFA else dq doer end if @@ -165,10 +167,17 @@ label#_DFA: macro tfa2cfa reg { mov reg,qword [reg+8] } +macro tfa2does reg { + tfa2cfa reg + sub reg,8 +} macro tfa2dfa reg { tfa2cfa reg add reg,8 } +macro tfa2flags reg { + add reg,16 +} macro tfa2pfa reg { add reg,24 } @@ -189,11 +198,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 @@ -218,3 +228,25 @@ 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 +} + +;;; ======================================== +;;; The STREAM macro starts an in-core FORTH STREAM area. See WORD +;;; STREAM for details. + macro STREAM endlabel { + local datastart + dq $+32 + dq -1 + dq endlabel - datastart + dq 0 +datastart: + }