summaryrefslogtreecommitdiff
path: root/instruction.h
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2010-11-17 10:02:56 +0100
committerTobias Klauser <tklauser@distanz.ch>2010-11-17 10:02:56 +0100
commit7b796fda06442a469f9109828ceb57847920887f (patch)
treeb80af0e35ac9088e503366550ce1db499cc6db6f /instruction.h
parentfc6515ef027d94412228875095708b949b801496 (diff)
Reorganize instruction table handling, use return value for exceptions
Diffstat (limited to 'instruction.h')
-rw-r--r--instruction.h15
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);