summaryrefslogtreecommitdiffstats
path: root/tpu.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-07-25 00:47:01 +0200
committerLouis Burda <quent.burda@gmail.com>2023-07-25 00:47:01 +0200
commit40d8eb449ed072b47bfbe953a191708f761c53a0 (patch)
tree63ed15404eb3acd99a9ca0f77654b2c97efe54d9 /tpu.h
parent29894d56e144223629e558070cbc52080e21342e (diff)
downloadtis100-40d8eb449ed072b47bfbe953a191708f761c53a0.tar.gz
tis100-40d8eb449ed072b47bfbe953a191708f761c53a0.zip
Reimplement value passing and improve curses ui
Diffstat (limited to 'tpu.h')
-rw-r--r--tpu.h36
1 files changed, 30 insertions, 6 deletions
diff --git a/tpu.h b/tpu.h
index 79155f8..98c9ad1 100644
--- a/tpu.h
+++ b/tpu.h
@@ -62,20 +62,26 @@ struct tpu_port {
struct tpu *dst_tpu;
enum tpu_port_type type;
struct tpu_port *dst_port;
- bool attached, reading;
+ bool clr_post_run;
+ bool reading, writing;
+ bool attached;
int in, out;
};
struct tpu {
enum tpu_status status;
- struct label_map labels;
- struct tpu_port ports[4];
- int read_port;
- uint8_t acc, bak;
size_t x, y;
+
+ struct tpu_port ports[4];
+ int io_port;
int last;
+ size_t steps;
+ size_t idle_steps;
+
+ uint8_t acc, bak;
uint8_t pc;
+ struct label_map labels;
struct tpu_inst insts[TPU_MAX_INST];
size_t inst_cnt;
};
@@ -90,11 +96,20 @@ struct tpu_map {
struct tpu_map_link *buckets[TPU_MAP_BUCKETS];
};
+struct tis {
+ struct tpu_map tpu_map;
+ struct tpu_port stdin_port;
+ struct tpu_port stdout_port;
+};
+
void label_map_init(struct label_map *map);
void label_map_deinit(struct label_map *map);
bool label_map_add(struct label_map *map, const char *name, size_t pc);
size_t label_map_get(struct label_map *map, const char *name);
+void tpu_port_init(struct tpu_port *port);
+void tpu_port_deinit(struct tpu_port *port);
+
void tpu_init(struct tpu *tpu);
void tpu_deinit(struct tpu *tpu);
struct tpu_inst *tpu_current_inst(struct tpu *tpu);
@@ -107,9 +122,18 @@ bool tpu_add_inst(struct tpu *tpu, enum tpu_inst_type inst,
void tpu_clear_ports(struct tpu *tpu);
enum tpu_status tpu_exec_mov(struct tpu *tpu, struct tpu_inst *inst);
enum tpu_status tpu_exec(struct tpu *tpu, struct tpu_inst *inst);
-void tpu_step(struct tpu *tpu);
+enum tpu_status tpu_step(struct tpu *tpu);
void tpu_map_init(struct tpu_map *map);
void tpu_map_deinit(struct tpu_map *map);
void tpu_map_add(struct tpu_map *map, struct tpu *tpu);
struct tpu *tpu_map_get(struct tpu_map *map, size_t x, size_t y);
+
+void tis_init(struct tis *tis);
+void tis_deinit(struct tis *tis);
+bool tis_step(struct tis *tis);
+
+extern const char *dir_reprs[];
+extern const char *status_reprs[];
+extern const char *inst_reprs[];
+extern const char *op_reprs[];