diff --git a/header/instruction_table.h b/header/instruction_table.h new file mode 100644 index 0000000..0c6bca7 --- /dev/null +++ b/header/instruction_table.h @@ -0,0 +1,25 @@ +#ifndef _INSTRUCTION_TABLE_H_ +#define _INSTRUCTION_TABLE_H_ + +#include "../header/shash/shash.h" +#include + +// Create a hashtable that contains +shash_hashtable_t create_instruction_information_hastable(void); + +typedef struct +{ + unsigned int requires_adress; + unsigned int supports_adress_label; + u_int8_t opcode; +} instruction_information_t; + +typedef struct +{ + char *name; + unsigned int requires_adress; + unsigned int supports_adress_label; + u_int8_t opcode; +} instruction_information_config_t; + +#endif diff --git a/src/instruction_table.c b/src/instruction_table.c new file mode 100644 index 0000000..94171ba --- /dev/null +++ b/src/instruction_table.c @@ -0,0 +1,68 @@ +#include "../header/instruction_table.h" +#include "../header/shash/shash.h" +#include + +shash_hashtable_t create_instruction_information_hastable(void) +{ + shash_hashtable_t instruction_table; + + // Change this code if you want to configure changes to the instruction format + instruction_information_config_t config[] = { + {.name = "INC", + .requires_adress = 1, + .supports_adress_label = 0, + .opcode = 0b0001}, + + {.name = "OUT", + .requires_adress = 1, + .supports_adress_label = 0, + .opcode = 0b0010}, + + {.name = "LDA", + .requires_adress = 1, + .supports_adress_label = 0, + .opcode = 0b0011}, + + {.name = "STA", + .requires_adress = 1, + .supports_adress_label = 0, + .opcode = 0b0100}, + + {.name = "INC", + .requires_adress = 0, + .supports_adress_label = 0, + .opcode = 0b0101}, + + {.name = "DEC", + .requires_adress = 0, + .supports_adress_label = 0, + .opcode = 0b0110}, + + {.name = "JPP", + .requires_adress = 1, + .supports_adress_label = 1, + .opcode = 0b0111}, + + {.name = "JPZ", + .requires_adress = 1, + .supports_adress_label = 1, + .opcode = 0b1000}, + + {.name = "JPN", + .requires_adress = 1, + .supports_adress_label = 1, + .opcode = 0b1001}, + + {.name = "JPU", + .requires_adress = 1, + .supports_adress_label = 1, + .opcode = 0b1010}, + + {.name = "EOJ", + .requires_adress = 0, + .supports_adress_label = 0, + .opcode = 0b1011}, + {0} + }; + return instruction_table; +}