diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-07-26 18:02:50 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-07-26 18:03:06 +0200 |
| commit | d9dd10cd6a69f6da102814ebefe1d7ad2a32a020 (patch) | |
| tree | 44ffd669d103100bd136508a5b79d2b12ddb5465 /tpu.c | |
| parent | ed666b4fd98ad168f735b814cf74e77ef5c52794 (diff) | |
| download | tis100-d9dd10cd6a69f6da102814ebefe1d7ad2a32a020.tar.gz tis100-d9dd10cd6a69f6da102814ebefe1d7ad2a32a020.zip | |
Revert adding AND/NOT
Diffstat (limited to 'tpu.c')
| -rw-r--r-- | tpu.c | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -16,8 +16,8 @@ const char *status_reprs[] = { }; const char *inst_reprs[] = { - "NOP", "MOV", "SWP", "SAV", "ADD", "SUB", "NEG", - "NOT", "AND", "JMP", "JEZ", "JNZ", "JGZ", "JLZ", "JRO" + "NOP", "MOV", "SWP", "SAV", "ADD", "SUB", + "NEG", "JMP", "JEZ", "JNZ", "JGZ", "JLZ", "JRO" }; const char *op_reprs[] = { @@ -277,19 +277,19 @@ tpu_set_inst(struct tpu *tpu, uint8_t pc, enum tpu_inst_type inst_type, inst->ops[1] = op2; switch (inst->type) { - case INST_NOP: case INST_SAV: case INST_SWP: - case INST_NEG: case INST_NOT: + case INST_NOP: case INST_SAV: + case INST_SWP: case INST_NEG: if (inst->opcnt != 0) return false; break; - case INST_ADD: case INST_SUB: case INST_AND: + case INST_ADD: case INST_SUB: if (inst->opcnt != 1) return false; - if (inst->opcnt == OP_LABEL) return false; break; case INST_JRO: if (inst->opcnt != 1) return false; if (inst->ops[0].type != OP_LIT) return false; break; case INST_JMP: case INST_JEZ: case INST_JNZ: + case INST_JGZ: case INST_JLZ: if (inst->opcnt != 1) return false; if (inst->ops[0].type != OP_LABEL) return false; break; @@ -477,16 +477,6 @@ tpu_exec(struct tpu *tpu, struct tpu_inst *inst) tpu->acc = -tpu->acc; tpu->pc += 1; return STATUS_RUN; - case INST_NOT: - tpu->acc = ~tpu->acc; - tpu->pc += 1; - return STATUS_RUN; - case INST_AND: - val = tpu_exec_get(tpu, &inst->ops[0]); - if (val < 0) return STATUS_READ; - tpu->acc &= (uint8_t) val; - tpu->pc += 1; - return STATUS_RUN; case INST_JMP: tpu_jmp_label(tpu, inst->ops[0].val.label); return STATUS_RUN; @@ -502,6 +492,18 @@ tpu_exec(struct tpu *tpu, struct tpu_inst *inst) else tpu->pc += 1; return STATUS_RUN; + case INST_JGZ: + if (tpu->acc > 0) + tpu_jmp_label(tpu, inst->ops[0].val.label); + else + tpu->pc += 1; + return STATUS_RUN; + case INST_JLZ: + if (tpu->acc < 0) + tpu_jmp_label(tpu, inst->ops[0].val.label); + else + tpu->pc += 1; + return STATUS_RUN; case INST_JRO: tpu->pc += inst->ops[0].val.lit; if (tpu->pc >= tpu->inst_cnt) tpu->pc = 0; |
