Initial commit, can parse a test source file but no assembly passes yet
authorNick Downing <nick@ndcode.org>
Mon, 22 Jan 2024 06:04:34 +0000 (17:04 +1100)
committerNick Downing <nick@ndcode.org>
Mon, 22 Jan 2024 06:08:14 +0000 (17:08 +1100)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
c_vm.c [new file with mode: 0644]
test.asm [new file with mode: 0644]
vm_asm.l [new file with mode: 0644]
vm_asm.py [new file with mode: 0755]
vm_asm.t [new file with mode: 0644]
vm_asm.y [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..3a1c769
--- /dev/null
@@ -0,0 +1,6 @@
+*.xml
+__pycache__
+/element.py
+/lex_yy.py
+/t_def.py
+/y_tab.py
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..6ea358f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,27 @@
+CFLAGS=-Wall
+
+all: \
+element.py \
+lex_yy.py \
+t_def.py \
+y_tab.py \
+c_vm
+
+element.py:
+       pitree --install-element
+
+lex_yy.py: vm_asm.l
+       pilex --element --groups --python $<
+
+t_def.py: vm_asm.t
+       pitree --python $<
+
+y_tab.py: vm_asm.y
+       piyacc --element --python $<
+
+c_vm.o: c_vm.c
+c_vm: c_vm.o
+       ${CC} -o $@ $<
+
+clean:
+       rm -f element.py lex_yy.py t_def.py y_tab.py c_vm *.o
diff --git a/c_vm.c b/c_vm.c
new file mode 100644 (file)
index 0000000..92ffa00
--- /dev/null
+++ b/c_vm.c
@@ -0,0 +1,934 @@
+#include <stdio.h>
+
+enum op {
+  // the following are coded as OP_xxx
+  OP_NOP = 0,
+  OP_ADD_EXPR_I8_R1,
+  OP_ADD_EXPR_I8_R2,
+  OP_ADD_EXPR_I8_R3,
+  OP_ADD_EXPR_I8_R4,
+  OP_ADD_EXPR_I8_R5,
+  OP_ADD_EXPR_I16_R1,
+  OP_ADD_EXPR_I16_R2,
+  OP_ADD_EXPR_I16_R3,
+  OP_ADD_EXPR_I16_R4,
+  OP_ADD_EXPR_I16_R5,
+  OP_ADD_EXPR_I32_R1,
+  OP_ADD_EXPR_I32_R2,
+  OP_ADD_EXPR_I32_R3,
+  OP_ADD_EXPR_I32_R4,
+  OP_ADD_EXPR_I32_R5,
+  OP_ADD_I8,
+  OP_ADD_I16,
+  OP_ADD_I32,
+  OP_ADD_F32,
+  OP_AND_I8,
+  OP_AND_I16,
+  OP_AND_I32,
+  OP_CALL,
+  OP_CALL_EXPR_I8,
+  OP_CALL_EXPR_I16,
+  OP_CALL_EXPR_I32,
+  OP_CVT_SI8_I16,
+  OP_CVT_SI8_I32,
+  OP_CVT_SI8_F32,
+  OP_CVT_SI16_I32,
+  OP_CVT_SI16_F32,
+  OP_CVT_SI32_F32,
+  OP_CVT_UI8_I16,
+  OP_CVT_UI8_I32,
+  OP_CVT_UI8_F32,
+  OP_CVT_UI16_I32,
+  OP_CVT_UI16_F32,
+  OP_CVT_UI32_F32,
+  OP_CVT_F32_I8,
+  OP_CVT_F32_I16,
+  OP_CVT_F32_I32,
+  OP_DIV_SI8,
+  OP_DIV_SI16,
+  OP_DIV_SI32,
+  OP_DIV_UI8,
+  OP_DIV_UI16,
+  OP_DIV_UI32,
+  OP_DIV_F32,
+  OP_DIV_R_SI8,
+  OP_DIV_R_SI16,
+  OP_DIV_R_SI32,
+  OP_DIV_R_UI8,
+  OP_DIV_R_UI16,
+  OP_DIV_R_UI32,
+  OP_DIV_R_F32,
+  OP_EQ_I8,
+  OP_EQ_I16,
+  OP_EQ_I32,
+  OP_EQ_F32,
+  OP_GE_SI8,
+  OP_GE_SI16,
+  OP_GE_SI32,
+  OP_GE_UI8,
+  OP_GE_UI16,
+  OP_GE_UI32,
+  OP_GE_F32,
+  OP_GT_SI8,
+  OP_GT_SI16,
+  OP_GT_SI32,
+  OP_GT_UI8,
+  OP_GT_UI16,
+  OP_GT_UI32,
+  OP_GT_F32,
+  OP_IMM_EXPR_8,
+  OP_IMM_EXPR_16,
+  OP_IMM_EXPR_32,
+  OP_JMPF_I8_EXPR_I8,
+  OP_JMPF_I8_EXPR_I16,
+  OP_JMPF_I8_EXPR_I32,
+  OP_JMPF_I16_EXPR_I8,
+  OP_JMPF_I16_EXPR_I16,
+  OP_JMPF_I16_EXPR_I32,
+  OP_JMPF_I32_EXPR_I8,
+  OP_JMPF_I32_EXPR_I16,
+  OP_JMPF_I32_EXPR_I32,
+  OP_JMPF_F32_EXPR_I8,
+  OP_JMPF_F32_EXPR_I16,
+  OP_JMPF_F32_EXPR_I32,
+  OP_JMPF_R1_EXPR_I8,
+  OP_JMPF_R1_EXPR_I16,
+  OP_JMPF_R1_EXPR_I32,
+  OP_JMPF_R2_EXPR_I8,
+  OP_JMPF_R2_EXPR_I16,
+  OP_JMPF_R2_EXPR_I32,
+  OP_JMPF_R3_EXPR_I8,
+  OP_JMPF_R3_EXPR_I16,
+  OP_JMPF_R3_EXPR_I32,
+  OP_JMPT_I8_EXPR_I8,
+  OP_JMPT_I8_EXPR_I16,
+  OP_JMPT_I8_EXPR_I32,
+  OP_JMPT_I16_EXPR_I8,
+  OP_JMPT_I16_EXPR_I16,
+  OP_JMPT_I16_EXPR_I32,
+  OP_JMPT_I32_EXPR_I8,
+  OP_JMPT_I32_EXPR_I16,
+  OP_JMPT_I32_EXPR_I32,
+  OP_JMPT_F32_EXPR_I8,
+  OP_JMPT_F32_EXPR_I16,
+  OP_JMPT_F32_EXPR_I32,
+  OP_JMPT_R1_EXPR_I8,
+  OP_JMPT_R1_EXPR_I16,
+  OP_JMPT_R1_EXPR_I32,
+  OP_JMPT_R2_EXPR_I8,
+  OP_JMPT_R2_EXPR_I16,
+  OP_JMPT_R2_EXPR_I32,
+  OP_JMPT_R3_EXPR_I8,
+  OP_JMPT_R3_EXPR_I16,
+  OP_JMPT_R3_EXPR_I32,
+  OP_LD_8,
+  OP_LD_16,
+  OP_LD_32,
+  OP_LEA_EXPR_I8_R1,
+  OP_LEA_EXPR_I8_R2,
+  OP_LEA_EXPR_I8_R3,
+  OP_LEA_EXPR_I8_R4,
+  OP_LEA_EXPR_I8_R5,
+  OP_LEA_EXPR_I16_R1,
+  OP_LEA_EXPR_I16_R2,
+  OP_LEA_EXPR_I16_R3,
+  OP_LEA_EXPR_I16_R4,
+  OP_LEA_EXPR_I16_R5,
+  OP_LEA_EXPR_I32_R1,
+  OP_LEA_EXPR_I32_R2,
+  OP_LEA_EXPR_I32_R3,
+  OP_LEA_EXPR_I32_R4,
+  OP_LEA_EXPR_I32_R5,
+  OP_LE_SI8,
+  OP_LE_SI16,
+  OP_LE_SI32,
+  OP_LE_UI8,
+  OP_LE_UI16,
+  OP_LE_UI32,
+  OP_LE_F32,
+  OP_LT_SI8,
+  OP_LT_SI16,
+  OP_LT_SI32,
+  OP_LT_UI8,
+  OP_LT_UI16,
+  OP_LT_UI32,
+  OP_LT_F32,
+  OP_MOD_SI8,
+  OP_MOD_SI16,
+  OP_MOD_SI32,
+  OP_MOD_UI8,
+  OP_MOD_UI16,
+  OP_MOD_UI32,
+  OP_MOD_R_SI8,
+  OP_MOD_R_SI16,
+  OP_MOD_R_SI32,
+  OP_MOD_R_UI8,
+  OP_MOD_R_UI16,
+  OP_MOD_R_UI32,
+  OP_MOV_R0_R1,
+  OP_MOV_R0_R2,
+  OP_MOV_R0_R3,
+  OP_MOV_R0_R4,
+  OP_MOV_R0_R5,
+  OP_MOV_R1_R0,
+  OP_MOV_R2_R0,
+  OP_MOV_R3_R0,
+  OP_MOV_R4_R0,
+  OP_MOV_R5_R0,
+  OP_MUL_I8,
+  OP_MUL_I16,
+  OP_MUL_I32,
+  OP_MUL_F32,
+  OP_NEG_I8,
+  OP_NEG_I16,
+  OP_NEG_I32,
+  OP_NEG_F32,
+  OP_NE_I8,
+  OP_NE_I16,
+  OP_NE_I32,
+  OP_NE_F32,
+  OP_NOT_I8,
+  OP_NOT_I16,
+  OP_NOT_I32,
+  OP_OR_I8,
+  OP_OR_I16,
+  OP_OR_I32,
+  OP_POP_8,
+  OP_POP_16,
+  OP_POP_32,
+  OP_POP_R1,
+  OP_POP_R2,
+  OP_POP_R3,
+  OP_POP_R4,
+  OP_POP_R5,
+  OP_PUSH_8,
+  OP_PUSH_16,
+  OP_PUSH_32,
+  OP_PUSH_R1,
+  OP_PUSH_R2,
+  OP_PUSH_R3,
+  OP_PUSH_R4,
+  OP_PUSH_R5,
+  OP_RET,
+  OP_SHL_I8,
+  OP_SHL_I16,
+  OP_SHL_I32,
+  OP_SHL_R_I8,
+  OP_SHL_R_I16,
+  OP_SHL_R_I32,
+  OP_SHR_SI8,
+  OP_SHR_SI16,
+  OP_SHR_SI32,
+  OP_SHR_UI8,
+  OP_SHR_UI16,
+  OP_SHR_UI32,
+  OP_SHR_R_SI8,
+  OP_SHR_R_SI16,
+  OP_SHR_R_SI32,
+  OP_SHR_R_UI8,
+  OP_SHR_R_UI16,
+  OP_SHR_R_UI32,
+  OP_ST_8,
+  OP_ST_16,
+  OP_ST_32,
+  OP_ST_R_8,
+  OP_ST_R_16,
+  OP_ST_R_32,
+  OP_SUB_I8,
+  OP_SUB_I16,
+  OP_SUB_I32,
+  OP_SUB_F32,
+  OP_SUB_R_I8,
+  OP_SUB_R_I16,
+  OP_SUB_R_I32,
+  OP_SUB_R_F32,
+  OP_TRAP,
+  OP_XOR_I8,
+  OP_XOR_I16,
+  OP_XOR_I32,
+
+  // the following are coded as 0xff, OP_xxx & 0xff
+  // the commented items are for a system with 64-bit addressing
+  //OP_ADD_EXPR_I64_R1 = 0x100,
+  //OP_ADD_EXPR_I64_R2,
+  //OP_ADD_EXPR_I64_R3,
+  //OP_ADD_EXPR_I64_R4,
+  //OP_ADD_EXPR_I64_R5,
+  OP_ADD_I64 = 0x100,
+  OP_ADD_I128,
+  OP_ADD_F64,
+  OP_ADD_F128,
+  OP_AND_I64,
+  OP_AND_I128,
+  //OP_CALL_EXPR_I64,
+  OP_CVT_SI8_I64,
+  OP_CVT_SI8_I128,
+  OP_CVT_SI8_F64,
+  OP_CVT_SI8_F128,
+  OP_CVT_SI16_I64,
+  OP_CVT_SI16_I128,
+  OP_CVT_SI16_F64,
+  OP_CVT_SI16_F128,
+  OP_CVT_SI32_I64,
+  OP_CVT_SI32_I128,
+  OP_CVT_SI32_F64,
+  OP_CVT_SI32_F128,
+  OP_CVT_SI64_I128,
+  OP_CVT_SI64_F32,
+  OP_CVT_SI64_F64,
+  OP_CVT_SI64_F128,
+  OP_CVT_SI128_F32,
+  OP_CVT_SI128_F64,
+  OP_CVT_SI128_F128,
+  OP_CVT_UI8_I64,
+  OP_CVT_UI8_I128,
+  OP_CVT_UI8_F64,
+  OP_CVT_UI8_F128,
+  OP_CVT_UI16_I64,
+  OP_CVT_UI16_I128,
+  OP_CVT_UI16_F64,
+  OP_CVT_UI16_F128,
+  OP_CVT_UI32_I64,
+  OP_CVT_UI32_I128,
+  OP_CVT_UI32_F64,
+  OP_CVT_UI32_F128,
+  OP_CVT_UI64_I128,
+  OP_CVT_UI64_F32,
+  OP_CVT_UI64_F64,
+  OP_CVT_UI64_F128,
+  OP_CVT_UI128_F32,
+  OP_CVT_UI128_F64,
+  OP_CVT_UI128_F128,
+  OP_CVT_F32_F64,
+  OP_CVT_F32_F128,
+  OP_CVT_F32_I64,
+  OP_CVT_F32_I128,
+  OP_CVT_F64_F32,
+  OP_CVT_F64_F128,
+  OP_CVT_F64_I8,
+  OP_CVT_F64_I16,
+  OP_CVT_F64_I32,
+  OP_CVT_F64_I64,
+  OP_CVT_F64_I128,
+  OP_CVT_F128_F32,
+  OP_CVT_F128_F64,
+  OP_CVT_F128_I8,
+  OP_CVT_F128_I16,
+  OP_CVT_F128_I32,
+  OP_CVT_F128_I64,
+  OP_CVT_F128_I128,
+  OP_DIV_SI64,
+  OP_DIV_SI128,
+  OP_DIV_UI64,
+  OP_DIV_UI128,
+  OP_DIV_F64,
+  OP_DIV_F128,
+  OP_DIV_R_SI64,
+  OP_DIV_R_SI128,
+  OP_DIV_R_UI64,
+  OP_DIV_R_UI128,
+  OP_DIV_R_F64,
+  OP_DIV_R_F128,
+  OP_EQ_I64,
+  OP_EQ_I128,
+  OP_EQ_F64,
+  OP_EQ_F128,
+  OP_GE_SI64,
+  OP_GE_SI128,
+  OP_GE_UI64,
+  OP_GE_UI128,
+  OP_GE_F64,
+  OP_GE_F128,
+  OP_GT_SI64,
+  OP_GT_SI128,
+  OP_GT_UI64,
+  OP_GT_UI128,
+  OP_GT_F64,
+  OP_GT_F128,
+  OP_IMM_EXPR_64,
+  OP_IMM_EXPR_128,
+  //OP_JMPF_I8_EXPR_I64,
+  //OP_JMPF_I16_EXPR_I64,
+  //OP_JMPF_I32_EXPR_I64,
+  OP_JMPF_I64_EXPR_I8,
+  OP_JMPF_I64_EXPR_I16,
+  OP_JMPF_I64_EXPR_I32,
+  //OP_JMPF_I64_EXPR_I64,
+  OP_JMPF_I128_EXPR_I8,
+  OP_JMPF_I128_EXPR_I16,
+  OP_JMPF_I128_EXPR_I32,
+  //OP_JMPF_I128_EXPR_I64,
+  //OP_JMPF_F32_EXPR_I64,
+  OP_JMPF_F64_EXPR_I8,
+  OP_JMPF_F64_EXPR_I16,
+  OP_JMPF_F64_EXPR_I32,
+  //OP_JMPF_F64_EXPR_I64,
+  OP_JMPF_F128_EXPR_I8,
+  OP_JMPF_F128_EXPR_I16,
+  OP_JMPF_F128_EXPR_I32,
+  //OP_JMPF_F128_EXPR_I64,
+  //OP_JMPF_R1_EXPR_I64,
+  //OP_JMPF_R2_EXPR_I64,
+  //OP_JMPF_R3_EXPR_I64,
+  //OP_JMPT_I8_EXPR_I64,
+  //OP_JMPT_I16_EXPR_I64,
+  //OP_JMPT_I32_EXPR_I64,
+  OP_JMPT_I64_EXPR_I8,
+  OP_JMPT_I64_EXPR_I16,
+  OP_JMPT_I64_EXPR_I32,
+  //OP_JMPT_I64_EXPR_I64,
+  OP_JMPT_I128_EXPR_I8,
+  OP_JMPT_I128_EXPR_I16,
+  OP_JMPT_I128_EXPR_I32,
+  //OP_JMPT_I128_EXPR_I64,
+  //OP_JMPT_F32_EXPR_I64,
+  OP_JMPT_F64_EXPR_I8,
+  OP_JMPT_F64_EXPR_I16,
+  OP_JMPT_F64_EXPR_I32,
+  //OP_JMPT_F64_EXPR_I64,
+  OP_JMPT_F128_EXPR_I8,
+  OP_JMPT_F128_EXPR_I16,
+  OP_JMPT_F128_EXPR_I32,
+  //OP_JMPT_F128_EXPR_I64,
+  //OP_JMPT_R1_EXPR_I64,
+  //OP_JMPT_R2_EXPR_I64,
+  //OP_JMPT_R3_EXPR_I64,
+  OP_LD_64,
+  OP_LD_128,
+  //OP_LEA_EXPR_I64_R1,
+  //OP_LEA_EXPR_I64_R2,
+  //OP_LEA_EXPR_I64_R3,
+  //OP_LEA_EXPR_I64_R4,
+  //OP_LEA_EXPR_I64_R5,
+  OP_LE_SI64,
+  OP_LE_SI128,
+  OP_LE_UI64,
+  OP_LE_UI128,
+  OP_LE_F64,
+  OP_LE_F128,
+  OP_LT_SI64,
+  OP_LT_SI128,
+  OP_LT_UI64,
+  OP_LT_UI128,
+  OP_LT_F64,
+  OP_LT_F128,
+  OP_MOD_SI64,
+  OP_MOD_SI128,
+  OP_MOD_UI64,
+  OP_MOD_UI128,
+  OP_MOD_R_SI64,
+  OP_MOD_R_SI128,
+  OP_MOD_R_UI64,
+  OP_MOD_R_UI128,
+  OP_MUL_I64,
+  OP_MUL_I128,
+  OP_MUL_F64,
+  OP_MUL_F128,
+  OP_NEG_I64,
+  OP_NEG_I128,
+  OP_NEG_F64,
+  OP_NEG_F128,
+  OP_NE_I64,
+  OP_NE_I128,
+  OP_NE_F64,
+  OP_NE_F128,
+  OP_NOT_I64,
+  OP_NOT_I128,
+  OP_OR_I64,
+  OP_OR_I128,
+  OP_POP_64,
+  OP_POP_128,
+  OP_PUSH_64,
+  OP_PUSH_128,
+  OP_SHL_I64,
+  OP_SHL_I128,
+  OP_SHL_R_I64,
+  OP_SHL_R_I128,
+  OP_SHR_SI64,
+  OP_SHR_SI128,
+  OP_SHR_UI64,
+  OP_SHR_UI128,
+  OP_SHR_R_SI64,
+  OP_SHR_R_SI128,
+  OP_SHR_R_UI64,
+  OP_SHR_R_UI128,
+  OP_ST_64,
+  OP_ST_128,
+  OP_ST_R_64,
+  OP_ST_R_128,
+  OP_SUB_I64,
+  OP_SUB_I128,
+  OP_SUB_F64,
+  OP_SUB_F128,
+  OP_SUB_R_I64,
+  OP_SUB_R_I128,
+  OP_SUB_R_F64,
+  OP_SUB_R_F128,
+  OP_XOR_I64,
+  OP_XOR_I128,
+};
+
+int main(void) {
+  printf("OP_NOP = 0x%x\n", OP_NOP);
+  printf("OP_ADD_EXPR_I8_R1 = 0x%x\n", OP_ADD_EXPR_I8_R1);
+  printf("OP_ADD_EXPR_I8_R2 = 0x%x\n", OP_ADD_EXPR_I8_R2);
+  printf("OP_ADD_EXPR_I8_R3 = 0x%x\n", OP_ADD_EXPR_I8_R3);
+  printf("OP_ADD_EXPR_I8_R4 = 0x%x\n", OP_ADD_EXPR_I8_R4);
+  printf("OP_ADD_EXPR_I8_R5 = 0x%x\n", OP_ADD_EXPR_I8_R5);
+  printf("OP_ADD_EXPR_I16_R1 = 0x%x\n", OP_ADD_EXPR_I16_R1);
+  printf("OP_ADD_EXPR_I16_R2 = 0x%x\n", OP_ADD_EXPR_I16_R2);
+  printf("OP_ADD_EXPR_I16_R3 = 0x%x\n", OP_ADD_EXPR_I16_R3);
+  printf("OP_ADD_EXPR_I16_R4 = 0x%x\n", OP_ADD_EXPR_I16_R4);
+  printf("OP_ADD_EXPR_I16_R5 = 0x%x\n", OP_ADD_EXPR_I16_R5);
+  printf("OP_ADD_EXPR_I32_R1 = 0x%x\n", OP_ADD_EXPR_I32_R1);
+  printf("OP_ADD_EXPR_I32_R2 = 0x%x\n", OP_ADD_EXPR_I32_R2);
+  printf("OP_ADD_EXPR_I32_R3 = 0x%x\n", OP_ADD_EXPR_I32_R3);
+  printf("OP_ADD_EXPR_I32_R4 = 0x%x\n", OP_ADD_EXPR_I32_R4);
+  printf("OP_ADD_EXPR_I32_R5 = 0x%x\n", OP_ADD_EXPR_I32_R5);
+  printf("OP_ADD_I8 = 0x%x\n", OP_ADD_I8);
+  printf("OP_ADD_I16 = 0x%x\n", OP_ADD_I16);
+  printf("OP_ADD_I32 = 0x%x\n", OP_ADD_I32);
+  printf("OP_ADD_F32 = 0x%x\n", OP_ADD_F32);
+  printf("OP_AND_I8 = 0x%x\n", OP_AND_I8);
+  printf("OP_AND_I16 = 0x%x\n", OP_AND_I16);
+  printf("OP_AND_I32 = 0x%x\n", OP_AND_I32);
+  printf("OP_CALL = 0x%x\n", OP_CALL);
+  printf("OP_CALL_EXPR_I8 = 0x%x\n", OP_CALL_EXPR_I8);
+  printf("OP_CALL_EXPR_I16 = 0x%x\n", OP_CALL_EXPR_I16);
+  printf("OP_CALL_EXPR_I32 = 0x%x\n", OP_CALL_EXPR_I32);
+  printf("OP_CVT_SI8_I16 = 0x%x\n", OP_CVT_SI8_I16);
+  printf("OP_CVT_SI8_I32 = 0x%x\n", OP_CVT_SI8_I32);
+  printf("OP_CVT_SI8_F32 = 0x%x\n", OP_CVT_SI8_F32);
+  printf("OP_CVT_SI16_I32 = 0x%x\n", OP_CVT_SI16_I32);
+  printf("OP_CVT_SI16_F32 = 0x%x\n", OP_CVT_SI16_F32);
+  printf("OP_CVT_SI32_F32 = 0x%x\n", OP_CVT_SI32_F32);
+  printf("OP_CVT_UI8_I16 = 0x%x\n", OP_CVT_UI8_I16);
+  printf("OP_CVT_UI8_I32 = 0x%x\n", OP_CVT_UI8_I32);
+  printf("OP_CVT_UI8_F32 = 0x%x\n", OP_CVT_UI8_F32);
+  printf("OP_CVT_UI16_I32 = 0x%x\n", OP_CVT_UI16_I32);
+  printf("OP_CVT_UI16_F32 = 0x%x\n", OP_CVT_UI16_F32);
+  printf("OP_CVT_UI32_F32 = 0x%x\n", OP_CVT_UI32_F32);
+  printf("OP_CVT_F32_I8 = 0x%x\n", OP_CVT_F32_I8);
+  printf("OP_CVT_F32_I16 = 0x%x\n", OP_CVT_F32_I16);
+  printf("OP_CVT_F32_I32 = 0x%x\n", OP_CVT_F32_I32);
+  printf("OP_DIV_SI8 = 0x%x\n", OP_DIV_SI8);
+  printf("OP_DIV_SI16 = 0x%x\n", OP_DIV_SI16);
+  printf("OP_DIV_SI32 = 0x%x\n", OP_DIV_SI32);
+  printf("OP_DIV_UI8 = 0x%x\n", OP_DIV_UI8);
+  printf("OP_DIV_UI16 = 0x%x\n", OP_DIV_UI16);
+  printf("OP_DIV_UI32 = 0x%x\n", OP_DIV_UI32);
+  printf("OP_DIV_F32 = 0x%x\n", OP_DIV_F32);
+  printf("OP_DIV_R_SI8 = 0x%x\n", OP_DIV_R_SI8);
+  printf("OP_DIV_R_SI16 = 0x%x\n", OP_DIV_R_SI16);
+  printf("OP_DIV_R_SI32 = 0x%x\n", OP_DIV_R_SI32);
+  printf("OP_DIV_R_UI8 = 0x%x\n", OP_DIV_R_UI8);
+  printf("OP_DIV_R_UI16 = 0x%x\n", OP_DIV_R_UI16);
+  printf("OP_DIV_R_UI32 = 0x%x\n", OP_DIV_R_UI32);
+  printf("OP_DIV_R_F32 = 0x%x\n", OP_DIV_R_F32);
+  printf("OP_EQ_I8 = 0x%x\n", OP_EQ_I8);
+  printf("OP_EQ_I16 = 0x%x\n", OP_EQ_I16);
+  printf("OP_EQ_I32 = 0x%x\n", OP_EQ_I32);
+  printf("OP_EQ_F32 = 0x%x\n", OP_EQ_F32);
+  printf("OP_GE_SI8 = 0x%x\n", OP_GE_SI8);
+  printf("OP_GE_SI16 = 0x%x\n", OP_GE_SI16);
+  printf("OP_GE_SI32 = 0x%x\n", OP_GE_SI32);
+  printf("OP_GE_UI8 = 0x%x\n", OP_GE_UI8);
+  printf("OP_GE_UI16 = 0x%x\n", OP_GE_UI16);
+  printf("OP_GE_UI32 = 0x%x\n", OP_GE_UI32);
+  printf("OP_GE_F32 = 0x%x\n", OP_GE_F32);
+  printf("OP_GT_SI8 = 0x%x\n", OP_GT_SI8);
+  printf("OP_GT_SI16 = 0x%x\n", OP_GT_SI16);
+  printf("OP_GT_SI32 = 0x%x\n", OP_GT_SI32);
+  printf("OP_GT_UI8 = 0x%x\n", OP_GT_UI8);
+  printf("OP_GT_UI16 = 0x%x\n", OP_GT_UI16);
+  printf("OP_GT_UI32 = 0x%x\n", OP_GT_UI32);
+  printf("OP_GT_F32 = 0x%x\n", OP_GT_F32);
+  printf("OP_IMM_EXPR_8 = 0x%x\n", OP_IMM_EXPR_8);
+  printf("OP_IMM_EXPR_16 = 0x%x\n", OP_IMM_EXPR_16);
+  printf("OP_IMM_EXPR_32 = 0x%x\n", OP_IMM_EXPR_32);
+  printf("OP_JMPF_I8_EXPR_I8 = 0x%x\n", OP_JMPF_I8_EXPR_I8);
+  printf("OP_JMPF_I8_EXPR_I16 = 0x%x\n", OP_JMPF_I8_EXPR_I16);
+  printf("OP_JMPF_I8_EXPR_I32 = 0x%x\n", OP_JMPF_I8_EXPR_I32);
+  printf("OP_JMPF_I16_EXPR_I8 = 0x%x\n", OP_JMPF_I16_EXPR_I8);
+  printf("OP_JMPF_I16_EXPR_I16 = 0x%x\n", OP_JMPF_I16_EXPR_I16);
+  printf("OP_JMPF_I16_EXPR_I32 = 0x%x\n", OP_JMPF_I16_EXPR_I32);
+  printf("OP_JMPF_I32_EXPR_I8 = 0x%x\n", OP_JMPF_I32_EXPR_I8);
+  printf("OP_JMPF_I32_EXPR_I16 = 0x%x\n", OP_JMPF_I32_EXPR_I16);
+  printf("OP_JMPF_I32_EXPR_I32 = 0x%x\n", OP_JMPF_I32_EXPR_I32);
+  printf("OP_JMPF_F32_EXPR_I8 = 0x%x\n", OP_JMPF_F32_EXPR_I8);
+  printf("OP_JMPF_F32_EXPR_I16 = 0x%x\n", OP_JMPF_F32_EXPR_I16);
+  printf("OP_JMPF_F32_EXPR_I32 = 0x%x\n", OP_JMPF_F32_EXPR_I32);
+  printf("OP_JMPF_R1_EXPR_I8 = 0x%x\n", OP_JMPF_R1_EXPR_I8);
+  printf("OP_JMPF_R1_EXPR_I16 = 0x%x\n", OP_JMPF_R1_EXPR_I16);
+  printf("OP_JMPF_R1_EXPR_I32 = 0x%x\n", OP_JMPF_R1_EXPR_I32);
+  printf("OP_JMPF_R2_EXPR_I8 = 0x%x\n", OP_JMPF_R2_EXPR_I8);
+  printf("OP_JMPF_R2_EXPR_I16 = 0x%x\n", OP_JMPF_R2_EXPR_I16);
+  printf("OP_JMPF_R2_EXPR_I32 = 0x%x\n", OP_JMPF_R2_EXPR_I32);
+  printf("OP_JMPF_R3_EXPR_I8 = 0x%x\n", OP_JMPF_R3_EXPR_I8);
+  printf("OP_JMPF_R3_EXPR_I16 = 0x%x\n", OP_JMPF_R3_EXPR_I16);
+  printf("OP_JMPF_R3_EXPR_I32 = 0x%x\n", OP_JMPF_R3_EXPR_I32);
+  printf("OP_JMPT_I8_EXPR_I8 = 0x%x\n", OP_JMPT_I8_EXPR_I8);
+  printf("OP_JMPT_I8_EXPR_I16 = 0x%x\n", OP_JMPT_I8_EXPR_I16);
+  printf("OP_JMPT_I8_EXPR_I32 = 0x%x\n", OP_JMPT_I8_EXPR_I32);
+  printf("OP_JMPT_I16_EXPR_I8 = 0x%x\n", OP_JMPT_I16_EXPR_I8);
+  printf("OP_JMPT_I16_EXPR_I16 = 0x%x\n", OP_JMPT_I16_EXPR_I16);
+  printf("OP_JMPT_I16_EXPR_I32 = 0x%x\n", OP_JMPT_I16_EXPR_I32);
+  printf("OP_JMPT_I32_EXPR_I8 = 0x%x\n", OP_JMPT_I32_EXPR_I8);
+  printf("OP_JMPT_I32_EXPR_I16 = 0x%x\n", OP_JMPT_I32_EXPR_I16);
+  printf("OP_JMPT_I32_EXPR_I32 = 0x%x\n", OP_JMPT_I32_EXPR_I32);
+  printf("OP_JMPT_F32_EXPR_I8 = 0x%x\n", OP_JMPT_F32_EXPR_I8);
+  printf("OP_JMPT_F32_EXPR_I16 = 0x%x\n", OP_JMPT_F32_EXPR_I16);
+  printf("OP_JMPT_F32_EXPR_I32 = 0x%x\n", OP_JMPT_F32_EXPR_I32);
+  printf("OP_JMPT_R1_EXPR_I8 = 0x%x\n", OP_JMPT_R1_EXPR_I8);
+  printf("OP_JMPT_R1_EXPR_I16 = 0x%x\n", OP_JMPT_R1_EXPR_I16);
+  printf("OP_JMPT_R1_EXPR_I32 = 0x%x\n", OP_JMPT_R1_EXPR_I32);
+  printf("OP_JMPT_R2_EXPR_I8 = 0x%x\n", OP_JMPT_R2_EXPR_I8);
+  printf("OP_JMPT_R2_EXPR_I16 = 0x%x\n", OP_JMPT_R2_EXPR_I16);
+  printf("OP_JMPT_R2_EXPR_I32 = 0x%x\n", OP_JMPT_R2_EXPR_I32);
+  printf("OP_JMPT_R3_EXPR_I8 = 0x%x\n", OP_JMPT_R3_EXPR_I8);
+  printf("OP_JMPT_R3_EXPR_I16 = 0x%x\n", OP_JMPT_R3_EXPR_I16);
+  printf("OP_JMPT_R3_EXPR_I32 = 0x%x\n", OP_JMPT_R3_EXPR_I32);
+  printf("OP_LD_8 = 0x%x\n", OP_LD_8);
+  printf("OP_LD_16 = 0x%x\n", OP_LD_16);
+  printf("OP_LD_32 = 0x%x\n", OP_LD_32);
+  printf("OP_LEA_EXPR_I8_R1 = 0x%x\n", OP_LEA_EXPR_I8_R1);
+  printf("OP_LEA_EXPR_I8_R2 = 0x%x\n", OP_LEA_EXPR_I8_R2);
+  printf("OP_LEA_EXPR_I8_R3 = 0x%x\n", OP_LEA_EXPR_I8_R3);
+  printf("OP_LEA_EXPR_I8_R4 = 0x%x\n", OP_LEA_EXPR_I8_R4);
+  printf("OP_LEA_EXPR_I8_R5 = 0x%x\n", OP_LEA_EXPR_I8_R5);
+  printf("OP_LEA_EXPR_I16_R1 = 0x%x\n", OP_LEA_EXPR_I16_R1);
+  printf("OP_LEA_EXPR_I16_R2 = 0x%x\n", OP_LEA_EXPR_I16_R2);
+  printf("OP_LEA_EXPR_I16_R3 = 0x%x\n", OP_LEA_EXPR_I16_R3);
+  printf("OP_LEA_EXPR_I16_R4 = 0x%x\n", OP_LEA_EXPR_I16_R4);
+  printf("OP_LEA_EXPR_I16_R5 = 0x%x\n", OP_LEA_EXPR_I16_R5);
+  printf("OP_LEA_EXPR_I32_R1 = 0x%x\n", OP_LEA_EXPR_I32_R1);
+  printf("OP_LEA_EXPR_I32_R2 = 0x%x\n", OP_LEA_EXPR_I32_R2);
+  printf("OP_LEA_EXPR_I32_R3 = 0x%x\n", OP_LEA_EXPR_I32_R3);
+  printf("OP_LEA_EXPR_I32_R4 = 0x%x\n", OP_LEA_EXPR_I32_R4);
+  printf("OP_LEA_EXPR_I32_R5 = 0x%x\n", OP_LEA_EXPR_I32_R5);
+  printf("OP_LE_SI8 = 0x%x\n", OP_LE_SI8);
+  printf("OP_LE_SI16 = 0x%x\n", OP_LE_SI16);
+  printf("OP_LE_SI32 = 0x%x\n", OP_LE_SI32);
+  printf("OP_LE_UI8 = 0x%x\n", OP_LE_UI8);
+  printf("OP_LE_UI16 = 0x%x\n", OP_LE_UI16);
+  printf("OP_LE_UI32 = 0x%x\n", OP_LE_UI32);
+  printf("OP_LE_F32 = 0x%x\n", OP_LE_F32);
+  printf("OP_LT_SI8 = 0x%x\n", OP_LT_SI8);
+  printf("OP_LT_SI16 = 0x%x\n", OP_LT_SI16);
+  printf("OP_LT_SI32 = 0x%x\n", OP_LT_SI32);
+  printf("OP_LT_UI8 = 0x%x\n", OP_LT_UI8);
+  printf("OP_LT_UI16 = 0x%x\n", OP_LT_UI16);
+  printf("OP_LT_UI32 = 0x%x\n", OP_LT_UI32);
+  printf("OP_LT_F32 = 0x%x\n", OP_LT_F32);
+  printf("OP_MOD_SI8 = 0x%x\n", OP_MOD_SI8);
+  printf("OP_MOD_SI16 = 0x%x\n", OP_MOD_SI16);
+  printf("OP_MOD_SI32 = 0x%x\n", OP_MOD_SI32);
+  printf("OP_MOD_UI8 = 0x%x\n", OP_MOD_UI8);
+  printf("OP_MOD_UI16 = 0x%x\n", OP_MOD_UI16);
+  printf("OP_MOD_UI32 = 0x%x\n", OP_MOD_UI32);
+  printf("OP_MOD_R_SI8 = 0x%x\n", OP_MOD_R_SI8);
+  printf("OP_MOD_R_SI16 = 0x%x\n", OP_MOD_R_SI16);
+  printf("OP_MOD_R_SI32 = 0x%x\n", OP_MOD_R_SI32);
+  printf("OP_MOD_R_UI8 = 0x%x\n", OP_MOD_R_UI8);
+  printf("OP_MOD_R_UI16 = 0x%x\n", OP_MOD_R_UI16);
+  printf("OP_MOD_R_UI32 = 0x%x\n", OP_MOD_R_UI32);
+  printf("OP_MOV_R0_R1 = 0x%x\n", OP_MOV_R0_R1);
+  printf("OP_MOV_R0_R2 = 0x%x\n", OP_MOV_R0_R2);
+  printf("OP_MOV_R0_R3 = 0x%x\n", OP_MOV_R0_R3);
+  printf("OP_MOV_R0_R4 = 0x%x\n", OP_MOV_R0_R4);
+  printf("OP_MOV_R0_R5 = 0x%x\n", OP_MOV_R0_R5);
+  printf("OP_MOV_R1_R0 = 0x%x\n", OP_MOV_R1_R0);
+  printf("OP_MOV_R2_R0 = 0x%x\n", OP_MOV_R2_R0);
+  printf("OP_MOV_R3_R0 = 0x%x\n", OP_MOV_R3_R0);
+  printf("OP_MOV_R4_R0 = 0x%x\n", OP_MOV_R4_R0);
+  printf("OP_MOV_R5_R0 = 0x%x\n", OP_MOV_R5_R0);
+  printf("OP_MUL_I8 = 0x%x\n", OP_MUL_I8);
+  printf("OP_MUL_I16 = 0x%x\n", OP_MUL_I16);
+  printf("OP_MUL_I32 = 0x%x\n", OP_MUL_I32);
+  printf("OP_MUL_F32 = 0x%x\n", OP_MUL_F32);
+  printf("OP_NEG_I8 = 0x%x\n", OP_NEG_I8);
+  printf("OP_NEG_I16 = 0x%x\n", OP_NEG_I16);
+  printf("OP_NEG_I32 = 0x%x\n", OP_NEG_I32);
+  printf("OP_NEG_F32 = 0x%x\n", OP_NEG_F32);
+  printf("OP_NE_I8 = 0x%x\n", OP_NE_I8);
+  printf("OP_NE_I16 = 0x%x\n", OP_NE_I16);
+  printf("OP_NE_I32 = 0x%x\n", OP_NE_I32);
+  printf("OP_NE_F32 = 0x%x\n", OP_NE_F32);
+  printf("OP_NOT_I8 = 0x%x\n", OP_NOT_I8);
+  printf("OP_NOT_I16 = 0x%x\n", OP_NOT_I16);
+  printf("OP_NOT_I32 = 0x%x\n", OP_NOT_I32);
+  printf("OP_OR_I8 = 0x%x\n", OP_OR_I8);
+  printf("OP_OR_I16 = 0x%x\n", OP_OR_I16);
+  printf("OP_OR_I32 = 0x%x\n", OP_OR_I32);
+  printf("OP_POP_8 = 0x%x\n", OP_POP_8);
+  printf("OP_POP_16 = 0x%x\n", OP_POP_16);
+  printf("OP_POP_32 = 0x%x\n", OP_POP_32);
+  printf("OP_POP_R1 = 0x%x\n", OP_POP_R1);
+  printf("OP_POP_R2 = 0x%x\n", OP_POP_R2);
+  printf("OP_POP_R3 = 0x%x\n", OP_POP_R3);
+  printf("OP_POP_R4 = 0x%x\n", OP_POP_R4);
+  printf("OP_POP_R5 = 0x%x\n", OP_POP_R5);
+  printf("OP_PUSH_8 = 0x%x\n", OP_PUSH_8);
+  printf("OP_PUSH_16 = 0x%x\n", OP_PUSH_16);
+  printf("OP_PUSH_32 = 0x%x\n", OP_PUSH_32);
+  printf("OP_PUSH_R1 = 0x%x\n", OP_PUSH_R1);
+  printf("OP_PUSH_R2 = 0x%x\n", OP_PUSH_R2);
+  printf("OP_PUSH_R3 = 0x%x\n", OP_PUSH_R3);
+  printf("OP_PUSH_R4 = 0x%x\n", OP_PUSH_R4);
+  printf("OP_PUSH_R5 = 0x%x\n", OP_PUSH_R5);
+  printf("OP_RET = 0x%x\n", OP_RET);
+  printf("OP_SHL_I8 = 0x%x\n", OP_SHL_I8);
+  printf("OP_SHL_I16 = 0x%x\n", OP_SHL_I16);
+  printf("OP_SHL_I32 = 0x%x\n", OP_SHL_I32);
+  printf("OP_SHL_R_I8 = 0x%x\n", OP_SHL_R_I8);
+  printf("OP_SHL_R_I16 = 0x%x\n", OP_SHL_R_I16);
+  printf("OP_SHL_R_I32 = 0x%x\n", OP_SHL_R_I32);
+  printf("OP_SHR_SI8 = 0x%x\n", OP_SHR_SI8);
+  printf("OP_SHR_SI16 = 0x%x\n", OP_SHR_SI16);
+  printf("OP_SHR_SI32 = 0x%x\n", OP_SHR_SI32);
+  printf("OP_SHR_UI8 = 0x%x\n", OP_SHR_UI8);
+  printf("OP_SHR_UI16 = 0x%x\n", OP_SHR_UI16);
+  printf("OP_SHR_UI32 = 0x%x\n", OP_SHR_UI32);
+  printf("OP_SHR_R_SI8 = 0x%x\n", OP_SHR_R_SI8);
+  printf("OP_SHR_R_SI16 = 0x%x\n", OP_SHR_R_SI16);
+  printf("OP_SHR_R_SI32 = 0x%x\n", OP_SHR_R_SI32);
+  printf("OP_SHR_R_UI8 = 0x%x\n", OP_SHR_R_UI8);
+  printf("OP_SHR_R_UI16 = 0x%x\n", OP_SHR_R_UI16);
+  printf("OP_SHR_R_UI32 = 0x%x\n", OP_SHR_R_UI32);
+  printf("OP_ST_8 = 0x%x\n", OP_ST_8);
+  printf("OP_ST_16 = 0x%x\n", OP_ST_16);
+  printf("OP_ST_32 = 0x%x\n", OP_ST_32);
+  printf("OP_ST_R_8 = 0x%x\n", OP_ST_R_8);
+  printf("OP_ST_R_16 = 0x%x\n", OP_ST_R_16);
+  printf("OP_ST_R_32 = 0x%x\n", OP_ST_R_32);
+  printf("OP_SUB_I8 = 0x%x\n", OP_SUB_I8);
+  printf("OP_SUB_I16 = 0x%x\n", OP_SUB_I16);
+  printf("OP_SUB_I32 = 0x%x\n", OP_SUB_I32);
+  printf("OP_SUB_F32 = 0x%x\n", OP_SUB_F32);
+  printf("OP_SUB_R_I8 = 0x%x\n", OP_SUB_R_I8);
+  printf("OP_SUB_R_I16 = 0x%x\n", OP_SUB_R_I16);
+  printf("OP_SUB_R_I32 = 0x%x\n", OP_SUB_R_I32);
+  printf("OP_SUB_R_F32 = 0x%x\n", OP_SUB_R_F32);
+  printf("OP_TRAP = 0x%x\n", OP_TRAP);
+  printf("OP_XOR_I8 = 0x%x\n", OP_XOR_I8);
+  printf("OP_XOR_I16 = 0x%x\n", OP_XOR_I16);
+  printf("OP_XOR_I32 = 0x%x\n", OP_XOR_I32);
+  //printf("OP_ADD_EXPR_I64_R1 = 0x%x\n", OP_ADD_EXPR_I64_R1);
+  //printf("OP_ADD_EXPR_I64_R2 = 0x%x\n", OP_ADD_EXPR_I64_R2);
+  //printf("OP_ADD_EXPR_I64_R3 = 0x%x\n", OP_ADD_EXPR_I64_R3);
+  //printf("OP_ADD_EXPR_I64_R4 = 0x%x\n", OP_ADD_EXPR_I64_R4);
+  //printf("OP_ADD_EXPR_I64_R5 = 0x%x\n", OP_ADD_EXPR_I64_R5);
+  printf("OP_ADD_I64 = 0x%x\n", OP_ADD_I64);
+  printf("OP_ADD_I128 = 0x%x\n", OP_ADD_I128);
+  printf("OP_ADD_F64 = 0x%x\n", OP_ADD_F64);
+  printf("OP_ADD_F128 = 0x%x\n", OP_ADD_F128);
+  printf("OP_AND_I64 = 0x%x\n", OP_AND_I64);
+  printf("OP_AND_I128 = 0x%x\n", OP_AND_I128);
+  //printf("OP_CALL_EXPR_I64 = 0x%x\n", OP_CALL_EXPR_I64);
+  printf("OP_CVT_SI8_I64 = 0x%x\n", OP_CVT_SI8_I64);
+  printf("OP_CVT_SI8_I128 = 0x%x\n", OP_CVT_SI8_I128);
+  printf("OP_CVT_SI8_F64 = 0x%x\n", OP_CVT_SI8_F64);
+  printf("OP_CVT_SI8_F128 = 0x%x\n", OP_CVT_SI8_F128);
+  printf("OP_CVT_SI16_I64 = 0x%x\n", OP_CVT_SI16_I64);
+  printf("OP_CVT_SI16_I128 = 0x%x\n", OP_CVT_SI16_I128);
+  printf("OP_CVT_SI16_F64 = 0x%x\n", OP_CVT_SI16_F64);
+  printf("OP_CVT_SI16_F128 = 0x%x\n", OP_CVT_SI16_F128);
+  printf("OP_CVT_SI32_I64 = 0x%x\n", OP_CVT_SI32_I64);
+  printf("OP_CVT_SI32_I128 = 0x%x\n", OP_CVT_SI32_I128);
+  printf("OP_CVT_SI32_F64 = 0x%x\n", OP_CVT_SI32_F64);
+  printf("OP_CVT_SI32_F128 = 0x%x\n", OP_CVT_SI32_F128);
+  printf("OP_CVT_SI64_I128 = 0x%x\n", OP_CVT_SI64_I128);
+  printf("OP_CVT_SI64_F32 = 0x%x\n", OP_CVT_SI64_F32);
+  printf("OP_CVT_SI64_F64 = 0x%x\n", OP_CVT_SI64_F64);
+  printf("OP_CVT_SI64_F128 = 0x%x\n", OP_CVT_SI64_F128);
+  printf("OP_CVT_SI128_F32 = 0x%x\n", OP_CVT_SI128_F32);
+  printf("OP_CVT_SI128_F64 = 0x%x\n", OP_CVT_SI128_F64);
+  printf("OP_CVT_SI128_F128 = 0x%x\n", OP_CVT_SI128_F128);
+  printf("OP_CVT_UI8_I64 = 0x%x\n", OP_CVT_UI8_I64);
+  printf("OP_CVT_UI8_I128 = 0x%x\n", OP_CVT_UI8_I128);
+  printf("OP_CVT_UI8_F64 = 0x%x\n", OP_CVT_UI8_F64);
+  printf("OP_CVT_UI8_F128 = 0x%x\n", OP_CVT_UI8_F128);
+  printf("OP_CVT_UI16_I64 = 0x%x\n", OP_CVT_UI16_I64);
+  printf("OP_CVT_UI16_I128 = 0x%x\n", OP_CVT_UI16_I128);
+  printf("OP_CVT_UI16_F64 = 0x%x\n", OP_CVT_UI16_F64);
+  printf("OP_CVT_UI16_F128 = 0x%x\n", OP_CVT_UI16_F128);
+  printf("OP_CVT_UI32_I64 = 0x%x\n", OP_CVT_UI32_I64);
+  printf("OP_CVT_UI32_I128 = 0x%x\n", OP_CVT_UI32_I128);
+  printf("OP_CVT_UI32_F64 = 0x%x\n", OP_CVT_UI32_F64);
+  printf("OP_CVT_UI32_F128 = 0x%x\n", OP_CVT_UI32_F128);
+  printf("OP_CVT_UI64_I128 = 0x%x\n", OP_CVT_UI64_I128);
+  printf("OP_CVT_UI64_F32 = 0x%x\n", OP_CVT_UI64_F32);
+  printf("OP_CVT_UI64_F64 = 0x%x\n", OP_CVT_UI64_F64);
+  printf("OP_CVT_UI64_F128 = 0x%x\n", OP_CVT_UI64_F128);
+  printf("OP_CVT_UI128_F32 = 0x%x\n", OP_CVT_UI128_F32);
+  printf("OP_CVT_UI128_F64 = 0x%x\n", OP_CVT_UI128_F64);
+  printf("OP_CVT_UI128_F128 = 0x%x\n", OP_CVT_UI128_F128);
+  printf("OP_CVT_F32_F64 = 0x%x\n", OP_CVT_F32_F64);
+  printf("OP_CVT_F32_F128 = 0x%x\n", OP_CVT_F32_F128);
+  printf("OP_CVT_F32_I64 = 0x%x\n", OP_CVT_F32_I64);
+  printf("OP_CVT_F32_I128 = 0x%x\n", OP_CVT_F32_I128);
+  printf("OP_CVT_F64_F32 = 0x%x\n", OP_CVT_F64_F32);
+  printf("OP_CVT_F64_F128 = 0x%x\n", OP_CVT_F64_F128);
+  printf("OP_CVT_F64_I8 = 0x%x\n", OP_CVT_F64_I8);
+  printf("OP_CVT_F64_I16 = 0x%x\n", OP_CVT_F64_I16);
+  printf("OP_CVT_F64_I32 = 0x%x\n", OP_CVT_F64_I32);
+  printf("OP_CVT_F64_I64 = 0x%x\n", OP_CVT_F64_I64);
+  printf("OP_CVT_F64_I128 = 0x%x\n", OP_CVT_F64_I128);
+  printf("OP_CVT_F128_F32 = 0x%x\n", OP_CVT_F128_F32);
+  printf("OP_CVT_F128_F64 = 0x%x\n", OP_CVT_F128_F64);
+  printf("OP_CVT_F128_I8 = 0x%x\n", OP_CVT_F128_I8);
+  printf("OP_CVT_F128_I16 = 0x%x\n", OP_CVT_F128_I16);
+  printf("OP_CVT_F128_I32 = 0x%x\n", OP_CVT_F128_I32);
+  printf("OP_CVT_F128_I64 = 0x%x\n", OP_CVT_F128_I64);
+  printf("OP_CVT_F128_I128 = 0x%x\n", OP_CVT_F128_I128);
+  printf("OP_DIV_SI64 = 0x%x\n", OP_DIV_SI64);
+  printf("OP_DIV_SI128 = 0x%x\n", OP_DIV_SI128);
+  printf("OP_DIV_UI64 = 0x%x\n", OP_DIV_UI64);
+  printf("OP_DIV_UI128 = 0x%x\n", OP_DIV_UI128);
+  printf("OP_DIV_F64 = 0x%x\n", OP_DIV_F64);
+  printf("OP_DIV_F128 = 0x%x\n", OP_DIV_F128);
+  printf("OP_DIV_R_SI64 = 0x%x\n", OP_DIV_R_SI64);
+  printf("OP_DIV_R_SI128 = 0x%x\n", OP_DIV_R_SI128);
+  printf("OP_DIV_R_UI64 = 0x%x\n", OP_DIV_R_UI64);
+  printf("OP_DIV_R_UI128 = 0x%x\n", OP_DIV_R_UI128);
+  printf("OP_DIV_R_F64 = 0x%x\n", OP_DIV_R_F64);
+  printf("OP_DIV_R_F128 = 0x%x\n", OP_DIV_R_F128);
+  printf("OP_EQ_I64 = 0x%x\n", OP_EQ_I64);
+  printf("OP_EQ_I128 = 0x%x\n", OP_EQ_I128);
+  printf("OP_EQ_F64 = 0x%x\n", OP_EQ_F64);
+  printf("OP_EQ_F128 = 0x%x\n", OP_EQ_F128);
+  printf("OP_GE_SI64 = 0x%x\n", OP_GE_SI64);
+  printf("OP_GE_SI128 = 0x%x\n", OP_GE_SI128);
+  printf("OP_GE_UI64 = 0x%x\n", OP_GE_UI64);
+  printf("OP_GE_UI128 = 0x%x\n", OP_GE_UI128);
+  printf("OP_GE_F64 = 0x%x\n", OP_GE_F64);
+  printf("OP_GE_F128 = 0x%x\n", OP_GE_F128);
+  printf("OP_GT_SI64 = 0x%x\n", OP_GT_SI64);
+  printf("OP_GT_SI128 = 0x%x\n", OP_GT_SI128);
+  printf("OP_GT_UI64 = 0x%x\n", OP_GT_UI64);
+  printf("OP_GT_UI128 = 0x%x\n", OP_GT_UI128);
+  printf("OP_GT_F64 = 0x%x\n", OP_GT_F64);
+  printf("OP_GT_F128 = 0x%x\n", OP_GT_F128);
+  printf("OP_IMM_EXPR_64 = 0x%x\n", OP_IMM_EXPR_64);
+  printf("OP_IMM_EXPR_128 = 0x%x\n", OP_IMM_EXPR_128);
+  //printf("OP_JMPF_I8_EXPR_I64 = 0x%x\n", OP_JMPF_I8_EXPR_I64);
+  //printf("OP_JMPF_I16_EXPR_I64 = 0x%x\n", OP_JMPF_I16_EXPR_I64);
+  //printf("OP_JMPF_I32_EXPR_I64 = 0x%x\n", OP_JMPF_I32_EXPR_I64);
+  printf("OP_JMPF_I64_EXPR_I8 = 0x%x\n", OP_JMPF_I64_EXPR_I8);
+  printf("OP_JMPF_I64_EXPR_I16 = 0x%x\n", OP_JMPF_I64_EXPR_I16);
+  printf("OP_JMPF_I64_EXPR_I32 = 0x%x\n", OP_JMPF_I64_EXPR_I32);
+  //printf("OP_JMPF_I64_EXPR_I64 = 0x%x\n", OP_JMPF_I64_EXPR_I64);
+  printf("OP_JMPF_I128_EXPR_I8 = 0x%x\n", OP_JMPF_I128_EXPR_I8);
+  printf("OP_JMPF_I128_EXPR_I16 = 0x%x\n", OP_JMPF_I128_EXPR_I16);
+  printf("OP_JMPF_I128_EXPR_I32 = 0x%x\n", OP_JMPF_I128_EXPR_I32);
+  //printf("OP_JMPF_I128_EXPR_I64 = 0x%x\n", OP_JMPF_I128_EXPR_I64);
+  //printf("OP_JMPF_F32_EXPR_I64 = 0x%x\n", OP_JMPF_F32_EXPR_I64);
+  printf("OP_JMPF_F64_EXPR_I8 = 0x%x\n", OP_JMPF_F64_EXPR_I8);
+  printf("OP_JMPF_F64_EXPR_I16 = 0x%x\n", OP_JMPF_F64_EXPR_I16);
+  printf("OP_JMPF_F64_EXPR_I32 = 0x%x\n", OP_JMPF_F64_EXPR_I32);
+  //printf("OP_JMPF_F64_EXPR_I64 = 0x%x\n", OP_JMPF_F64_EXPR_I64);
+  printf("OP_JMPF_F128_EXPR_I8 = 0x%x\n", OP_JMPF_F128_EXPR_I8);
+  printf("OP_JMPF_F128_EXPR_I16 = 0x%x\n", OP_JMPF_F128_EXPR_I16);
+  printf("OP_JMPF_F128_EXPR_I32 = 0x%x\n", OP_JMPF_F128_EXPR_I32);
+  //printf("OP_JMPF_F128_EXPR_I64 = 0x%x\n", OP_JMPF_F128_EXPR_I64);
+  //printf("OP_JMPF_R1_EXPR_I64 = 0x%x\n", OP_JMPF_R1_EXPR_I64);
+  //printf("OP_JMPF_R2_EXPR_I64 = 0x%x\n", OP_JMPF_R2_EXPR_I64);
+  //printf("OP_JMPF_R3_EXPR_I64 = 0x%x\n", OP_JMPF_R3_EXPR_I64);
+  //printf("OP_JMPT_I8_EXPR_I64 = 0x%x\n", OP_JMPT_I8_EXPR_I64);
+  //printf("OP_JMPT_I16_EXPR_I64 = 0x%x\n", OP_JMPT_I16_EXPR_I64);
+  //printf("OP_JMPT_I32_EXPR_I64 = 0x%x\n", OP_JMPT_I32_EXPR_I64);
+  printf("OP_JMPT_I64_EXPR_I8 = 0x%x\n", OP_JMPT_I64_EXPR_I8);
+  printf("OP_JMPT_I64_EXPR_I16 = 0x%x\n", OP_JMPT_I64_EXPR_I16);
+  printf("OP_JMPT_I64_EXPR_I32 = 0x%x\n", OP_JMPT_I64_EXPR_I32);
+  //printf("OP_JMPT_I64_EXPR_I64 = 0x%x\n", OP_JMPT_I64_EXPR_I64);
+  printf("OP_JMPT_I128_EXPR_I8 = 0x%x\n", OP_JMPT_I128_EXPR_I8);
+  printf("OP_JMPT_I128_EXPR_I16 = 0x%x\n", OP_JMPT_I128_EXPR_I16);
+  printf("OP_JMPT_I128_EXPR_I32 = 0x%x\n", OP_JMPT_I128_EXPR_I32);
+  //printf("OP_JMPT_I128_EXPR_I64 = 0x%x\n", OP_JMPT_I128_EXPR_I64);
+  //printf("OP_JMPT_F32_EXPR_I64 = 0x%x\n", OP_JMPT_F32_EXPR_I64);
+  printf("OP_JMPT_F64_EXPR_I8 = 0x%x\n", OP_JMPT_F64_EXPR_I8);
+  printf("OP_JMPT_F64_EXPR_I16 = 0x%x\n", OP_JMPT_F64_EXPR_I16);
+  printf("OP_JMPT_F64_EXPR_I32 = 0x%x\n", OP_JMPT_F64_EXPR_I32);
+  //printf("OP_JMPT_F64_EXPR_I64 = 0x%x\n", OP_JMPT_F64_EXPR_I64);
+  printf("OP_JMPT_F128_EXPR_I8 = 0x%x\n", OP_JMPT_F128_EXPR_I8);
+  printf("OP_JMPT_F128_EXPR_I16 = 0x%x\n", OP_JMPT_F128_EXPR_I16);
+  printf("OP_JMPT_F128_EXPR_I32 = 0x%x\n", OP_JMPT_F128_EXPR_I32);
+  //printf("OP_JMPT_F128_EXPR_I64 = 0x%x\n", OP_JMPT_F128_EXPR_I64);
+  //printf("OP_JMPT_R1_EXPR_I64 = 0x%x\n", OP_JMPT_R1_EXPR_I64);
+  //printf("OP_JMPT_R2_EXPR_I64 = 0x%x\n", OP_JMPT_R2_EXPR_I64);
+  //printf("OP_JMPT_R3_EXPR_I64 = 0x%x\n", OP_JMPT_R3_EXPR_I64);
+  printf("OP_LD_64 = 0x%x\n", OP_LD_64);
+  printf("OP_LD_128 = 0x%x\n", OP_LD_128);
+  //printf("OP_LEA_EXPR_I64_R1 = 0x%x\n", OP_LEA_EXPR_I64_R1);
+  //printf("OP_LEA_EXPR_I64_R2 = 0x%x\n", OP_LEA_EXPR_I64_R2);
+  //printf("OP_LEA_EXPR_I64_R3 = 0x%x\n", OP_LEA_EXPR_I64_R3);
+  //printf("OP_LEA_EXPR_I64_R4 = 0x%x\n", OP_LEA_EXPR_I64_R4);
+  //printf("OP_LEA_EXPR_I64_R5 = 0x%x\n", OP_LEA_EXPR_I64_R5);
+  printf("OP_LE_SI64 = 0x%x\n", OP_LE_SI64);
+  printf("OP_LE_SI128 = 0x%x\n", OP_LE_SI128);
+  printf("OP_LE_UI64 = 0x%x\n", OP_LE_UI64);
+  printf("OP_LE_UI128 = 0x%x\n", OP_LE_UI128);
+  printf("OP_LE_F64 = 0x%x\n", OP_LE_F64);
+  printf("OP_LE_F128 = 0x%x\n", OP_LE_F128);
+  printf("OP_LT_SI64 = 0x%x\n", OP_LT_SI64);
+  printf("OP_LT_SI128 = 0x%x\n", OP_LT_SI128);
+  printf("OP_LT_UI64 = 0x%x\n", OP_LT_UI64);
+  printf("OP_LT_UI128 = 0x%x\n", OP_LT_UI128);
+  printf("OP_LT_F64 = 0x%x\n", OP_LT_F64);
+  printf("OP_LT_F128 = 0x%x\n", OP_LT_F128);
+  printf("OP_MOD_SI64 = 0x%x\n", OP_MOD_SI64);
+  printf("OP_MOD_SI128 = 0x%x\n", OP_MOD_SI128);
+  printf("OP_MOD_UI64 = 0x%x\n", OP_MOD_UI64);
+  printf("OP_MOD_UI128 = 0x%x\n", OP_MOD_UI128);
+  printf("OP_MOD_R_SI64 = 0x%x\n", OP_MOD_R_SI64);
+  printf("OP_MOD_R_SI128 = 0x%x\n", OP_MOD_R_SI128);
+  printf("OP_MOD_R_UI64 = 0x%x\n", OP_MOD_R_UI64);
+  printf("OP_MOD_R_UI128 = 0x%x\n", OP_MOD_R_UI128);
+  printf("OP_MUL_I64 = 0x%x\n", OP_MUL_I64);
+  printf("OP_MUL_I128 = 0x%x\n", OP_MUL_I128);
+  printf("OP_MUL_F64 = 0x%x\n", OP_MUL_F64);
+  printf("OP_MUL_F128 = 0x%x\n", OP_MUL_F128);
+  printf("OP_NEG_I64 = 0x%x\n", OP_NEG_I64);
+  printf("OP_NEG_I128 = 0x%x\n", OP_NEG_I128);
+  printf("OP_NEG_F64 = 0x%x\n", OP_NEG_F64);
+  printf("OP_NEG_F128 = 0x%x\n", OP_NEG_F128);
+  printf("OP_NE_I64 = 0x%x\n", OP_NE_I64);
+  printf("OP_NE_I128 = 0x%x\n", OP_NE_I128);
+  printf("OP_NE_F64 = 0x%x\n", OP_NE_F64);
+  printf("OP_NE_F128 = 0x%x\n", OP_NE_F128);
+  printf("OP_NOT_I64 = 0x%x\n", OP_NOT_I64);
+  printf("OP_NOT_I128 = 0x%x\n", OP_NOT_I128);
+  printf("OP_OR_I64 = 0x%x\n", OP_OR_I64);
+  printf("OP_OR_I128 = 0x%x\n", OP_OR_I128);
+  printf("OP_POP_64 = 0x%x\n", OP_POP_64);
+  printf("OP_POP_128 = 0x%x\n", OP_POP_128);
+  printf("OP_PUSH_64 = 0x%x\n", OP_PUSH_64);
+  printf("OP_PUSH_128 = 0x%x\n", OP_PUSH_128);
+  printf("OP_SHL_I64 = 0x%x\n", OP_SHL_I64);
+  printf("OP_SHL_I128 = 0x%x\n", OP_SHL_I128);
+  printf("OP_SHL_R_I64 = 0x%x\n", OP_SHL_R_I64);
+  printf("OP_SHL_R_I128 = 0x%x\n", OP_SHL_R_I128);
+  printf("OP_SHR_SI64 = 0x%x\n", OP_SHR_SI64);
+  printf("OP_SHR_SI128 = 0x%x\n", OP_SHR_SI128);
+  printf("OP_SHR_UI64 = 0x%x\n", OP_SHR_UI64);
+  printf("OP_SHR_UI128 = 0x%x\n", OP_SHR_UI128);
+  printf("OP_SHR_R_SI64 = 0x%x\n", OP_SHR_R_SI64);
+  printf("OP_SHR_R_SI128 = 0x%x\n", OP_SHR_R_SI128);
+  printf("OP_SHR_R_UI64 = 0x%x\n", OP_SHR_R_UI64);
+  printf("OP_SHR_R_UI128 = 0x%x\n", OP_SHR_R_UI128);
+  printf("OP_ST_64 = 0x%x\n", OP_ST_64);
+  printf("OP_ST_128 = 0x%x\n", OP_ST_128);
+  printf("OP_ST_R_64 = 0x%x\n", OP_ST_R_64);
+  printf("OP_ST_R_128 = 0x%x\n", OP_ST_R_128);
+  printf("OP_SUB_I64 = 0x%x\n", OP_SUB_I64);
+  printf("OP_SUB_I128 = 0x%x\n", OP_SUB_I128);
+  printf("OP_SUB_F64 = 0x%x\n", OP_SUB_F64);
+  printf("OP_SUB_F128 = 0x%x\n", OP_SUB_F128);
+  printf("OP_SUB_R_I64 = 0x%x\n", OP_SUB_R_I64);
+  printf("OP_SUB_R_I128 = 0x%x\n", OP_SUB_R_I128);
+  printf("OP_SUB_R_F64 = 0x%x\n", OP_SUB_R_F64);
+  printf("OP_SUB_R_F128 = 0x%x\n", OP_SUB_R_F128);
+  printf("OP_XOR_I64 = 0x%x\n", OP_XOR_I64);
+  printf("OP_XOR_I128 = 0x%x\n", OP_XOR_I128);
+  return 0;
+}
diff --git a/test.asm b/test.asm
new file mode 100644 (file)
index 0000000..fb3cb71
--- /dev/null
+++ b/test.asm
@@ -0,0 +1,533 @@
+exit = -1
+getchar = -2
+putchar = -3
+
+main: ; stack alignment 0x10
+       ; printing test
+       imm hello_world,pcr32
+       call print_str,pcr32
+
+       imm 0x01234567,i32
+       call print_hex_i32,pcr32
+       call print_newline,pcr32
+
+       imm 0,i32
+       call print_dec_i32,pcr32
+       call print_newline,pcr32
+
+       imm 123456789,i32
+       call print_dec_i32,pcr32
+       call print_newline,pcr32
+
+       imm -123456789,i32
+       call print_dec_i32,pcr32
+       call print_newline,pcr32
+
+       imm 0,f32
+       call print_sci_f32,pcr32
+       call print_newline,pcr32
+
+       imm 1.23456789e19,f32
+       call print_sci_f32,pcr32
+       call print_newline,pcr32
+
+       imm -1.23456789e-19,f32
+       call print_sci_f32,pcr32
+       call print_newline,pcr32
+
+       imm 1.40129846e-45,f32
+       call print_sci_f32,pcr32
+       call print_newline,pcr32
+
+       ; square root calculation tests
+       ; the square root routine is C-style (takes argument on stack)
+       add -8,i32,sp
+       imm 2,f32
+       push 32
+       call sqrt_f32,pcr32
+       add 0xc,i32,sp
+       call print_sci_f32,pcr32
+       call print_newline,pcr32
+
+       add -8,i32,sp
+       imm 1000,f32
+       push 32
+       call sqrt_f32,pcr32
+       add 0xc,i32,sp
+       call print_sci_f32,pcr32
+       call print_newline,pcr32
+
+       ; done
+       imm 0,i32
+       push 32
+       call exit,pcr32
+
+hello_world:
+       .data 'h',i8
+       .data 'e',i8
+       .data 'l',i8
+       .data 'l',i8
+       .data 'o',i8
+       .data ',',i8
+       .data ' ',i8
+       .data 'w',i8
+       .data 'o',i8
+       .data 'r',i8
+       .data 'l',i8
+       .data 'd',i8
+       .data '\n',i8
+       .data 0,i8
+
+print_str:
+       mov r0,r2
+       ld 8
+       jmpf i8,print_str_done,pcr32
+print_str_loop:
+       cvt si8,i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+       add 1,i32,r2
+       mov r2,r0
+       ld 8
+       jmpt i8,print_str_loop,pcr32
+print_str_done:
+       ret
+
+print_newline:
+       imm 0xa,i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+       ret
+
+print_hex_i32:
+       push 32
+
+       push 32
+       imm 16,i8
+       shr ui32
+       call print_hex_i16,pcr32
+
+       pop 32
+       ; fallthru
+
+print_hex_i16:
+       push 16
+
+       push 16
+       imm 8,i8
+       shr ui16
+       call print_hex_i8,pcr32
+       add 2,i32,sp
+
+       pop 16
+       ; fallthru
+
+print_hex_i8:
+       push 8
+
+       push 8
+       imm 4,i8
+       shr ui8
+       call print_hex_nibble,pcr32
+       add 3,i32,sp
+
+       pop 8
+       ; fallthru
+
+print_hex_nibble:
+       push 8
+       imm 0xf,i8
+       and i8
+       cvt si8,i32
+
+       push 8
+       imm print_hex_table,pcr32
+       add i8
+       ld 8
+
+       cvt si8,i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       ret
+
+print_hex_table:
+       .data '0',i8
+       .data '1',i8
+       .data '2',i8
+       .data '3',i8
+       .data '4',i8
+       .data '5',i8
+       .data '6',i8
+       .data '7',i8
+       .data '8',i8
+       .data '9',i8
+       .data 'a',i8
+       .data 'b',i8
+       .data 'c',i8
+       .data 'd',i8
+       .data 'e',i8
+       .data 'f',i8
+
+print_dec_i32: ; stack alignment 8
+       push 32
+
+       push 32
+       imm 0,i32
+       lt si32
+       jmpf i8,print_dec_pos,pcr32
+
+       imm '-',i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       pop 32
+       neg i32
+       push 32
+
+print_dec_pos:
+       imm print_dec_buf_end,pcr32
+       mov r0,r2
+
+       pop 32
+print_dec_loop0:
+       push 32
+
+       push 32
+       imm 10,i32
+       mod ui32
+       push 8
+       imm '0',i8
+       add i8
+       push 8
+       add -1,i32,r2
+       mov r2,r0
+       st_r 8
+
+       imm 10,i32
+       div ui32
+       jmpt i32,print_dec_loop0,pcr32
+
+print_dec_loop1:
+       mov r2,r0
+       ld 8
+       cvt si8,i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       add 1,i32,r2
+       mov r2,r0
+       push 32
+       imm print_dec_buf_end,pcr32
+       lt ui32
+       jmpt i8,print_dec_loop1,pcr32
+
+       ret
+
+       .space 10 ; 1 << 31 == 2147483648
+print_dec_buf_end:
+
+print_sci_f32:
+       push 32
+
+       push 32
+       imm 0,f32
+       lt f32
+       jmpf i8,print_sci_pos,pcr32
+
+       imm '-',i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       pop 32
+       neg f32
+       push 32
+
+print_sci_pos:
+       ; r2 points to table of exponents
+       ; when dividing it down:
+       ; entry is struct with threshold value (> 1) then scaling value (< 1)
+       ; when multiplying it up:
+       ; entry is struct with scaling value (> 1) then threshold value (< 1)
+       imm print_sci_table,pcr32
+       mov r0,r2
+
+       ; if number is >= 1, exponent is positive and we'll divide it down
+       ; if number is < 1, exponent is negative and we'll multiply it up
+       pop 32
+       push 32
+
+       push 32
+       imm 1,f32
+       lt f32
+       jmpt i8,print_sci_multiply,pcr32
+
+       ; dividing it down case
+
+       ; r3 is shift register for exponent bits
+       imm 0,i32
+       mov r0,r3
+
+print_sci_loop0:
+       ; calculate next exponent bit
+       pop 32
+       push 32
+
+       push 32
+       mov r2,r0
+       ld 32
+       ge f32
+       push 8
+
+       ; shift exponent bit into r3
+       cvt si8,i32
+       push 32
+       mov r3,r0
+       push 32
+       imm 1,i8
+       shl i32
+       or i32
+       mov r0,r3
+       add 3,i32,sp
+
+       ; if exponent bit is 1, divide
+       pop 8
+       jmpf i8,print_sci_no_div,pcr32
+
+       lea 4,i32,r2
+       ld 32
+       mul f32
+       push 32
+
+print_sci_no_div:
+       add 8,i32,r2
+       mov r2,r0
+       push 32
+       imm print_sci_table_end,pcr32
+       lt ui32
+       jmpt i8,print_sci_loop0,pcr32
+
+       imm 1e8,f32 ; factor to shift left by 8 decimal places
+       jmp print_sci_normalized,pcr32
+
+print_sci_multiply:
+       ; multiplying it up case
+
+       ; r3 is shift register for exponent bits
+       ; we will build negative exponent directly, starting with all ones
+       imm -1,i32
+       mov r0,r3
+
+print_sci_loop1:
+       ; calculate next exponent bit
+       pop 32
+       push 32
+
+       push 32
+       lea 4,i32,r2
+       ld 32
+       ge f32
+       push 8
+
+       ; shift exponent bit into r3
+       cvt si8,i32
+       push 32
+       mov r3,r0
+       push 32
+       imm 1,i8
+       shl i32
+       or i32
+       mov r0,r3
+       add 3,i32,sp
+
+       ; if exponent bit is 0, multiply
+       pop 8
+       jmpt i8,print_sci_no_mul,pcr32
+
+       mov r2,r0
+       ld 32
+       mul f32
+       push 32
+
+print_sci_no_mul:
+       add 8,i32,r2
+       mov r2,r0
+       push 32
+       imm print_sci_table_end,pcr32
+       lt ui32
+       jmpt i8,print_sci_loop1,pcr32
+
+       ; at this point the number is still < 1, do final multiply by 10
+       ; we used "not exponent" rather than "neg exponent" for extra -1
+       imm 1e9,f32 ; 10 * factor to shift left by 8 decimal places
+
+print_sci_normalized:
+       ; convert mantissa to 9 digit integer with 8 decimal places
+       mul f32
+       push 32
+       imm .5,f32
+       add f32
+       cvt f32,i32
+       push 32
+
+       ; if mantissa is zero, zero out exponent as well
+       jmpt i32,print_sci_not_zero,pcr32
+
+       imm 0,i32
+       mov r0,r3
+       jmp print_sci_no_overflow,pcr32
+
+print_sci_not_zero:
+       ; check for 10-digit integer (rounding overflow)
+       push 32
+       imm 1000000000,i32
+       ge ui32
+       jmpf i8,print_sci_no_overflow,pcr32
+
+       ; move along one digit position and bump exponent
+       ; note: no rounding is needed, as low order digit must be 0
+       imm 10,i32
+       div ui32
+       push 32
+       add 1,i32,r3
+
+print_sci_no_overflow:
+       ; render all 9 digits backwards into buffer
+       imm print_sci_buf_end,pcr32
+       mov r0,r2
+
+print_sci_loop2:
+       pop 32
+       push 32
+
+       push 32
+       imm 10,i32
+       mod ui32
+       push 8
+       imm '0',i8
+       add i8
+       push 8
+       add -1,i32,r2
+       mov r2,r0
+       st_r 8
+
+       imm 10,i32
+       div ui32
+       push 32
+
+       mov r2,r0
+       push 32
+       imm print_sci_buf,pcr32
+       gt ui32
+       jmpt i8,print_sci_loop2,pcr32
+
+       pop 32 ; should be 0, discard
+
+       ; print first digit
+       mov r2,r0
+       ld 8
+       cvt si8,i32
+
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       add 1,i32,r2
+
+       ; print decimal point
+       imm '.',i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       ; print remaining digits
+print_sci_loop3:
+       mov r2,r0
+       ld 8
+       cvt si8,i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       add 1,i32,r2
+       mov r2,r0
+       push 32
+       imm print_sci_buf_end,pcr32
+       lt ui32
+       jmpt i8,print_sci_loop3,pcr32
+
+       ; print exponent part
+       imm 'e',i32
+       push 32
+       call putchar,pcr32
+       add 4,i32,sp
+
+       mov r3,r0
+       jmp print_dec_i32,pcr32
+
+print_sci_buf:
+       .space 9
+print_sci_buf_end:
+
+       .align 4
+print_sci_table:
+       .data 1e32,f32
+       .data 1e-32,f32
+       .data 1e16,f32
+       .data 1e-16,f32
+       .data 1e8,f32
+       .data 1e-8,f32
+       .data 1e4,f32
+       .data 1e-4,f32
+       .data 1e2,f32
+       .data 1e-2,f32
+       .data 1e1,f32
+       .data 1e-1,f32
+print_sci_table_end:
+
+; this routine is C-style
+; it is called with stack alignment 0x10 (but only needs 4)
+; it takes the argument on the stack at entry sp + 4
+; it preserves r2 register (r3 register is not used)
+sqrt_f32:
+       ; prologue
+       mov r2,r0
+       push 32
+
+       imm 8,i32 ; iterations
+       mov r0,r2
+
+       imm 1,f32 ; initial estimate
+       push 32
+sqrt_loop:
+       pop 32
+
+       push 32
+       push 32
+       lea 0x10,i32,sp
+       ld 32
+       div_r f32
+       add f32
+       push 32
+       imm .5,f32
+       mul f32
+
+       push 32
+       add -1,i32,r2
+       mov r2,r0
+       jmpt i32,sqrt_loop,pcr32
+
+       ; epilogue (return value is on stack)
+       lea 4,i32,sp
+       ld 32
+       mov r0,r2
+
+       pop 32
+       add 4,i32,sp
+       ret
diff --git a/vm_asm.l b/vm_asm.l
new file mode 100644 (file)
index 0000000..3339a1f
--- /dev/null
+++ b/vm_asm.l
@@ -0,0 +1,234 @@
+/* see lexical_grammar.txt, converted to lex style */
+NONDIGIT [_a-zA-Z]
+DIGIT [0-9]
+FRACTIONAL_CONSTANT (?:{DIGIT_SEQUENCE}|(?E{t_def.Text}""))\.{DIGIT_SEQUENCE}|{DIGIT_SEQUENCE}\.(?E{t_def.Text}"")
+EXPONENT_PART [eE](?:{SIGN}|(?E{t_def.Sign}"")){DIGIT_SEQUENCE}
+SIGN (?E{t_def.Sign}\+)|(?E{t_def.Sign, value = -1}-)
+DIGIT_SEQUENCE (?E{t_def.Text}{DIGIT}+)
+/* we have changed DECIMAL_CONSTANT and OCTAL_CONSTANT slightly, so that */
+/* "0" is recognized as decimal, hence OCTAL_CONSTANT is now >= 2 digits */
+DECIMAL_CONSTANT (?E{t_def.Text}0|{NONZERO_DIGIT}{DIGIT}*)
+OCTAL_CONSTANT 0(?E{t_def.Text}{OCTAL_DIGIT}+)
+HEXADECIMAL_CONSTANT 0[xX](?E{t_def.Text}{HEXADECIMAL_DIGIT}+)
+NONZERO_DIGIT [1-9]
+OCTAL_DIGIT [0-7]
+HEXADECIMAL_DIGIT [0-9a-fA-F]
+C_CHAR_SEQUENCE {C_CHAR}+
+/* we have changed C_CHAR to recognize multiple characters per Text element */
+C_CHAR (?E{t_def.Text}[^'\\\n]+)|{ESCAPE_SEQUENCE}
+ESCAPE_SEQUENCE {SIMPLE_ESCAPE_SEQUENCE}|{OCTAL_ESCAPE_SEQUENCE}|{HEXADECIMAL_ESCAPE_SEQUENCE}
+SIMPLE_ESCAPE_SEQUENCE (?E{t_def.SimpleEscapeSequence, value = 0x27}\\')|(?E{t_def.SimpleEscapeSequence, value = 0x22}\\\")|(?E{t_def.SimpleEscapeSequence, value = 0x3f}\\\?)|(?E{t_def.SimpleEscapeSequence, value = 0x5c}\\\\)|(?E{t_def.SimpleEscapeSequence, value = 0x07}\\a)|(?E{t_def.SimpleEscapeSequence, value = 0x08}\\b)|(?E{t_def.SimpleEscapeSequence, value = 0x0c}\\f)|(?E{t_def.SimpleEscapeSequence, value = 0x0a}\\n)|(?E{t_def.SimpleEscapeSequence, value = 0x0d}\\r)|(?E{t_def.SimpleEscapeSequence, value = 0x09}\\t)|(?E{t_def.SimpleEscapeSequence, value = 0x0b}\\v)
+OCTAL_ESCAPE_SEQUENCE (?E{t_def.IntegerEscapeSequence, base = 8}\\(?E{t_def.Text}{OCTAL_DIGIT}{1,3}))
+HEXADECIMAL_ESCAPE_SEQUENCE (?E{t_def.IntegerEscapeSequence, base = 16}\\x(?E{t_def.Text}{HEXADECIMAL_DIGIT}+))
+/* we have changed S_CHAR to recognize multiple characters per Text element */
+S_CHAR_SEQUENCE {S_CHAR}+
+S_CHAR (?E{t_def.Text}[^"\\\n]+)|{ESCAPE_SEQUENCE}
+
+%{
+  import t_def
+  import y_tab
+
+  def YY_USER_ACTION():
+    line = y_tab.yylloc.last_line
+    column = y_tab.yylloc.last_column
+    y_tab.yylloc.first_line = line
+    y_tab.yylloc.first_column = column
+    p0 = 0
+    p = 0
+    while p < len(yytext):
+      if yytext[p] == '\n':
+        line += 1
+        column = 1
+        p0 = p + 1
+      elif yytext[p] == '\t':
+        column += p - p0
+        column += 8 - ((column - 1) & 7)
+        p0 = p + 1
+      p += 1
+    column += p - p0
+    y_tab.yylloc.last_line = line
+    y_tab.yylloc.last_column = column
+%}
+
+%%
+
+;.*            # consume ;-comment
+
+.align                                 return y_tab.DOT_ALIGN
+.data                                  return y_tab.DOT_DATA
+.space                                 return y_tab.DOT_SPACE
+add                                    return y_tab.ADD
+and                                    return y_tab.AND
+call                                   return y_tab.CALL
+cvt                                    return y_tab.CVT
+div                                    return y_tab.DIV
+div_r                                  return y_tab.DIV_R
+eq                                     return y_tab.EQ
+expr                                   return y_tab.EXPR
+f32                                    return y_tab.F32
+f64                                    return y_tab.F64
+f128                                   return y_tab.F128
+ge                                     return y_tab.GE
+gt                                     return y_tab.GT
+i8                                     return y_tab.I8
+i16                                    return y_tab.I16
+i32                                    return y_tab.I32
+i64                                    return y_tab.I64
+i128                                   return y_tab.I128
+imm                                    return y_tab.IMM
+jmp                                    return y_tab.JMP
+jmpf                                   return y_tab.JMPF
+jmpt                                   return y_tab.JMPT
+ld                                     return y_tab.LD
+ld[ \t\v\f]+8/[ \t\n\v\f;]             return y_tab.LD_8
+ld[ \t\v\f]+16/[ \t\n\v\f;]            return y_tab.LD_16
+ld[ \t\v\f]+32/[ \t\n\v\f;]            return y_tab.LD_32
+ld[ \t\v\f]+64/[ \t\n\v\f;]            return y_tab.LD_64
+ld[ \t\v\f]+128/[ \t\n\v\f;]           return y_tab.LD_128
+lea                                    return y_tab.LEA
+le                                     return y_tab.LE
+lt                                     return y_tab.LT
+mod                                    return y_tab.MOD
+mod_r                                  return y_tab.MOD_R
+mov                                    return y_tab.MOV
+mul                                    return y_tab.MUL
+ne                                     return y_tab.NE
+neg                                    return y_tab.NEG
+nop                                    return y_tab.NOP
+not                                    return y_tab.NOT
+or                                     return y_tab.OR
+pc                                     return y_tab.R5
+pcr8                                   return y_tab.PCR8
+pcr16                                  return y_tab.PCR16
+pcr32                                  return y_tab.PCR32
+pcr64                                  return y_tab.PCR64
+pcr128                                 return y_tab.PCR128
+pop                                    return y_tab.POP
+pop[ \t\v\f]+8/[ \t\n\v\f;]            return y_tab.POP_8
+pop[ \t\v\f]+16/[ \t\n\v\f;]           return y_tab.POP_16
+pop[ \t\v\f]+32/[ \t\n\v\f;]           return y_tab.POP_32
+pop[ \t\v\f]+64/[ \t\n\v\f;]           return y_tab.POP_64
+pop[ \t\v\f]+128/[ \t\n\v\f;]          return y_tab.POP_128
+push                                   return y_tab.PUSH
+push[ \t\v\f]+8/[ \t\n\v\f;]           return y_tab.PUSH_8
+push[ \t\v\f]+16/[ \t\n\v\f;]          return y_tab.PUSH_16
+push[ \t\v\f]+32/[ \t\n\v\f;]          return y_tab.PUSH_32
+push[ \t\v\f]+64/[ \t\n\v\f;]          return y_tab.PUSH_64
+push[ \t\v\f]+128/[ \t\n\v\f;]         return y_tab.PUSH_128
+r0                                     return y_tab.R0
+r1                                     return y_tab.R1
+r2                                     return y_tab.R2
+r3                                     return y_tab.R3
+r4                                     return y_tab.R4
+r5                                     return y_tab.R5
+ret                                    return y_tab.RET
+shl                                    return y_tab.SHL
+shl_r                                  return y_tab.SHL_R
+shr                                    return y_tab.SHR
+shr_r                                  return y_tab.SHR_R
+si8                                    return y_tab.SI8
+si16                                   return y_tab.SI16
+si32                                   return y_tab.SI32
+si64                                   return y_tab.SI64
+si128                                  return y_tab.SI128
+sp                                     return y_tab.R4
+st                                     return y_tab.ST
+st[ \t\v\f]+8/[ \t\n\v\f;]             return y_tab.ST_8
+st[ \t\v\f]+16/[ \t\n\v\f;]            return y_tab.ST_16
+st[ \t\v\f]+32/[ \t\n\v\f;]            return y_tab.ST_32
+st[ \t\v\f]+64/[ \t\n\v\f;]            return y_tab.ST_64
+st[ \t\v\f]+128/[ \t\n\v\f;]           return y_tab.ST_128
+st_r                                   return y_tab.ST_R
+st_r[ \t\v\f]+8/[ \t\n\v\f;]           return y_tab.ST_R_8
+st_r[ \t\v\f]+16/[ \t\n\v\f;]          return y_tab.ST_R_16
+st_r[ \t\v\f]+32/[ \t\n\v\f;]          return y_tab.ST_R_32
+st_r[ \t\v\f]+64/[ \t\n\v\f;]          return y_tab.ST_R_64
+st_r[ \t\v\f]+128/[ \t\n\v\f;]         return y_tab.ST_R_128
+sub                                    return y_tab.SUB
+sub_r                                  return y_tab.SUB_R
+trap                                   return y_tab.TRAP
+ui8                                    return y_tab.UI8
+ui16                                   return y_tab.UI16
+ui32                                   return y_tab.UI32
+ui64                                   return y_tab.UI64
+ui128                                  return y_tab.UI128
+xor                                    return y_tab.XOR
+
+{NONDIGIT}(?:{NONDIGIT}|{DIGIT})* {
+  # don't apply any markup yet, done by parser later depending on context
+  return y_tab.IDENTIFIER
+}
+
+(?E{t_def.ExpressionFloatingConstant}{FRACTIONAL_CONSTANT}(?E{t_def.ExponentPart}{EXPONENT_PART}?)) |
+(?E{t_def.ExpressionFloatingConstant}{DIGIT_SEQUENCE}(?E{t_def.Text}"")(?E{t_def.ExponentPart}{EXPONENT_PART})) {
+  return y_tab.FLOATING_CONSTANT
+}
+
+(?E{t_def.ExpressionIntegerConstant, base = 10}{DECIMAL_CONSTANT}) |
+(?E{t_def.ExpressionIntegerConstant, base = 8}{OCTAL_CONSTANT}) |
+(?E{t_def.ExpressionIntegerConstant, base = 16}{HEXADECIMAL_CONSTANT}) {
+  return y_tab.INTEGER_CONSTANT
+}
+
+(?E{t_def.ExpressionCharacterConstant, wide = False}'{C_CHAR_SEQUENCE}') |
+(?E{t_def.ExpressionCharacterConstant, wide = True}L'{C_CHAR_SEQUENCE}') {
+  return y_tab.CHARACTER_CONSTANT
+}
+
+(?E{t_def.ExpressionStringLiteral, wide = False}\"{S_CHAR_SEQUENCE}\") |
+(?E{t_def.ExpressionStringLiteral, wide = True}L\"{S_CHAR_SEQUENCE}\") {
+  return y_tab.STRING_LITERAL
+}
+
+">>"           return y_tab.RIGHT_OP
+"<<"           return y_tab.LEFT_OP
+"&&"           return y_tab.AND_OP
+"||"           return y_tab.OR_OP
+"<="           return y_tab.LE_OP
+">="           return y_tab.GE_OP
+"=="           return y_tab.EQ_OP
+"!="           return y_tab.NE_OP
+","            return ord(',')
+":"            return ord(':')
+"="            return ord('=')
+"("            return ord('(')
+")"            return ord(')')
+"."            return ord('.')
+"&"            return ord('&')
+"!"            return ord('!')
+"~"            return ord('~')
+"-"            return ord('-')
+"+"            return ord('+')
+"*"            return ord('*')
+"/"            return ord('/')
+"%"            return ord('%')
+"<"            return ord('<')
+">"            return ord('>')
+"^"            return ord('^')
+"|"            return ord('|')
+"?"            return ord('?')
+
+\n             return y_tab.NEWLINE
+[ \t\v\f]+     # whitespace separates tokens
+. {
+  y_tab.yyerror(y_tab.yylloc, 'invalid character')
+}
+<<EOF>>                return 0
+
+%%
+
+def yywrap(): # called at end of input
+  return 1 # terminate now
+
+def yyerror(s):
+  sys.stdout.flush()
+  sys.stderr.write('*** {0:s}\n'.format(s))
+
+# intercept calls to yylex() for size literal processing after certain tokens
+def yylex_size_literal():
+  global last_token
+
+  # the actual size literal processing is done using REJECT() inside yylex()
+  token = lex_yy.yylex()
+  last_token = token
+  return token
diff --git a/vm_asm.py b/vm_asm.py
new file mode 100755 (executable)
index 0000000..2c0bdfd
--- /dev/null
+++ b/vm_asm.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2023 Nick Downing <nick@ndcode.org>
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
+import element
+import lex_yy
+import sys
+import t_def
+import y_tab
+
+EXIT_SUCCESS = 0
+EXIT_FAILURE = 1
+
+#print('yylex()', lex_yy.yylex())
+#print('yytext', f'"{lex_yy.yytext:s}"')
+#assert False
+
+if len(sys.argv) < 2:
+  print(f'usage: {sys.argv[0]:s} in_file.asm')
+  sys.exit(EXIT_FAILURE)
+in_file_asm = sys.argv[1]
+
+with open(in_file_asm) as fin:
+  lex_yy.yyin = fin
+  y_tab.in_file = in_file_asm
+  expression = y_tab.yyparse(t_def.InputFile)
+expression.post_process(t_def.Context())
+element.serialize(expression, 'a.xml', 'utf-8')
+expression = element.deserialize('a.xml', t_def.factory, 'utf-8')
+element.serialize(expression, 'b.xml', 'utf-8')
diff --git a/vm_asm.t b/vm_asm.t
new file mode 100644 (file)
index 0000000..5ebd919
--- /dev/null
+++ b/vm_asm.t
@@ -0,0 +1,564 @@
+/*
+ * Copyright (C) 2019 Nick Downing <nick@ndcode.org>
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+%{
+  import element
+  import gmpy2
+  import sys
+
+  gmpy2.get_context().precision = 128
+
+  OP_NOP = 0x0
+  OP_ADD_EXPR_I8_R1 = 0x1
+  OP_ADD_EXPR_I8_R2 = 0x2
+  OP_ADD_EXPR_I8_R3 = 0x3
+  OP_ADD_EXPR_I8_R4 = 0x4
+  OP_ADD_EXPR_I8_R5 = 0x5
+  OP_ADD_EXPR_I16_R1 = 0x6
+  OP_ADD_EXPR_I16_R2 = 0x7
+  OP_ADD_EXPR_I16_R3 = 0x8
+  OP_ADD_EXPR_I16_R4 = 0x9
+  OP_ADD_EXPR_I16_R5 = 0xa
+  OP_ADD_EXPR_I32_R1 = 0xb
+  OP_ADD_EXPR_I32_R2 = 0xc
+  OP_ADD_EXPR_I32_R3 = 0xd
+  OP_ADD_EXPR_I32_R4 = 0xe
+  OP_ADD_EXPR_I32_R5 = 0xf
+  OP_ADD_I8 = 0x10
+  OP_ADD_I16 = 0x11
+  OP_ADD_I32 = 0x12
+  OP_ADD_F32 = 0x13
+  OP_AND_I8 = 0x14
+  OP_AND_I16 = 0x15
+  OP_AND_I32 = 0x16
+  OP_CALL = 0x17
+  OP_CALL_EXPR_I8 = 0x18
+  OP_CALL_EXPR_I16 = 0x19
+  OP_CALL_EXPR_I32 = 0x1a
+  OP_CVT_SI8_I16 = 0x1b
+  OP_CVT_SI8_I32 = 0x1c
+  OP_CVT_SI8_F32 = 0x1d
+  OP_CVT_SI16_I32 = 0x1e
+  OP_CVT_SI16_F32 = 0x1f
+  OP_CVT_SI32_F32 = 0x20
+  OP_CVT_UI8_I16 = 0x21
+  OP_CVT_UI8_I32 = 0x22
+  OP_CVT_UI8_F32 = 0x23
+  OP_CVT_UI16_I32 = 0x24
+  OP_CVT_UI16_F32 = 0x25
+  OP_CVT_UI32_F32 = 0x26
+  OP_CVT_F32_I8 = 0x27
+  OP_CVT_F32_I16 = 0x28
+  OP_CVT_F32_I32 = 0x29
+  OP_DIV_SI8 = 0x2a
+  OP_DIV_SI16 = 0x2b
+  OP_DIV_SI32 = 0x2c
+  OP_DIV_UI8 = 0x2d
+  OP_DIV_UI16 = 0x2e
+  OP_DIV_UI32 = 0x2f
+  OP_DIV_F32 = 0x30
+  OP_DIV_R_SI8 = 0x31
+  OP_DIV_R_SI16 = 0x32
+  OP_DIV_R_SI32 = 0x33
+  OP_DIV_R_UI8 = 0x34
+  OP_DIV_R_UI16 = 0x35
+  OP_DIV_R_UI32 = 0x36
+  OP_DIV_R_F32 = 0x37
+  OP_EQ_I8 = 0x38
+  OP_EQ_I16 = 0x39
+  OP_EQ_I32 = 0x3a
+  OP_EQ_F32 = 0x3b
+  OP_GE_SI8 = 0x3c
+  OP_GE_SI16 = 0x3d
+  OP_GE_SI32 = 0x3e
+  OP_GE_UI8 = 0x3f
+  OP_GE_UI16 = 0x40
+  OP_GE_UI32 = 0x41
+  OP_GE_F32 = 0x42
+  OP_GT_SI8 = 0x43
+  OP_GT_SI16 = 0x44
+  OP_GT_SI32 = 0x45
+  OP_GT_UI8 = 0x46
+  OP_GT_UI16 = 0x47
+  OP_GT_UI32 = 0x48
+  OP_GT_F32 = 0x49
+  OP_IMM_EXPR_8 = 0x4a
+  OP_IMM_EXPR_16 = 0x4b
+  OP_IMM_EXPR_32 = 0x4c
+  OP_JMPF_I8_EXPR_I8 = 0x4d
+  OP_JMPF_I8_EXPR_I16 = 0x4e
+  OP_JMPF_I8_EXPR_I32 = 0x4f
+  OP_JMPF_I16_EXPR_I8 = 0x50
+  OP_JMPF_I16_EXPR_I16 = 0x51
+  OP_JMPF_I16_EXPR_I32 = 0x52
+  OP_JMPF_I32_EXPR_I8 = 0x53
+  OP_JMPF_I32_EXPR_I16 = 0x54
+  OP_JMPF_I32_EXPR_I32 = 0x55
+  OP_JMPF_F32_EXPR_I8 = 0x56
+  OP_JMPF_F32_EXPR_I16 = 0x57
+  OP_JMPF_F32_EXPR_I32 = 0x58
+  OP_JMPF_R1_EXPR_I8 = 0x59
+  OP_JMPF_R1_EXPR_I16 = 0x5a
+  OP_JMPF_R1_EXPR_I32 = 0x5b
+  OP_JMPF_R2_EXPR_I8 = 0x5c
+  OP_JMPF_R2_EXPR_I16 = 0x5d
+  OP_JMPF_R2_EXPR_I32 = 0x5e
+  OP_JMPF_R3_EXPR_I8 = 0x5f
+  OP_JMPF_R3_EXPR_I16 = 0x60
+  OP_JMPF_R3_EXPR_I32 = 0x61
+  OP_JMPT_I8_EXPR_I8 = 0x62
+  OP_JMPT_I8_EXPR_I16 = 0x63
+  OP_JMPT_I8_EXPR_I32 = 0x64
+  OP_JMPT_I16_EXPR_I8 = 0x65
+  OP_JMPT_I16_EXPR_I16 = 0x66
+  OP_JMPT_I16_EXPR_I32 = 0x67
+  OP_JMPT_I32_EXPR_I8 = 0x68
+  OP_JMPT_I32_EXPR_I16 = 0x69
+  OP_JMPT_I32_EXPR_I32 = 0x6a
+  OP_JMPT_F32_EXPR_I8 = 0x6b
+  OP_JMPT_F32_EXPR_I16 = 0x6c
+  OP_JMPT_F32_EXPR_I32 = 0x6d
+  OP_JMPT_R1_EXPR_I8 = 0x6e
+  OP_JMPT_R1_EXPR_I16 = 0x6f
+  OP_JMPT_R1_EXPR_I32 = 0x70
+  OP_JMPT_R2_EXPR_I8 = 0x71
+  OP_JMPT_R2_EXPR_I16 = 0x72
+  OP_JMPT_R2_EXPR_I32 = 0x73
+  OP_JMPT_R3_EXPR_I8 = 0x74
+  OP_JMPT_R3_EXPR_I16 = 0x75
+  OP_JMPT_R3_EXPR_I32 = 0x76
+  OP_LD_8 = 0x77
+  OP_LD_16 = 0x78
+  OP_LD_32 = 0x79
+  OP_LEA_EXPR_I8_R1 = 0x7a
+  OP_LEA_EXPR_I8_R2 = 0x7b
+  OP_LEA_EXPR_I8_R3 = 0x7c
+  OP_LEA_EXPR_I8_R4 = 0x7d
+  OP_LEA_EXPR_I8_R5 = 0x7e
+  OP_LEA_EXPR_I16_R1 = 0x7f
+  OP_LEA_EXPR_I16_R2 = 0x80
+  OP_LEA_EXPR_I16_R3 = 0x81
+  OP_LEA_EXPR_I16_R4 = 0x82
+  OP_LEA_EXPR_I16_R5 = 0x83
+  OP_LEA_EXPR_I32_R1 = 0x84
+  OP_LEA_EXPR_I32_R2 = 0x85
+  OP_LEA_EXPR_I32_R3 = 0x86
+  OP_LEA_EXPR_I32_R4 = 0x87
+  OP_LEA_EXPR_I32_R5 = 0x88
+  OP_LE_SI8 = 0x89
+  OP_LE_SI16 = 0x8a
+  OP_LE_SI32 = 0x8b
+  OP_LE_UI8 = 0x8c
+  OP_LE_UI16 = 0x8d
+  OP_LE_UI32 = 0x8e
+  OP_LE_F32 = 0x8f
+  OP_LT_SI8 = 0x90
+  OP_LT_SI16 = 0x91
+  OP_LT_SI32 = 0x92
+  OP_LT_UI8 = 0x93
+  OP_LT_UI16 = 0x94
+  OP_LT_UI32 = 0x95
+  OP_LT_F32 = 0x96
+  OP_MOD_SI8 = 0x97
+  OP_MOD_SI16 = 0x98
+  OP_MOD_SI32 = 0x99
+  OP_MOD_UI8 = 0x9a
+  OP_MOD_UI16 = 0x9b
+  OP_MOD_UI32 = 0x9c
+  OP_MOD_R_SI8 = 0x9d
+  OP_MOD_R_SI16 = 0x9e
+  OP_MOD_R_SI32 = 0x9f
+  OP_MOD_R_UI8 = 0xa0
+  OP_MOD_R_UI16 = 0xa1
+  OP_MOD_R_UI32 = 0xa2
+  OP_MOV_R0_R1 = 0xa3
+  OP_MOV_R0_R2 = 0xa4
+  OP_MOV_R0_R3 = 0xa5
+  OP_MOV_R0_R4 = 0xa6
+  OP_MOV_R0_R5 = 0xa7
+  OP_MOV_R1_R0 = 0xa8
+  OP_MOV_R2_R0 = 0xa9
+  OP_MOV_R3_R0 = 0xaa
+  OP_MOV_R4_R0 = 0xab
+  OP_MOV_R5_R0 = 0xac
+  OP_MUL_I8 = 0xad
+  OP_MUL_I16 = 0xae
+  OP_MUL_I32 = 0xaf
+  OP_MUL_F32 = 0xb0
+  OP_NEG_I8 = 0xb1
+  OP_NEG_I16 = 0xb2
+  OP_NEG_I32 = 0xb3
+  OP_NEG_F32 = 0xb4
+  OP_NE_I8 = 0xb5
+  OP_NE_I16 = 0xb6
+  OP_NE_I32 = 0xb7
+  OP_NE_F32 = 0xb8
+  OP_NOT_I8 = 0xb9
+  OP_NOT_I16 = 0xba
+  OP_NOT_I32 = 0xbb
+  OP_OR_I8 = 0xbc
+  OP_OR_I16 = 0xbd
+  OP_OR_I32 = 0xbe
+  OP_POP_8 = 0xbf
+  OP_POP_16 = 0xc0
+  OP_POP_32 = 0xc1
+  OP_POP_R1 = 0xc2
+  OP_POP_R2 = 0xc3
+  OP_POP_R3 = 0xc4
+  OP_POP_R4 = 0xc5
+  OP_POP_R5 = 0xc6
+  OP_PUSH_8 = 0xc7
+  OP_PUSH_16 = 0xc8
+  OP_PUSH_32 = 0xc9
+  OP_PUSH_R1 = 0xca
+  OP_PUSH_R2 = 0xcb
+  OP_PUSH_R3 = 0xcc
+  OP_PUSH_R4 = 0xcd
+  OP_PUSH_R5 = 0xce
+  OP_RET = 0xcf
+  OP_SHL_I8 = 0xd0
+  OP_SHL_I16 = 0xd1
+  OP_SHL_I32 = 0xd2
+  OP_SHL_R_I8 = 0xd3
+  OP_SHL_R_I16 = 0xd4
+  OP_SHL_R_I32 = 0xd5
+  OP_SHR_SI8 = 0xd6
+  OP_SHR_SI16 = 0xd7
+  OP_SHR_SI32 = 0xd8
+  OP_SHR_UI8 = 0xd9
+  OP_SHR_UI16 = 0xda
+  OP_SHR_UI32 = 0xdb
+  OP_SHR_R_SI8 = 0xdc
+  OP_SHR_R_SI16 = 0xdd
+  OP_SHR_R_SI32 = 0xde
+  OP_SHR_R_UI8 = 0xdf
+  OP_SHR_R_UI16 = 0xe0
+  OP_SHR_R_UI32 = 0xe1
+  OP_ST_8 = 0xe2
+  OP_ST_16 = 0xe3
+  OP_ST_32 = 0xe4
+  OP_ST_R_8 = 0xe5
+  OP_ST_R_16 = 0xe6
+  OP_ST_R_32 = 0xe7
+  OP_SUB_I8 = 0xe8
+  OP_SUB_I16 = 0xe9
+  OP_SUB_I32 = 0xea
+  OP_SUB_F32 = 0xeb
+  OP_SUB_R_I8 = 0xec
+  OP_SUB_R_I16 = 0xed
+  OP_SUB_R_I32 = 0xee
+  OP_SUB_R_F32 = 0xef
+  OP_TRAP = 0xf0
+  OP_XOR_I8 = 0xf1
+  OP_XOR_I16 = 0xf2
+  OP_XOR_I32 = 0xf3
+  OP_ADD_I64 = 0x100
+  OP_ADD_I128 = 0x101
+  OP_ADD_F64 = 0x102
+  OP_ADD_F128 = 0x103
+  OP_AND_I64 = 0x104
+  OP_AND_I128 = 0x105
+  OP_CVT_SI8_I64 = 0x106
+  OP_CVT_SI8_I128 = 0x107
+  OP_CVT_SI8_F64 = 0x108
+  OP_CVT_SI8_F128 = 0x109
+  OP_CVT_SI16_I64 = 0x10a
+  OP_CVT_SI16_I128 = 0x10b
+  OP_CVT_SI16_F64 = 0x10c
+  OP_CVT_SI16_F128 = 0x10d
+  OP_CVT_SI32_I64 = 0x10e
+  OP_CVT_SI32_I128 = 0x10f
+  OP_CVT_SI32_F64 = 0x110
+  OP_CVT_SI32_F128 = 0x111
+  OP_CVT_SI64_I128 = 0x112
+  OP_CVT_SI64_F32 = 0x113
+  OP_CVT_SI64_F64 = 0x114
+  OP_CVT_SI64_F128 = 0x115
+  OP_CVT_SI128_F32 = 0x116
+  OP_CVT_SI128_F64 = 0x117
+  OP_CVT_SI128_F128 = 0x118
+  OP_CVT_UI8_I64 = 0x119
+  OP_CVT_UI8_I128 = 0x11a
+  OP_CVT_UI8_F64 = 0x11b
+  OP_CVT_UI8_F128 = 0x11c
+  OP_CVT_UI16_I64 = 0x11d
+  OP_CVT_UI16_I128 = 0x11e
+  OP_CVT_UI16_F64 = 0x11f
+  OP_CVT_UI16_F128 = 0x120
+  OP_CVT_UI32_I64 = 0x121
+  OP_CVT_UI32_I128 = 0x122
+  OP_CVT_UI32_F64 = 0x123
+  OP_CVT_UI32_F128 = 0x124
+  OP_CVT_UI64_I128 = 0x125
+  OP_CVT_UI64_F32 = 0x126
+  OP_CVT_UI64_F64 = 0x127
+  OP_CVT_UI64_F128 = 0x128
+  OP_CVT_UI128_F32 = 0x129
+  OP_CVT_UI128_F64 = 0x12a
+  OP_CVT_UI128_F128 = 0x12b
+  OP_CVT_F32_F64 = 0x12c
+  OP_CVT_F32_F128 = 0x12d
+  OP_CVT_F32_I64 = 0x12e
+  OP_CVT_F32_I128 = 0x12f
+  OP_CVT_F64_F32 = 0x130
+  OP_CVT_F64_F128 = 0x131
+  OP_CVT_F64_I8 = 0x132
+  OP_CVT_F64_I16 = 0x133
+  OP_CVT_F64_I32 = 0x134
+  OP_CVT_F64_I64 = 0x135
+  OP_CVT_F64_I128 = 0x136
+  OP_CVT_F128_F32 = 0x137
+  OP_CVT_F128_F64 = 0x138
+  OP_CVT_F128_I8 = 0x139
+  OP_CVT_F128_I16 = 0x13a
+  OP_CVT_F128_I32 = 0x13b
+  OP_CVT_F128_I64 = 0x13c
+  OP_CVT_F128_I128 = 0x13d
+  OP_DIV_SI64 = 0x13e
+  OP_DIV_SI128 = 0x13f
+  OP_DIV_UI64 = 0x140
+  OP_DIV_UI128 = 0x141
+  OP_DIV_F64 = 0x142
+  OP_DIV_F128 = 0x143
+  OP_DIV_R_SI64 = 0x144
+  OP_DIV_R_SI128 = 0x145
+  OP_DIV_R_UI64 = 0x146
+  OP_DIV_R_UI128 = 0x147
+  OP_DIV_R_F64 = 0x148
+  OP_DIV_R_F128 = 0x149
+  OP_EQ_I64 = 0x14a
+  OP_EQ_I128 = 0x14b
+  OP_EQ_F64 = 0x14c
+  OP_EQ_F128 = 0x14d
+  OP_GE_SI64 = 0x14e
+  OP_GE_SI128 = 0x14f
+  OP_GE_UI64 = 0x150
+  OP_GE_UI128 = 0x151
+  OP_GE_F64 = 0x152
+  OP_GE_F128 = 0x153
+  OP_GT_SI64 = 0x154
+  OP_GT_SI128 = 0x155
+  OP_GT_UI64 = 0x156
+  OP_GT_UI128 = 0x157
+  OP_GT_F64 = 0x158
+  OP_GT_F128 = 0x159
+  OP_IMM_EXPR_64 = 0x15a
+  OP_IMM_EXPR_128 = 0x15b
+  OP_JMPF_I64_EXPR_I8 = 0x15c
+  OP_JMPF_I64_EXPR_I16 = 0x15d
+  OP_JMPF_I64_EXPR_I32 = 0x15e
+  OP_JMPF_I128_EXPR_I8 = 0x15f
+  OP_JMPF_I128_EXPR_I16 = 0x160
+  OP_JMPF_I128_EXPR_I32 = 0x161
+  OP_JMPF_F64_EXPR_I8 = 0x162
+  OP_JMPF_F64_EXPR_I16 = 0x163
+  OP_JMPF_F64_EXPR_I32 = 0x164
+  OP_JMPF_F128_EXPR_I8 = 0x165
+  OP_JMPF_F128_EXPR_I16 = 0x166
+  OP_JMPF_F128_EXPR_I32 = 0x167
+  OP_JMPT_I64_EXPR_I8 = 0x168
+  OP_JMPT_I64_EXPR_I16 = 0x169
+  OP_JMPT_I64_EXPR_I32 = 0x16a
+  OP_JMPT_I128_EXPR_I8 = 0x16b
+  OP_JMPT_I128_EXPR_I16 = 0x16c
+  OP_JMPT_I128_EXPR_I32 = 0x16d
+  OP_JMPT_F64_EXPR_I8 = 0x16e
+  OP_JMPT_F64_EXPR_I16 = 0x16f
+  OP_JMPT_F64_EXPR_I32 = 0x170
+  OP_JMPT_F128_EXPR_I8 = 0x171
+  OP_JMPT_F128_EXPR_I16 = 0x172
+  OP_JMPT_F128_EXPR_I32 = 0x173
+  OP_LD_64 = 0x174
+  OP_LD_128 = 0x175
+  OP_LE_SI64 = 0x176
+  OP_LE_SI128 = 0x177
+  OP_LE_UI64 = 0x178
+  OP_LE_UI128 = 0x179
+  OP_LE_F64 = 0x17a
+  OP_LE_F128 = 0x17b
+  OP_LT_SI64 = 0x17c
+  OP_LT_SI128 = 0x17d
+  OP_LT_UI64 = 0x17e
+  OP_LT_UI128 = 0x17f
+  OP_LT_F64 = 0x180
+  OP_LT_F128 = 0x181
+  OP_MOD_SI64 = 0x182
+  OP_MOD_SI128 = 0x183
+  OP_MOD_UI64 = 0x184
+  OP_MOD_UI128 = 0x185
+  OP_MOD_R_SI64 = 0x186
+  OP_MOD_R_SI128 = 0x187
+  OP_MOD_R_UI64 = 0x188
+  OP_MOD_R_UI128 = 0x189
+  OP_MUL_I64 = 0x18a
+  OP_MUL_I128 = 0x18b
+  OP_MUL_F64 = 0x18c
+  OP_MUL_F128 = 0x18d
+  OP_NEG_I64 = 0x18e
+  OP_NEG_I128 = 0x18f
+  OP_NEG_F64 = 0x190
+  OP_NEG_F128 = 0x191
+  OP_NE_I64 = 0x192
+  OP_NE_I128 = 0x193
+  OP_NE_F64 = 0x194
+  OP_NE_F128 = 0x195
+  OP_NOT_I64 = 0x196
+  OP_NOT_I128 = 0x197
+  OP_OR_I64 = 0x198
+  OP_OR_I128 = 0x199
+  OP_POP_64 = 0x19a
+  OP_POP_128 = 0x19b
+  OP_PUSH_64 = 0x19c
+  OP_PUSH_128 = 0x19d
+  OP_SHL_I64 = 0x19e
+  OP_SHL_I128 = 0x19f
+  OP_SHL_R_I64 = 0x1a0
+  OP_SHL_R_I128 = 0x1a1
+  OP_SHR_SI64 = 0x1a2
+  OP_SHR_SI128 = 0x1a3
+  OP_SHR_UI64 = 0x1a4
+  OP_SHR_UI128 = 0x1a5
+  OP_SHR_R_SI64 = 0x1a6
+  OP_SHR_R_SI128 = 0x1a7
+  OP_SHR_R_UI64 = 0x1a8
+  OP_SHR_R_UI128 = 0x1a9
+  OP_ST_64 = 0x1aa
+  OP_ST_128 = 0x1ab
+  OP_ST_R_64 = 0x1ac
+  OP_ST_R_128 = 0x1ad
+  OP_SUB_I64 = 0x1ae
+  OP_SUB_I128 = 0x1af
+  OP_SUB_F64 = 0x1b0
+  OP_SUB_F128 = 0x1b1
+  OP_SUB_R_I64 = 0x1b2
+  OP_SUB_R_I128 = 0x1b3
+  OP_SUB_R_F64 = 0x1b4
+  OP_SUB_R_F128 = 0x1b5
+  OP_XOR_I64 = 0x1b6
+  OP_XOR_I128 = 0x1b7
+%}
+
+%%
+
+/* expression evaluation */
+class Value;
+class ValueInt: Value {
+  int value;
+};
+class ValueFloat: Value {
+  mpfr value;
+};
+class ValueString: Value {
+  list(int) values;
+};
+class ValueExtern: Value {
+  str name;
+  int offset;
+};
+
+/*
+ * all of the following classes can appear as children or indirect children
+ * of the InputFile (root) node, and have Node as a superclass so that
+ * the post_process() routine can effortlessly recurse through all children
+ */
+
+/* internal */
+class Node;
+class Text: Node;
+class Expression: Node;
+class ExpressionUnary: Expression;
+class ExpressionBinary: Expression;
+class InputLine: Node;
+class DotData: InputLine {
+  int size;
+};
+
+/* lexical analyzer */
+class EscapeSequence: Node;
+class ExponentPart: Node;
+class IntegerEscapeSequence: EscapeSequence {
+  int base;
+};
+class Sign: Node {
+  int value = 1;
+};
+class SimpleEscapeSequence: EscapeSequence {
+  int value = -1;
+};
+
+/* parser */
+class ExpressionAdd: ExpressionBinary;
+class ExpressionBitwiseAnd: ExpressionBinary;
+class ExpressionBitwiseNot: ExpressionUnary;
+class ExpressionBitwiseOr: ExpressionBinary;
+class ExpressionCharacterConstant: Expression {
+  bool wide;
+};
+class ExpressionConditional: Expression;
+class ExpressionDivide: ExpressionBinary;
+class ExpressionEqual: ExpressionBinary;
+class ExpressionExclusiveOr: ExpressionBinary;
+class ExpressionFloatingConstant: Expression;
+class ExpressionGreaterThan: ExpressionBinary;
+class ExpressionGreaterThanOrEqual: ExpressionBinary;
+class ExpressionIdentifier: Expression;
+class ExpressionIntegerConstant: Expression {
+  int base;
+};
+class ExpressionLessThan: ExpressionBinary;
+class ExpressionLessThanOrEqual: ExpressionBinary;
+class ExpressionLogicalAnd: ExpressionBinary;
+class ExpressionLogicalNot: ExpressionUnary;
+class ExpressionLogicalOr: ExpressionBinary;
+class ExpressionMinus: ExpressionUnary;
+class ExpressionModulo: ExpressionBinary;
+class ExpressionMultiply: ExpressionBinary;
+class ExpressionNotEqual: ExpressionBinary;
+class ExpressionPlus: ExpressionUnary;
+class ExpressionShiftLeft: ExpressionBinary;
+class ExpressionShiftRight: ExpressionBinary;
+class ExpressionSubtract: ExpressionBinary;
+class Identifier: Node;
+class Label: InputLine;
+class Equate: InputLine;
+class DotAlign: InputLine;
+class DotDataI: DotData;
+class DotDataF: DotData;
+class DotSpace: InputLine;
+class Op: InputLine {
+  int op;
+};
+class OpWithData: Op {
+  int size;
+};
+class OpI: OpWithData;
+class OpF: OpWithData;
+class OpPCR: OpWithData;
+class InputFile: Node;
+
+%%
+
+def factory(tag, *args, **kwargs):
+  return tag_to_class[tag](*args, **kwargs)
+
+class Context:
+  pass
+
+@method(Node)
+def post_process(self, context):
+  pass
diff --git a/vm_asm.y b/vm_asm.y
new file mode 100644 (file)
index 0000000..e289212
--- /dev/null
+++ b/vm_asm.y
@@ -0,0 +1,758 @@
+%token DOT_ALIGN
+%token DOT_DATA
+%token DOT_SPACE
+%token ADD
+%token AND
+%token CALL
+%token CVT
+%token DIV
+%token DIV_R
+%token EQ
+%token EXPR
+%token F32
+%token F64
+%token F128
+%token GE
+%token GT
+%token I8
+%token I16
+%token I32
+%token I64
+%token I128
+%token IMM
+%token JMP
+%token JMPF
+%token JMPT
+%token LD
+%token LD_8
+%token LD_16
+%token LD_32
+%token LD_64
+%token LD_128
+%token LEA
+%token LE
+%token LT
+%token MOD
+%token MOD_R
+%token MOV
+%token MUL
+%token NE
+%token NEG
+%token NOP
+%token NOT
+%token OR
+%token PCR8
+%token PCR16
+%token PCR32
+%token POP
+%token POP_8
+%token POP_16
+%token POP_32
+%token POP_64
+%token POP_128
+%token PUSH
+%token PUSH_8
+%token PUSH_16
+%token PUSH_32
+%token PUSH_64
+%token PUSH_128
+%token R0
+%token R1
+%token R2
+%token R3
+%token R4
+%token R5
+%token RET
+%token SHL
+%token SHL_R
+%token SHR
+%token SHR_R
+%token SI8
+%token SI16
+%token SI32
+%token SI64
+%token SI128
+%token ST
+%token ST_8
+%token ST_16
+%token ST_32
+%token ST_64
+%token ST_128
+%token ST_R
+%token ST_R_8
+%token ST_R_16
+%token ST_R_32
+%token ST_R_64
+%token ST_R_128
+%token SUB
+%token SUB_R
+%token TRAP
+%token UI8
+%token UI16
+%token UI32
+%token UI64
+%token UI128
+%token XOR
+%token IDENTIFIER
+%token FLOATING_CONSTANT
+%token INTEGER_CONSTANT
+%token CHARACTER_CONSTANT
+%token STRING_LITERAL
+%token RIGHT_OP
+%token LEFT_OP
+%token AND_OP
+%token OR_OP
+%token LE_OP
+%token GE_OP
+%token EQ_OP
+%token NE_OP
+%token NEWLINE
+
+%start input_file 
+
+%{
+  import sys
+  import t_def
+
+  # set this before calling yyparse(), for error messages
+  in_file = None
+%}
+
+%%
+
+primary_expression
+  : expression_identifier
+  | constant
+  | STRING_LITERAL
+  | '(' expression ')'
+  ;
+
+constant
+  : INTEGER_CONSTANT
+  | FLOATING_CONSTANT
+  | CHARACTER_CONSTANT
+  ;
+
+unary_expression
+  : primary_expression
+  | %space (?E{t_def.ExpressionPlus}'+' unary_expression)
+  | %space (?E{t_def.ExpressionMinus}'-' unary_expression)
+  | %space (?E{t_def.ExpressionBitwiseNot}'~' unary_expression)
+  | %space (?E{t_def.ExpressionLogicalNot}'!' unary_expression)
+  ;
+
+multiplicative_expression
+  : unary_expression
+  | %space (?E{t_def.ExpressionMultiply}multiplicative_expression '*' unary_expression)
+  | %space (?E{t_def.ExpressionDivide}multiplicative_expression '/' unary_expression)
+  | %space (?E{t_def.ExpressionModulo}multiplicative_expression '%' unary_expression)
+  ;
+
+additive_expression
+  : multiplicative_expression
+  | %space (?E{t_def.ExpressionAdd}additive_expression '+' multiplicative_expression)
+  | %space (?E{t_def.ExpressionSubtract}additive_expression '-' multiplicative_expression)
+  ;
+
+shift_expression
+  : additive_expression
+  | %space (?E{t_def.ExpressionShiftLeft}shift_expression LEFT_OP additive_expression)
+  | %space (?E{t_def.ExpressionShiftRight}shift_expression RIGHT_OP additive_expression)
+  ;
+
+relational_expression
+  : shift_expression
+  | %space (?E{t_def.ExpressionLessThan}relational_expression '<' shift_expression)
+  | %space (?E{t_def.ExpressionGreaterThan}relational_expression '>' shift_expression)
+  | %space (?E{t_def.ExpressionLessThanOrEqual}relational_expression LE_OP shift_expression)
+  | %space (?E{t_def.ExpressionGreaterThanOrEqual}relational_expression GE_OP shift_expression)
+  ;
+
+equality_expression
+  : relational_expression
+  | %space (?E{t_def.ExpressionEqual}equality_expression EQ_OP relational_expression)
+  | %space (?E{t_def.ExpressionNotEqual}equality_expression NE_OP relational_expression)
+  ;
+
+and_expression
+  : equality_expression
+  | %space (?E{t_def.ExpressionBitwiseAnd}and_expression '&' equality_expression)
+  ;
+
+exclusive_or_expression
+  : and_expression
+  | %space (?E{t_def.ExpressionExclusiveOr}exclusive_or_expression '^' and_expression)
+  ;
+
+inclusive_or_expression
+  : exclusive_or_expression
+  | %space (?E{t_def.ExpressionBitwiseOr}inclusive_or_expression '|' exclusive_or_expression)
+  ;
+
+logical_and_expression
+  : inclusive_or_expression
+  | %space (?E{t_def.ExpressionLogicalAnd}logical_and_expression AND_OP inclusive_or_expression)
+  ;
+
+logical_or_expression
+  : logical_and_expression
+  | %space (?E{t_def.ExpressionLogicalOr}logical_or_expression OR_OP logical_and_expression)
+  ;
+
+expression
+  : logical_or_expression
+  | %space (?E{t_def.ExpressionConditional}logical_or_expression '?' expression ':' expression)
+  ;
+
+/* IDENTIFIER can have several different kinds of markup */
+/* therefore the markup is added here rather than in lexical analysis */
+identifier
+  : %space (?E{t_def.Identifier}IDENTIFIER)
+  ;
+
+expression_identifier
+  : %space (?E{t_def.ExpressionIdentifier}IDENTIFIER)
+  ;
+
+input_line
+  :
+  | %space (?E{t_def.Label}identifier ':')
+  | %space (?E{t_def.Equate}identifier '=' expression)
+  | %space (?E{t_def.DotAlign}DOT_ALIGN expression)
+  | %space (?E{t_def.DotDataI, size = 8}DOT_DATA expression ',' I8)
+  | %space (?E{t_def.DotDataI, size = 16}DOT_DATA expression ',' I16)
+  | %space (?E{t_def.DotDataI, size = 32}DOT_DATA expression ',' I32)
+  | %space (?E{t_def.DotDataI, size = 64}DOT_DATA expression ',' I64)
+  | %space (?E{t_def.DotDataI, size = 128}DOT_DATA expression ',' I128)
+  | %space (?E{t_def.DotDataF, size = 32}DOT_DATA expression ',' F32)
+  | %space (?E{t_def.DotDataF, size = 64}DOT_DATA expression ',' F64)
+  | %space (?E{t_def.DotDataF, size = 128}DOT_DATA expression ',' F128)
+  | %space (?E{t_def.DotSpace}DOT_SPACE expression)
+  | %space (?E{t_def.Op, op = t_def.OP_NOP}NOP)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I8_R1, size = 8}ADD expression ',' I8 ',' R1)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I8_R2, size = 8}ADD expression ',' I8 ',' R2)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I8_R3, size = 8}ADD expression ',' I8 ',' R3)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I8_R4, size = 8}ADD expression ',' I8 ',' R4)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I8_R5, size = 8}ADD expression ',' I8 ',' R5)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I16_R1, size = 16}ADD expression ',' I16 ',' R1)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I16_R2, size = 16}ADD expression ',' I16 ',' R2)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I16_R3, size = 16}ADD expression ',' I16 ',' R3)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I16_R4, size = 16}ADD expression ',' I16 ',' R4)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I16_R5, size = 16}ADD expression ',' I16 ',' R5)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I32_R1, size = 32}ADD expression ',' I32 ',' R1)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I32_R2, size = 32}ADD expression ',' I32 ',' R2)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I32_R3, size = 32}ADD expression ',' I32 ',' R3)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I32_R4, size = 32}ADD expression ',' I32 ',' R4)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I32_R5, size = 32}ADD expression ',' I32 ',' R5)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_I8}ADD I8)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_I16}ADD I16)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_I32}ADD I32)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_I64}ADD I64)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_I128}ADD I128)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_F32}ADD F32)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_F64}ADD F64)
+  | %space (?E{t_def.Op, op = t_def.OP_ADD_F128}ADD F128)
+  | %space (?E{t_def.Op, op = t_def.OP_AND_I8}AND I8)
+  | %space (?E{t_def.Op, op = t_def.OP_AND_I16}AND I16)
+  | %space (?E{t_def.Op, op = t_def.OP_AND_I32}AND I32)
+  | %space (?E{t_def.Op, op = t_def.OP_AND_I64}AND I64)
+  | %space (?E{t_def.Op, op = t_def.OP_AND_I128}AND I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CALL}CALL)
+  | %space (?E{t_def.OpI, op = t_def.OP_CALL_EXPR_I8, size = 8}CALL expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_CALL_EXPR_I16, size = 16}CALL expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_CALL_EXPR_I32, size = 32}CALL expression ',' I32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_CALL_EXPR_I8, size = 8}CALL expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_CALL_EXPR_I16, size = 16}CALL expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_CALL_EXPR_I32, size = 32}CALL expression ',' PCR32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_I16}CVT SI8 ',' I16)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_I32}CVT SI8 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_I64}CVT SI8 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_I128}CVT SI8 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_F32}CVT SI8 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_F64}CVT SI8 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI8_F128}CVT SI8 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI16_I32}CVT SI16 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI16_I64}CVT SI16 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI16_I128}CVT SI16 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI16_F32}CVT SI16 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI16_F64}CVT SI16 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI16_F128}CVT SI16 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI32_I64}CVT SI32 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI32_I128}CVT SI32 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI32_F32}CVT SI32 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI32_F64}CVT SI32 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI32_F128}CVT SI32 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI64_I128}CVT SI64 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI64_F32}CVT SI64 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI64_F64}CVT SI64 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI64_F128}CVT SI64 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI128_F32}CVT SI128 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI128_F64}CVT SI128 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_SI128_F128}CVT SI128 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_I16}CVT UI8 ',' I16)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_I32}CVT UI8 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_I64}CVT UI8 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_I128}CVT UI8 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_F32}CVT UI8 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_F64}CVT UI8 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI8_F128}CVT UI8 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI16_I32}CVT UI16 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI16_I64}CVT UI16 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI16_I128}CVT UI16 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI16_F32}CVT UI16 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI16_F64}CVT UI16 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI16_F128}CVT UI16 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI32_I64}CVT UI32 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI32_I128}CVT UI32 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI32_F32}CVT UI32 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI32_F64}CVT UI32 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI32_F128}CVT UI32 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI64_I128}CVT UI64 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI64_F32}CVT UI64 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI64_F64}CVT UI64 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI64_F128}CVT UI64 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI128_F32}CVT UI128 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI128_F64}CVT UI128 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_UI128_F128}CVT UI128 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_F64}CVT F32 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_F128}CVT F32 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_I8}CVT F32 ',' I8)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_I16}CVT F32 ',' I16)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_I32}CVT F32 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_I64}CVT F32 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F32_I128}CVT F32 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_F32}CVT F64 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_F128}CVT F64 ',' F128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_I8}CVT F64 ',' I8)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_I16}CVT F64 ',' I16)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_I32}CVT F64 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_I64}CVT F64 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F64_I128}CVT F64 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_F32}CVT F128 ',' F32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_F64}CVT F128 ',' F64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_I8}CVT F128 ',' I8)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_I16}CVT F128 ',' I16)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_I32}CVT F128 ',' I32)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_I64}CVT F128 ',' I64)
+  | %space (?E{t_def.Op, op = t_def.OP_CVT_F128_I128}CVT F128 ',' I128)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_SI8}DIV SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_SI16}DIV SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_SI32}DIV SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_SI64}DIV SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_SI128}DIV SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_UI8}DIV UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_UI16}DIV UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_UI32}DIV UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_UI64}DIV UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_UI128}DIV UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_F32}DIV F32)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_F64}DIV F64)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_F128}DIV F128)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_SI8}DIV_R SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_SI16}DIV_R SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_SI32}DIV_R SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_SI64}DIV_R SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_SI128}DIV_R SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_UI8}DIV_R UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_UI16}DIV_R UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_UI32}DIV_R UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_UI64}DIV_R UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_UI128}DIV_R UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_F32}DIV_R F32)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_F64}DIV_R F64)
+  | %space (?E{t_def.Op, op = t_def.OP_DIV_R_F128}DIV_R F128)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_I8}EQ I8)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_I16}EQ I16)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_I32}EQ I32)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_I64}EQ I64)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_I128}EQ I128)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_F32}EQ F32)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_F64}EQ F64)
+  | %space (?E{t_def.Op, op = t_def.OP_EQ_F128}EQ F128)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_SI8}GE SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_SI16}GE SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_SI32}GE SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_SI64}GE SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_SI128}GE SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_UI8}GE UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_UI16}GE UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_UI32}GE UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_UI64}GE UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_UI128}GE UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_F32}GE F32)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_F64}GE F64)
+  | %space (?E{t_def.Op, op = t_def.OP_GE_F128}GE F128)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_SI8}GT SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_SI16}GT SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_SI32}GT SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_SI64}GT SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_SI128}GT SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_UI8}GT UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_UI16}GT UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_UI32}GT UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_UI64}GT UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_UI128}GT UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_F32}GT F32)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_F64}GT F64)
+  | %space (?E{t_def.Op, op = t_def.OP_GT_F128}GT F128)
+  | %space (?E{t_def.OpI, op = t_def.OP_IMM_EXPR_8, size = 8}IMM expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_IMM_EXPR_16, size = 16}IMM expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_IMM_EXPR_32, size = 32}IMM expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_IMM_EXPR_64, size = 64}IMM expression ',' I64)
+  | %space (?E{t_def.OpI, op = t_def.OP_IMM_EXPR_128, size = 128}IMM expression ',' I128)
+  | %space (?E{t_def.OpF, op = t_def.OP_IMM_EXPR_32, size = 32}IMM expression ',' F32)
+  | %space (?E{t_def.OpF, op = t_def.OP_IMM_EXPR_64, size = 64}IMM expression ',' F64)
+  | %space (?E{t_def.OpF, op = t_def.OP_IMM_EXPR_128, size = 128}IMM expression ',' F128)
+
+  /* imm XXX,pcrY is a synonym for lea XXX,pcrY,r5 */
+  | %space (?E{t_def.OpPCR, op = t_def.OP_LEA_EXPR_I8_R5, size = 8}IMM expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_LEA_EXPR_I16_R5, size = 16}IMM expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_LEA_EXPR_I32_R5, size = 32}IMM expression ',' PCR32)
+
+  /* jmp XXX,YYY is a synonym for add XXX,YYY,r5 */
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I8_R5, size = 8}JMP expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I16_R5, size = 16}JMP expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_ADD_EXPR_I32_R5, size = 32}JMP expression ',' I32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_ADD_EXPR_I8_R5, size = 8}JMP expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_ADD_EXPR_I16_R5, size = 16}JMP expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_ADD_EXPR_I32_R5, size = 32}JMP expression ',' PCR32)
+
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I8_EXPR_I8, size = 8}JMPF I8 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I8_EXPR_I16, size = 16}JMPF I8 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I8_EXPR_I32, size = 32}JMPF I8 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I16_EXPR_I8, size = 8}JMPF I16 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I16_EXPR_I16, size = 16}JMPF I16 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I16_EXPR_I32, size = 32}JMPF I16 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I32_EXPR_I8, size = 8}JMPF I32 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I32_EXPR_I16, size = 16}JMPF I32 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I32_EXPR_I32, size = 32}JMPF I32 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I64_EXPR_I8, size = 8}JMPF I64 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I64_EXPR_I16, size = 16}JMPF I64 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I64_EXPR_I32, size = 32}JMPF I64 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I128_EXPR_I8, size = 8}JMPF I128 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I128_EXPR_I16, size = 16}JMPF I128 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_I128_EXPR_I32, size = 32}JMPF I128 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F32_EXPR_I8, size = 8}JMPF F32 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F32_EXPR_I16, size = 16}JMPF F32 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F32_EXPR_I32, size = 32}JMPF F32 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F64_EXPR_I8, size = 8}JMPF F64 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F64_EXPR_I16, size = 16}JMPF F64 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F64_EXPR_I32, size = 32}JMPF F64 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F128_EXPR_I8, size = 8}JMPF F128 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F128_EXPR_I16, size = 16}JMPF F128 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_F128_EXPR_I32, size = 32}JMPF F128 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R1_EXPR_I8, size = 8}JMPF R1 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R1_EXPR_I16, size = 16}JMPF R1 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R1_EXPR_I32, size = 32}JMPF R1 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R2_EXPR_I8, size = 8}JMPF R2 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R2_EXPR_I16, size = 16}JMPF R2 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R2_EXPR_I32, size = 32}JMPF R2 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R3_EXPR_I8, size = 8}JMPF R3 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R3_EXPR_I16, size = 16}JMPF R3 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPF_R3_EXPR_I32, size = 32}JMPF R3 ',' expression ',' I32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I8_EXPR_I8, size = 8}JMPF I8 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I8_EXPR_I16, size = 16}JMPF I8 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I8_EXPR_I32, size = 32}JMPF I8 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I16_EXPR_I8, size = 8}JMPF I16 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I16_EXPR_I16, size = 16}JMPF I16 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I16_EXPR_I32, size = 32}JMPF I16 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I32_EXPR_I8, size = 8}JMPF I32 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I32_EXPR_I16, size = 16}JMPF I32 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I32_EXPR_I32, size = 32}JMPF I32 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I64_EXPR_I8, size = 8}JMPF I64 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I64_EXPR_I16, size = 16}JMPF I64 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I64_EXPR_I32, size = 32}JMPF I64 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I128_EXPR_I8, size = 8}JMPF I128 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I128_EXPR_I16, size = 16}JMPF I128 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_I128_EXPR_I32, size = 32}JMPF I128 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F32_EXPR_I8, size = 8}JMPF F32 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F32_EXPR_I16, size = 16}JMPF F32 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F32_EXPR_I32, size = 32}JMPF F32 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F64_EXPR_I8, size = 8}JMPF F64 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F64_EXPR_I16, size = 16}JMPF F64 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F64_EXPR_I32, size = 32}JMPF F64 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F128_EXPR_I8, size = 8}JMPF F128 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F128_EXPR_I16, size = 16}JMPF F128 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_F128_EXPR_I32, size = 32}JMPF F128 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R1_EXPR_I8, size = 8}JMPF R1 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R1_EXPR_I16, size = 16}JMPF R1 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R1_EXPR_I32, size = 32}JMPF R1 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R2_EXPR_I8, size = 8}JMPF R2 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R2_EXPR_I16, size = 16}JMPF R2 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R2_EXPR_I32, size = 32}JMPF R2 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R3_EXPR_I8, size = 8}JMPF R3 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R3_EXPR_I16, size = 16}JMPF R3 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPF_R3_EXPR_I32, size = 32}JMPF R3 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I8_EXPR_I8, size = 8}JMPT I8 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I8_EXPR_I16, size = 16}JMPT I8 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I8_EXPR_I32, size = 32}JMPT I8 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I16_EXPR_I8, size = 8}JMPT I16 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I16_EXPR_I16, size = 16}JMPT I16 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I16_EXPR_I32, size = 32}JMPT I16 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I32_EXPR_I8, size = 8}JMPT I32 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I32_EXPR_I16, size = 16}JMPT I32 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I32_EXPR_I32, size = 32}JMPT I32 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I64_EXPR_I8, size = 8}JMPT I64 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I64_EXPR_I16, size = 16}JMPT I64 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I64_EXPR_I32, size = 32}JMPT I64 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I128_EXPR_I8, size = 8}JMPT I128 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I128_EXPR_I16, size = 16}JMPT I128 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_I128_EXPR_I32, size = 32}JMPT I128 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F32_EXPR_I8, size = 8}JMPT F32 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F32_EXPR_I16, size = 16}JMPT F32 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F32_EXPR_I32, size = 32}JMPT F32 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F64_EXPR_I8, size = 8}JMPT F64 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F64_EXPR_I16, size = 16}JMPT F64 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F64_EXPR_I32, size = 32}JMPT F64 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F128_EXPR_I8, size = 8}JMPT F128 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F128_EXPR_I16, size = 16}JMPT F128 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_F128_EXPR_I32, size = 32}JMPT F128 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R1_EXPR_I8, size = 8}JMPT R1 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R1_EXPR_I16, size = 16}JMPT R1 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R1_EXPR_I32, size = 32}JMPT R1 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R2_EXPR_I8, size = 8}JMPT R2 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R2_EXPR_I16, size = 16}JMPT R2 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R2_EXPR_I32, size = 32}JMPT R2 ',' expression ',' I32)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R3_EXPR_I8, size = 8}JMPT R3 ',' expression ',' I8)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R3_EXPR_I16, size = 16}JMPT R3 ',' expression ',' I16)
+  | %space (?E{t_def.OpI, op = t_def.OP_JMPT_R3_EXPR_I32, size = 32}JMPT R3 ',' expression ',' I32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I8_EXPR_I8, size = 8}JMPT I8 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I8_EXPR_I16, size = 16}JMPT I8 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I8_EXPR_I32, size = 32}JMPT I8 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I16_EXPR_I8, size = 8}JMPT I16 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I16_EXPR_I16, size = 16}JMPT I16 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I16_EXPR_I32, size = 32}JMPT I16 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I32_EXPR_I8, size = 8}JMPT I32 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I32_EXPR_I16, size = 16}JMPT I32 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I32_EXPR_I32, size = 32}JMPT I32 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I64_EXPR_I8, size = 8}JMPT I64 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I64_EXPR_I16, size = 16}JMPT I64 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I64_EXPR_I32, size = 32}JMPT I64 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I128_EXPR_I8, size = 8}JMPT I128 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I128_EXPR_I16, size = 16}JMPT I128 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_I128_EXPR_I32, size = 32}JMPT I128 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F32_EXPR_I8, size = 8}JMPT F32 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F32_EXPR_I16, size = 16}JMPT F32 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F32_EXPR_I32, size = 32}JMPT F32 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F64_EXPR_I8, size = 8}JMPT F64 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F64_EXPR_I16, size = 16}JMPT F64 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F64_EXPR_I32, size = 32}JMPT F64 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F128_EXPR_I8, size = 8}JMPT F128 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F128_EXPR_I16, size = 16}JMPT F128 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_F128_EXPR_I32, size = 32}JMPT F128 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R1_EXPR_I8, size = 8}JMPT R1 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R1_EXPR_I16, size = 16}JMPT R1 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R1_EXPR_I32, size = 32}JMPT R1 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R2_EXPR_I8, size = 8}JMPT R2 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R2_EXPR_I16, size = 16}JMPT R2 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R2_EXPR_I32, size = 32}JMPT R2 ',' expression ',' PCR32)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R3_EXPR_I8, size = 8}JMPT R3 ',' expression ',' PCR8)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R3_EXPR_I16, size = 16}JMPT R3 ',' expression ',' PCR16)
+  | %space (?E{t_def.OpPCR, op = t_def.OP_JMPT_R3_EXPR_I32, size = 32}JMPT R3 ',' expression ',' PCR32)
+  | %space (?E{t_def.Op, op = t_def.OP_LD_8}LD_8)
+  | %space (?E{t_def.Op, op = t_def.OP_LD_16}LD_16)
+  | %space (?E{t_def.Op, op = t_def.OP_LD_32}LD_32)
+  | %space (?E{t_def.Op, op = t_def.OP_LD_64}LD_64)
+  | %space (?E{t_def.Op, op = t_def.OP_LD_128}LD_128)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I8_R1, size = 8}LEA expression ',' I8 ',' R1)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I8_R2, size = 8}LEA expression ',' I8 ',' R2)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I8_R3, size = 8}LEA expression ',' I8 ',' R3)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I8_R4, size = 8}LEA expression ',' I8 ',' R4)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I8_R5, size = 8}LEA expression ',' I8 ',' R5)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I16_R1, size = 16}LEA expression ',' I16 ',' R1)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I16_R2, size = 16}LEA expression ',' I16 ',' R2)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I16_R3, size = 16}LEA expression ',' I16 ',' R3)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I16_R4, size = 16}LEA expression ',' I16 ',' R4)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I16_R5, size = 16}LEA expression ',' I16 ',' R5)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I32_R1, size = 32}LEA expression ',' I32 ',' R1)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I32_R2, size = 32}LEA expression ',' I32 ',' R2)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I32_R3, size = 32}LEA expression ',' I32 ',' R3)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I32_R4, size = 32}LEA expression ',' I32 ',' R4)
+  | %space (?E{t_def.OpI, op = t_def.OP_LEA_EXPR_I32_R5, size = 32}LEA expression ',' I32 ',' R5)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_SI8}LE SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_SI16}LE SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_SI32}LE SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_SI64}LE SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_SI128}LE SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_UI8}LE UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_UI16}LE UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_UI32}LE UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_UI64}LE UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_UI128}LE UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_F32}LE F32)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_F64}LE F64)
+  | %space (?E{t_def.Op, op = t_def.OP_LE_F128}LE F128)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_SI8}LT SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_SI16}LT SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_SI32}LT SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_SI64}LT SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_SI128}LT SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_UI8}LT UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_UI16}LT UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_UI32}LT UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_UI64}LT UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_UI128}LT UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_F32}LT F32)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_F64}LT F64)
+  | %space (?E{t_def.Op, op = t_def.OP_LT_F128}LT F128)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_SI8}MOD SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_SI16}MOD SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_SI32}MOD SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_SI64}MOD SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_SI128}MOD SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_UI8}MOD UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_UI16}MOD UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_UI32}MOD UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_UI64}MOD UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_UI128}MOD UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_SI8}MOD_R SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_SI16}MOD_R SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_SI32}MOD_R SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_SI64}MOD_R SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_SI128}MOD_R SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_UI8}MOD_R UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_UI16}MOD_R UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_UI32}MOD_R UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_UI64}MOD_R UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_MOD_R_UI128}MOD_R UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R0_R1}MOV R0 ',' R1)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R0_R2}MOV R0 ',' R2)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R0_R3}MOV R0 ',' R3)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R0_R4}MOV R0 ',' R4)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R0_R5}MOV R0 ',' R5)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R1_R0}MOV R1 ',' R0)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R2_R0}MOV R2 ',' R0)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R3_R0}MOV R3 ',' R0)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R4_R0}MOV R4 ',' R0)
+  | %space (?E{t_def.Op, op = t_def.OP_MOV_R5_R0}MOV R5 ',' R0)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_I8}MUL I8)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_I16}MUL I16)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_I32}MUL I32)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_I64}MUL I64)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_I128}MUL I128)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_F32}MUL F32)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_F64}MUL F64)
+  | %space (?E{t_def.Op, op = t_def.OP_MUL_F128}MUL F128)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_I8}NEG I8)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_I16}NEG I16)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_I32}NEG I32)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_I64}NEG I64)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_I128}NEG I128)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_F32}NEG F32)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_F64}NEG F64)
+  | %space (?E{t_def.Op, op = t_def.OP_NEG_F128}NEG F128)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_I8}NE I8)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_I16}NE I16)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_I32}NE I32)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_I64}NE I64)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_I128}NE I128)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_F32}NE F32)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_F64}NE F64)
+  | %space (?E{t_def.Op, op = t_def.OP_NE_F128}NE F128)
+  | %space (?E{t_def.Op, op = t_def.OP_NOT_I8}NOT I8)
+  | %space (?E{t_def.Op, op = t_def.OP_NOT_I16}NOT I16)
+  | %space (?E{t_def.Op, op = t_def.OP_NOT_I32}NOT I32)
+  | %space (?E{t_def.Op, op = t_def.OP_NOT_I64}NOT I64)
+  | %space (?E{t_def.Op, op = t_def.OP_NOT_I128}NOT I128)
+  | %space (?E{t_def.Op, op = t_def.OP_OR_I8}OR I8)
+  | %space (?E{t_def.Op, op = t_def.OP_OR_I16}OR I16)
+  | %space (?E{t_def.Op, op = t_def.OP_OR_I32}OR I32)
+  | %space (?E{t_def.Op, op = t_def.OP_OR_I64}OR I64)
+  | %space (?E{t_def.Op, op = t_def.OP_OR_I128}OR I128)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_8}POP_8)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_16}POP_16)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_32}POP_32)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_64}POP_64)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_128}POP_128)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_R1}POP R1)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_R2}POP R2)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_R3}POP R3)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_R4}POP R4)
+  | %space (?E{t_def.Op, op = t_def.OP_POP_R5}POP R5)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_8}PUSH_8)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_16}PUSH_16)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_32}PUSH_32)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_64}PUSH_64)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_128}PUSH_128)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_R1}PUSH R1)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_R2}PUSH R2)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_R3}PUSH R3)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_R4}PUSH R4)
+  | %space (?E{t_def.Op, op = t_def.OP_PUSH_R5}PUSH R5)
+  | %space (?E{t_def.Op, op = t_def.OP_RET}RET)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_I8}SHL I8)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_I16}SHL I16)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_I32}SHL I32)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_I64}SHL I64)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_I128}SHL I128)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_R_I8}SHL_R I8)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_R_I16}SHL_R I16)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_R_I32}SHL_R I32)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_R_I64}SHL_R I64)
+  | %space (?E{t_def.Op, op = t_def.OP_SHL_R_I128}SHL_R I128)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_SI8}SHR SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_SI16}SHR SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_SI32}SHR SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_SI64}SHR SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_SI128}SHR SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_UI8}SHR UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_UI16}SHR UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_UI32}SHR UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_UI64}SHR UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_UI128}SHR UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_SI8}SHR_R SI8)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_SI16}SHR_R SI16)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_SI32}SHR_R SI32)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_SI64}SHR_R SI64)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_SI128}SHR_R SI128)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_UI8}SHR_R UI8)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_UI16}SHR_R UI16)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_UI32}SHR_R UI32)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_UI64}SHR_R UI64)
+  | %space (?E{t_def.Op, op = t_def.OP_SHR_R_UI128}SHR_R UI128)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_8}ST_8)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_16}ST_16)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_32}ST_32)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_64}ST_64)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_128}ST_128)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_R_8}ST_R_8)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_R_16}ST_R_16)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_R_32}ST_R_32)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_R_64}ST_R_64)
+  | %space (?E{t_def.Op, op = t_def.OP_ST_R_128}ST_R_128)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_I8}SUB I8)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_I16}SUB I16)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_I32}SUB I32)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_I64}SUB I64)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_I128}SUB I128)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_F32}SUB F32)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_F64}SUB F64)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_F128}SUB F128)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_I8}SUB_R I8)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_I16}SUB_R I16)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_I32}SUB_R I32)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_I64}SUB_R I64)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_I128}SUB_R I128)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_F32}SUB_R F32)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_F64}SUB_R F64)
+  | %space (?E{t_def.Op, op = t_def.OP_SUB_R_F128}SUB_R F128)
+  | %space (?E{t_def.Op, op = t_def.OP_TRAP}TRAP)
+  | %space (?E{t_def.Op, op = t_def.OP_XOR_I8}XOR I8)
+  | %space (?E{t_def.Op, op = t_def.OP_XOR_I16}XOR I16)
+  | %space (?E{t_def.Op, op = t_def.OP_XOR_I32}XOR I32)
+  | %space (?E{t_def.Op, op = t_def.OP_XOR_I64}XOR I64)
+  | %space (?E{t_def.Op, op = t_def.OP_XOR_I128}XOR I128)
+  ;
+
+/* if file ends with NEWLINE, we will see a blank input_line after it */
+input_file
+  : input_line
+  | input_file NEWLINE input_line
+  ;
+
+%%
+
+def yyerror(loc, msg):
+  print(f'{in_file:s}({loc.first_line:d},{loc.first_column:d}..{loc.last_line:d},{loc.last_column:d}): {msg:s}')
+  sys.exit(1)
+