Dr Jefyll wrote:
I'm not clear why you began the executable code with the BRA. The following lda and sta seem meaningful as a placeholder to represent hypothetical user code. But why the BRA? Does it assist with testing?
As I've said before, I'm a complete noobie when it comes to Forth. In my attempt to incorporate some special support for FORTH, I decided to use the prefix instructions to support both an ITC and a DTC VM. As such, I followed a model where the parameter field of a primitive or secondary requires two bytes. Therefore, in my test case, I am just retaining the code field as a reminder of where the ITC CFA pointer must be inserted.I simply used the
bra *+2 as a two byte place holder for the code field; I kind of like how the machine code representation of that instruction, $80 $00, looks in the instruction stream.
When I set up the test for the DTC ENTER instruction, the
bra *+2 will be replaced with either the single byte (DTC)
ent ($7B) instruction.
Both you and Mike are correct in your assessment that a primitive DTC FORTH word could be implemented with machine code in the code field. The two cycles saved by having no code field in a DTC FORTH word probably should be the preferred implementation.
I hope to complete the testing of the FORTH VM support instructions soon:
nxt,
pli,
ini,
phi,
ent, and
lda (ip,I++). The ITC version of the fundamental operations will require the ind prefix instruction: ENTER =>
ind ent; NEXT =>
ind nxt; EXE =>
pli ind nxt; EXIT =>
pli ind nxt;
The auxiliary stack usage may add another prefix instruction (
osx) to the instruction sequences in either a DTC or an ITC implementation. With the
osx prefix, the auxiliary stack, accessed using X, can be used for the FORTH VM's Return Stack (RS), and the system stack can be used as the parameter stack (PS).