Skip to content

Commit

Permalink
Added dummy instruction enum
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cheng-alvin committed Dec 25, 2024
1 parent c8d9a6f commit 8824efc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libjas/include/instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -83,6 +83,8 @@ enum instructions {
INSTR_INT,
INSTR_SYSCALL,

INSTR_DUMMY,

// Directives:
INSTR_DIR_WRT_BUF, // A buffer_t to write to

Expand Down

0 comments on commit 8824efc

Please sign in to comment.