nut32 explain for week 4 lecture in Embedded Processor This version completed nut31 with "let" "enum" and string. Then implement an eval to prepare for a code generator. Code generator is the last piece. It generates s-code for a stack processor. step of work 1) complete nut31 2) write a small eval in nut run it with nsim 3) write a s-code generator 23 June 2006 The nut32/nut.c is essentially the same as in nut31. Only one bug fixed is char token[] which is previously declared as 20 char, now becomes 80 char (for storing the input token string). The nut32/nsim.c is identical to nut31. nut-in-nut compiler in nut32 (/test/nut.txt) is more complete, with "let" "enum" and string. The "evaluator" (or the n-code interpreter) is also implemented in nut, called "sim.txt" (also in /test). It can execute n-code object. sim.txt is an interim step to study a code generator. To "eval" n-code, the n-code tree must be traversed. The simplest way to do it is to do it recursively. The "operational semantic" (how each code acts) is explicit in the nut-code for "eval" function. The "eval" is only partially implemented. It understands only 12 operators (just enough to support running the example "t2.txt"): if, do, add, call, lit, str, get, ld, st, ldx, fun, sys. the test source file is as follows: (enum 10 xAA xBB) (let gv tv) (def prints s () (if (vec s 0) (do (sys 2 (vec s 0)) (prints (+ s 1))))) (def add1 x () (+ x 1)) (def main () () (do (set tv 5) (prints "string") (sys 1 (add1 xBB)))) This test exercise "let", "enum" and string. It outputs "string12" to the screen. Detailed discussion of the simulator in nut is in a separate article. This package is also include "gen.txt" the code generator. The code generator reads n-code object and generates s-code (version som-v2) object. The s-code object can be executed by somv2 (virtual machine). s-code is the instruction set that will be supported by SX chip simulator (to be designed and implemented soon for future lecture). 27 June 2006