From 8824efc38100d3188d7f79f3669f52ca15581b80 Mon Sep 17 00:00:00 2001 From: Alvin Cheng Date: Wed, 25 Dec 2024 16:10:04 +1100 Subject: [PATCH] Added dummy instruction enum Previously, the assembler used the final instruction in the enum as a "indicator" for when the direcives start. This brings out a very very obvious issue where if a developer fails to change the `IS_DIRECTIVE` macro can make the assembler think that a instruction that is valid as a directive. Therefore, a new "dummy" has been added and all directives must be **after** the dummy --- libjas/include/instruction.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libjas/include/instruction.h b/libjas/include/instruction.h index 98f968c..bbd15a4 100644 --- a/libjas/include/instruction.h +++ b/libjas/include/instruction.h @@ -47,7 +47,7 @@ typedef struct instr_encode_table instr_encode_table_t; * Please update this macro if more directives and/or instructions * are added/supported in this enum list (In the future). */ -#define INSTR_DIRECTIVE(i) ((uint8_t)i > (uint8_t)INSTR_SYSCALL) +#define INSTR_DIRECTIVE(i) ((uint8_t)i > (uint8_t)INSTR_DUMMY) enum instructions { INSTR_MOV, @@ -83,6 +83,8 @@ enum instructions { INSTR_INT, INSTR_SYSCALL, + INSTR_DUMMY, + // Directives: INSTR_DIR_WRT_BUF, // A buffer_t to write to