The Instr parameter is best explained by means of an example. The following example shows the full instruction set of a simple computer, preceded by the necessary operand STRUCT definitions. Each instruction consists of a function and zero, one or more operands.
>>> include insttruction table here.
-- operands for loading a register from memory using address + (index reg)
STRUCT (t_load, [RSTRING (dest_reg, "-", 5), RSTRING (src_reg, "-", 5),
RINT (address, 0)]);
-- operands for storing a register to memory using address + (index reg)
STRUCT (t_store, [RSTRING (src_reg, "-", 5), RSTRING (dest_reg, "-", 5),
RINT (address, 0)]);
-- operand for loading register with immediate
STRUCT (t_loadi, [RSTRING (dest_reg, "-", 5), RINT (immediate, 0)]);
-- operands for move instruction
STRUCT (t_move, [RSTRING (dest_reg, "-", 5), RSTRING (src_reg, "-", 5)]);
-- operands for ALU scalar instruction group
STRUCT (t_alu, [RSTRING (dest_reg, "-", 5),
RSTRING (src_reg1, "-", 5),
RSTRING (src_reg2, "-", 5)]);
-- operands for ALUI scalar instruction group
STRUCT (t_alui, [RSTRING (dest_reg, "-", 5),
RSTRING (src_reg1, "-", 5),
RINT (immediate, 0)]);
-- operands for COMP instruction
STRUCT (t_comp, [RSTRING (src_reg1, "-", 5), RSTRING (src_reg2, "-", 5)]);
-- Definition of a simple instruction set
INSTR (t_simple_instrn_set, [(NOP),
(JUMP, RINT (immediate, 0)),
(JREG, RSTRING (src_reg, "-")),
(SETCC(SEQ,SNE,SGT,SLT,SGE,SLE), RSTRUCT (t_comp, comp_field)),
(BRANCH, RSTRING (label, "-", 50)),
(LDM, RSTRUCT (t_load, load_field)),
(LDI, RSTRUCT (t_loadi, loadi_field)),
(STM, RSTRUCT (t_store, store_field)),
(ALU(ADD,SUB,MUL,DIV,AND,OR,XOR,SLL,SRL,SRA), RSTRUCT (t_alu, alu_field)),
(ALUI(ADDI,SUBI,MULI,DIVI,ANDI,ORI,XORI,SLLI,SRLI,SRAI),
RSTRUCT (t_alui, alui_field)),
(STOP) ], function);
Notes