codegen completion kit
To extend the code generator, the main "eval" must handle more n-code
instruction. The stub definition is "evalx" and "genwhile".
evalx
(op arg e) ; e is argument list
for NEW
eval head e,
out icArray
for SUB MUL DIV BAND SHL
SHR EQ LT GT
genbop
for LDX STX LDY STY
LDX LDY has
the form (ldx.a idx)
out
get.a/ld.a, eval idx, out icLdx
STX STY has
the form (stx.a idx val)
out
get.a/ld.a, eval idx, eval val, out icStx
genwhile (e)
(while e1 e2)
generate proper jump for
the form
jmp <in>
L: eval e2
in: eval e1
jt <L>
For patching proper displacement of jumps see how to generate
code for "if".
How to use codegen
You must have some n-code object first. (such as "t2.obj",
"t3.obj". Compile the code generator
c:>nut32
< gen.txt
use the code generator to generate s-code
c:>nsim32
< t2.obj > t2s.obj
use somv2 to examine the listing of s-code
c:>somv2
-l t2s.obj
or to execute it
c:>somv2
-x t2s.obj
End
6 July 2006