diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-07-26 18:38:11 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-07-26 18:38:11 +0200 |
| commit | 130db985e5594204897ad28d7463e7e9b5ef94c7 (patch) | |
| tree | b5c825de9374b82713b642ab423ad4e18b7fd00b /tpu.h | |
| parent | d9dd10cd6a69f6da102814ebefe1d7ad2a32a020 (diff) | |
| download | tis100-130db985e5594204897ad28d7463e7e9b5ef94c7.tar.gz tis100-130db985e5594204897ad28d7463e7e9b5ef94c7.zip | |
Restrict assembly input to fit game spec
Diffstat (limited to 'tpu.h')
| -rw-r--r-- | tpu.h | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -6,7 +6,8 @@ #define TPU_MAP_BUCKETS 64 #define LABEL_MAP_BUCKETS 64 -#define TPU_MAX_INST 256 +#define TPU_MAX_INST_CNT 15 +#define TPU_MAX_INST_LEN 18 /* enum order is important ! */ @@ -35,7 +36,7 @@ enum tpu_port_type { }; union tpu_inst_op_val { - uint8_t lit; + int lit; char *label; }; @@ -46,7 +47,7 @@ struct label_map_link { }; struct label_map { - char *labels[TPU_MAX_INST]; /* borrowed from label_map_links */ + char *labels[TPU_MAX_INST_CNT]; /* borrowed from label_map_links */ struct label_map_link *buckets[LABEL_MAP_BUCKETS]; }; @@ -82,11 +83,12 @@ struct tpu { size_t steps; size_t idle_steps; - uint8_t acc, bak; - uint8_t pc; + int acc, bak; + int pc; + struct label_map label_map; - struct tpu_inst insts[TPU_MAX_INST]; - size_t inst_cnt; + struct tpu_inst insts[TPU_MAX_INST_CNT]; + size_t inst_cnt, label_cnt; }; struct tpu_map_link { @@ -118,9 +120,9 @@ void tpu_deinit(struct tpu *tpu); struct tpu_inst *tpu_current_inst(struct tpu *tpu); void tpu_init_ports(struct tpu *tpu, struct tpu_map *map); void tpu_update_ports(struct tpu *tpu); -bool tpu_set_inst(struct tpu *tpu, uint8_t pc, enum tpu_inst_type inst, +bool tpu_set_inst(struct tpu *tpu, int pc, enum tpu_inst_type inst, unsigned opcnt, struct tpu_inst_op op1, struct tpu_inst_op op2); -bool tpu_add_inst(struct tpu *tpu, enum tpu_inst_type inst, +struct tpu_inst *tpu_add_inst(struct tpu *tpu, enum tpu_inst_type inst, unsigned opcnt, struct tpu_inst_op op1, struct tpu_inst_op op2); void tpu_clear_ports(struct tpu *tpu); enum tpu_status tpu_exec_mov(struct tpu *tpu, struct tpu_inst *inst); |
