In the GAMA, new assembler instructions for an arbitrary abstract machine are defined with definstr. definstr expects a COMMON LISP argument list, a type specification for these arguments, and the COMMON LISP code defining the instruction.
The following example shows the definition of the LLAMA instruction push-constant:
(definstr push-constant (c) (CONST) :standard (ll.push-constant (stack-push (constant c))))
ll.push-constant is the name of the COMMON LISP function corresponding to the push-constant instruction. The keyword :standard declares push-constant to be a simple instruction. The next example shows a non-standard instruction for which more than one COMMON LISP definition is needed:
(definstr ll-call (proc) (LABEL) :static (ll.call/st (stack-push (reg P)) (set-reg P proc)) :dynamic (ll.call/dy (stack-push (reg P)) (set-reg P (gmem.get proc))))
All instructions expecting a label can be used in two different ways: statically and dynamically. In the dynamic version, the address corresponding to the label is an entry in a jump table: an additional gmem.get is needed to dereference it. The static version does not use a jump table entry but directly uses the real address: dereferencing is not needed. It is used for procedures which will not be changed (like those in the prelude).