# 18fxx2 microcontroller target compiler # the target is an (incremental optimizing) procedure threaded # forth (native code), using 2 dictionaries: words & macros, # in the style of colorforth. (bitgrid 16 0x1000) new constant pic-buf 0x100 variable! pic-ast : pic-comma pic-ast >r r ! r> 1 + pic-ast ! ; : pic-here pic-ast @ ; # load assembler defines "18f452-defs.pf" load # load instruction set "18fxx2-ins.pf" load () variable! pic-word () variable! pic-macro # assembler : w| ; # destination wreg DEFAULT : reg| 0x0200 or # destination freg : op| 0xff and or ; # add operand to instruction : xop| swap op| ; # 0-op macro instructions ( -- opcode ) : DROP MOVF POSTDEC0 op| w| ; : DUP MOVWF PREINC0 op| reg| ; # 1-op macro instructions ( thing -- opcode ) : LIT MOVLW xop| ; # symbolic forth stuff : pic-find-macro pic-macro @find @ ; : pic-find-word pic-word @find @ ; : pic-literal ` lit pic-find pic-compile int pic-comma ;