diff options
Diffstat (limited to 'instruction.h')
-rw-r--r-- | instruction.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/instruction.h b/instruction.h index 1053936..5a268d3 100644 --- a/instruction.h +++ b/instruction.h @@ -202,13 +202,26 @@ enum { #define INSTR_ERR -1 /* Error in instruction */ #define PC_INC_NORMAL 0 /* Normal PC increment after instruction */ #define PC_INC_BY_INSTR 1 /* PC got incremented by instruction */ -#define INSTR_EXECPTION 2 /* Instruction generated an exception */ +#define INSTR_EXCEPTION_BASE 255 /* Instruction generated an exception */ + +#define EXCEPTION(cause) (INSTR_EXCEPTION_BASE + (cause)) +#define IS_EXCEPTION(ret) ((ret) >= INSTR_EXCEPTION_BASE) +#define EXCEPTION_CAUSE(ret) ((uint8_t)((ret) - INSTR_EXCEPTION_BASE)) /* Forward declaration */ struct nios2; typedef int (*instruction_handler)(struct nios2 *cpu, uint32_t opcode); +struct instruction { + const char *name; + instruction_handler handler; +}; + +#define INSTRUCTION(name) { __stringify(name), name } +#define INSTRUCTION_NOP(name) { __stringify(name), nop } +#define INSTRUCTION_UNIMPLEMENTED(name) { __stringify(name), unimplemented } + extern instruction_handler instruction_get_handler(uint32_t code); extern const char *instruction_get_string(uint32_t code); |