tis100

Reimplementation of Zachtronics TIS-100 as a TUI game
git clone https://git.sinitax.com/sinitax/tis100
Log | Files | Refs | sfeed.txt

commit 565355c91601043b5e599bc7e79ee7f1d3140e21
parent 5adac1252fb065ecb3e308152f6b178b303d6189
Author: Louis Burda <quent.burda@gmail.com>
Date:   Wed, 26 Jul 2023 07:41:11 +0200

Make BAK register unaddressable

Diffstat:
Masm.c | 16++++++++--------
Mtpu.c | 10++--------
Mtpu.h | 4++--
3 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/asm.c b/asm.c @@ -17,8 +17,8 @@ enum asm_tok { TOK_STDIN, TOK_STDOUT, TOK_TPU, TOK_END, /* Operands (order like OP_*) */ - TOK_ACC, TOK_BAK, TOK_NIL, TOK_LEFT, TOK_RIGHT, - TOK_UP, TOK_DOWN, TOK_ANY, TOK_LAST, TOK_LIT, TOK_NAME, + TOK_ACC, TOK_NIL, TOK_LEFT, TOK_RIGHT, TOK_UP, TOK_DOWN, + TOK_ANY, TOK_LAST, TOK_LIT, TOK_NAME, /* Instructions (order like INST_*) */ TOK_NOP, TOK_MOV, TOK_SWP, TOK_SAV, TOK_ADD, TOK_SUB, @@ -42,8 +42,8 @@ static const char *tok_strs[] = { "stdin", "stdout", "tpu", "end", /* Operands (order like OP_*) */ - "acc", "bak", "nil", "left", "right", - "up", "down", "any", "last", NULL, NULL, + "acc", "nil", "left", "right", "up", "down", + "any", "last", NULL, NULL, /* Instructions (order like INST_*) */ "nop", "mov", "swp", "sav", "add", "sub", @@ -58,8 +58,8 @@ static const char *tok_reprs[] = { "'STDIN'", "'STDOUT'", "'TPU'", "'END'", /* Operands (order like OP_*) */ - "'ACC'", "'BAK'", "'NIL'", "'LEFT'", "'RIGHT'", - "'UP'", "'DOWN'", "'ANY'", "'LAST'", "<LIT>", "<NAME>", + "'ACC'", "'NIL'", "'LEFT'", "'RIGHT'", "'UP'", "'DOWN'", + "'ANY'", "'LAST'", "<LIT>", "<NAME>", /* Instructions (order like INST_*) */ "'NOP'", "'MOV'", "'SWP'", "'SAV'", "'ADD'", "'SUB'", @@ -354,7 +354,7 @@ tis_load(struct tis *tis, const char *filepath) if (!tpu) goto disallowed; inst = tok_to_inst(tok); - optok = tok_next_in(&tokenizer, TOK_ACC, TOK_BAK, + optok = tok_next_in(&tokenizer, TOK_ACC, TOK_NIL, TOK_LEFT, TOK_RIGHT, TOK_UP, TOK_DOWN, TOK_ANY, TOK_LAST, TOK_LIT, TOK_NAME, TOK_NL, -1); if (optok == TOK_NL) { @@ -365,7 +365,7 @@ tis_load(struct tis *tis, const char *filepath) } op1 = tok_to_op(&tokenizer, optok); - optok = tok_next_in(&tokenizer, TOK_ACC, TOK_BAK, + optok = tok_next_in(&tokenizer, TOK_ACC, TOK_NIL, TOK_LEFT, TOK_RIGHT, TOK_UP, TOK_DOWN, TOK_ANY, TOK_LAST, TOK_LIT, TOK_NAME, TOK_NL, -1); if (optok == TOK_NL) { diff --git a/tpu.c b/tpu.c @@ -21,8 +21,8 @@ const char *inst_reprs[] = { }; const char *op_reprs[] = { - "ACC", "BAK", "NIL", "LEFT", "RIGHT", - "UP", "DOWN", "ANY", "LAST", "LIT", "<NAME>" + "ACC", "NIL", "LEFT", "RIGHT", "UP", "DOWN", + "ANY", "LAST", "LIT", "<NAME>" }; static enum tpu_port_dir @@ -363,9 +363,6 @@ tpu_exec_get(struct tpu *tpu, struct tpu_inst_op *op) case OP_ACC: lit = tpu->acc; break; - case OP_BAK: - lit = tpu->bak; - break; case OP_NIL: lit = 0; break; @@ -404,9 +401,6 @@ tpu_exec_put(struct tpu *tpu, struct tpu_inst_op *op, uint8_t lit) case OP_ACC: tpu->acc = lit; break; - case OP_BAK: - tpu->bak = lit; - break; case OP_NIL: break; case OP_LEFT: case OP_RIGHT: case OP_UP: case OP_DOWN: diff --git a/tpu.h b/tpu.h @@ -22,8 +22,8 @@ enum tpu_inst_type { }; enum tpu_inst_op_type { - OP_ACC, OP_BAK, OP_NIL, OP_LEFT, OP_RIGHT, - OP_UP, OP_DOWN, OP_ANY, OP_LAST, OP_LIT, OP_LABEL + OP_ACC, OP_NIL, OP_LEFT, OP_RIGHT, OP_UP, OP_DOWN, + OP_ANY, OP_LAST, OP_LIT, OP_LABEL }; enum tpu_port_dir {