/* AVM ISA v1 — Shared type definitions for C port */ #ifndef AVM_TYPES_H #define AVM_TYPES_H #include #include typedef enum { TY_Q0, TY_Q16, TY_BOOL } AvmTy; typedef struct { AvmTy ty; union { int32_t i; bool b; } val; } AnyVal; typedef enum { OP_PUSH_Q16, OP_PUSH_BOOL, OP_PUSH_Q0, OP_POP, OP_DUP, OP_SWAP, OP_LOAD, OP_STORE, OP_JUMP, OP_JUMP_IF, OP_PRIM, OP_HALT } OpCode; typedef enum { PRIM_ADD_Q0, PRIM_SUB_Q0, PRIM_ADD_Q16, PRIM_SUB_Q16, PRIM_MUL_Q16, PRIM_DIV_Q16, PRIM_LT_Q16, PRIM_EQ_Q16, PRIM_AND, PRIM_OR, PRIM_NOT } PrimCode; typedef struct { OpCode op; int32_t arg; bool arg2; } Instr; typedef struct { int pc; AnyVal stack[1024]; int sp; AnyVal locals[256]; bool local_set[256]; bool halted; } State; #endif