The memory model of our Hack VM is currently very simple. We have adopted the separation be-tween code ROM and data RAM from Nisan & Schocken. The operand is a signed 20-bit integer, and it can be used as a direct value, or as a ROM or as a RAM address.
The evaluation of Prolog arithmetic expressions and the testing of Prolog arithmetic compari-sons is mainly done through the 4-bit “Fun” field of each instruction. In the following we give an overview of the available “Fun” fields and their role in Prolog compilation:
Name Value Usage
mov 0 is/2 built-in predicate
neg 1 (-)/1 evaluable function
add 2 (+)/2 evaluable function
sub 3 (-)/2 evaluable function
mul 4 (*)/2 evaluable function
zdiv 5 (//)/2 evaluable function
rem 6 (rem)/2 evaluable function
min 7 (min)/2 evaluable function
max 8 (max)/2 evaluable function
eq 9 (=:=)/2 built-in predicate
nq 10 (=\=)/2 built-in predicate
ls 11 (<)/2 built-in predicate
gr 12 (>)/2 built-in predicate
lq 13 (=<)/2 built-in predicate
gq 14 (>=)/2 built-in predicate
A logical thread has does addresses the RAM relative to a base address. By choosing different base addresses multiple logical threads can be run. Book keeping like the program counter PC and the accumulator ACCU are stored in negative offsets to the base.