head 1.1; branch 1.1.1; access ; symbols start':1.1.1.1 cd16:1.1.1; locks ; strict; comment @# @; 1.1 date 2003.08.15.17.26.01; author beckert; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2003.08.15.17.26.01; author beckert; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @

Code Generation

Most of the work is done by a deferred word called PFUNC. It takes source and destination operands and lays down machine code for the requested function. The interface to the target compiler only uses a few deferred words:

PFUNC ( op:s2:s1 dest -- ) Arithmetic, logic and move
^STORE ( x1 x2 operation -- ) Memory stores
^STOREA ( x1 operation -- ) Register stores
^SET ( port# value -- ) Bit set/clear
^ZERO ( operation -- ) Zero operand functions
^BRAN ( destaddr srctype op -- resaddr ) Branches
<bmark ( -- resaddr ) Mark a backward branch
>bresolve ( resaddr -- ) Resolve a forward branch

In order to generate code for a particular target, redirect these words. You can also alter the following VALUEs using TO.

Cellsize Target bytes/cell, usually 2 or 4
Cache Number of registers to use for the top of stack
MaxScratch Number of allowed scratchpad registers
Bigendian Byte order: default is little endian (0)
Bits/cell Target bits/cell
Maxshifts Maximum shift count of compiled shifts

Registers in the virtual machine:

PC Program counter
SP Data stack pointer
RP Return stack pointer, usually hardware SP
A The A register
P1,P2,... Cache for top of stack
P-1,P-2,... Scratchpad registers
@ 1.1.1.1 log @Imported sources @ text @@