projects
/
rrq
/
rrqforth.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reorganisation of code
[rrq/rrqforth.git]
/
machine.asm
diff --git
a/machine.asm
b/machine.asm
index 74b1060427dbce1cfc4321e405ae19f8e2484f1b..7f65bbeb130390cd6f96121a65be3046275e5f6f 100644
(file)
--- a/
machine.asm
+++ b/
machine.asm
@@
-103,10
+103,6
@@
macro DOFORTH label {
ENDFORTH
}
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:
;;; ========================================
;;; 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
;;; 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
macro WORD label, name, doer, flags, previous, offset {
local pname
;; align 8
@@
-134,6
+132,7
@@
label#_TFA:
end if
previous_word = label#_TFA
;; PFA
end if
previous_word = label#_TFA
;; PFA
+label#_pCFA:
dq label#_CFA ; link to CFA of word
dq flags + 0
label#_PFA:
dq label#_CFA ; link to CFA of word
dq flags + 0
label#_PFA:
@@
-141,6
+140,7
@@
label#_PFA:
db name
pname: db 0 ; extra NUL byte
;; align 8
db name
pname: db 0 ; extra NUL byte
;; align 8
+label#_pTFA:
dq label#_TFA ; link to TFA of word
label#_OFF:
dq offset + 0 ; The DOES offset. Defaults to 0.
dq label#_TFA ; link to TFA of word
label#_OFF:
dq offset + 0 ; The DOES offset. Defaults to 0.
@@
-151,7
+151,7
@@
label:
dq doforth
else
if doer in <fasm>
dq doforth
else
if doer in <fasm>
- dq label#_DFA
+ dq
dofasm ;
label#_DFA
else
dq doer
end if
else
dq doer
end if
@@
-163,10
+163,17
@@
label#_DFA:
macro tfa2cfa reg {
mov reg,qword [reg+8]
}
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 tfa2dfa reg {
tfa2cfa reg
add reg,8
}
+macro tfa2flags reg {
+ add reg,16
+}
macro tfa2pfa reg {
add reg,24
}
macro tfa2pfa reg {
add reg,24
}
@@
-187,11
+194,12
@@
macro dfa2tfa reg {
sub reg,24
mov reg,qword [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
}
;;; ========================================
;;; The BLOCK macro lays out the length for a subsequent block to the
@@
-216,3
+224,13
@@
common
dataend:
}
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
+}