diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-12-08 17:56:02 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-12-08 18:07:51 -0500 |
commit | 28202af458a42e83f06415fa33d193258535a86d (patch) | |
tree | 7c285293af7679c734619c007366f4487eeaca72 /sux.h | |
parent | a2dac7cb48605eec322ca825e39ff709240c17b7 (diff) |
- Fixed yet another bug with the ortho extension.
Diffstat (limited to 'sux.h')
-rw-r--r-- | sux.h | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -533,14 +533,20 @@ static /*inline*/ uint64_t get_ortho_addr(struct sux *cpu, uint8_t prefix, uint6 } op[i].scale = (inst_size == 2) ? tmp.u8[0] : 0; } - if (addr_size != 0xFF || (rs && op[i].id == MEM_IMM)) { - inst_size = (addr_size != 0xFF) ? addr_size+1 : rs; + if (addr_size != 0xFF) { + inst_size = addr_size+1; op[i].value = read_value(cpu, 0, address, inst_size-1, inc_clk, 0); value[i] = op[i].value; if (inc_pc) { address += inst_size; } } + if (rs && op[i].id == MEM_IMM) { + value[i] = address; + if (inc_pc) { + address += rs; + } + } if (is_rind) { for (int j = 0; j < 2 && op[i].rind[j] != 0xFF; j++) { uint64_t reg; @@ -900,7 +906,7 @@ static /*inline*/ void exec_ortho_inst(struct sux *cpu, uint8_t opcode, uint8_t operand op[2]; cpu->pc = get_ortho_addr(cpu, prefix, cpu->pc, op, address, op_type, op_id, 1, 1, thread); if (op[1].type) { - src = read_value(cpu, 0, op[1].value, size, 1, 1); + src = read_value(cpu, 0, (op[1].id != MEM_IMM) ? op[1].value : address[1], size, 1, 1); } else { switch (op[1].id) { case REG_A : src = cpu->a; break; @@ -922,7 +928,9 @@ static /*inline*/ void exec_ortho_inst(struct sux *cpu, uint8_t opcode, uint8_t } } if (op[0].type) { - dst = read_value(cpu, 0, op[0].value, size, 1, 1); + if (op[0].id != MEM_IMM) { + dst = read_value(cpu, 0, op[0].value, size, 1, 1); + } } else { switch (op[0].id) { case REG_A : dst = cpu->a; break; @@ -1043,9 +1051,10 @@ static /*inline*/ void exec_ortho_inst(struct sux *cpu, uint8_t opcode, uint8_t case ORTHO_1CC(SET, VC): dst = set(cpu, !getflag(V), thread); break; } - if (op[0].type) { - write_value(cpu, dst, op[0].value, size, 1, 1); + if (op[0].id != MEM_IMM) { + write_value(cpu, dst, op[0].value, size, 1, 1); + } } else { switch (op[0].id) { case REG_A : cpu->a = dst; break; @@ -1068,7 +1077,9 @@ static /*inline*/ void exec_ortho_inst(struct sux *cpu, uint8_t opcode, uint8_t } if (isdiv) { if (op[1].type) { - write_value(cpu, rem, op[1].value, size, 1, 1); + if (op[0].id != MEM_IMM) { + write_value(cpu, dst, op[1].value, size, 1, 1); + } } else { switch (op[1].id) { case REG_A : cpu->a = rem; break; |