diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-01-21 14:58:17 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-01-21 14:58:17 -0400 |
commit | 101a518db2c0d57ece4fe95269917b2c0c1ca2e7 (patch) | |
tree | 16a8fae579ea83960ec69222221954d8a005fd43 | |
parent | a1cdb3e59112eaa11b8639c8ab7ed3f1ef088515 (diff) |
sux.h: Use conditional branch code for unconditional
jumps.
This gets rid of some code duplication, and is also
how `bra` was implemented anyway. So, might as well use
it for unconditional jumps too.
-rw-r--r-- | sux.h | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1825,15 +1825,14 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size, t(0, 0x00000000, 0x00000000, 0x02000000, 0x02100110, 0x02000000, 0x00000000, 0x00000000, 0x00000000) { --tmp; } /* dec */ \ /* Store modified value into memory. */ \ t(0, 0x00100000, 0x04101400, 0x00100100, 0x10100100, 0x01001000, 0x51005000, 0x51005000, 0x01001000) { write_value(cpu, tmp, addr, rs, inc_clk, 1); } \ - /* Stack related operations, and unconditional jumps. */ \ + /* Stack related operations. */ \ t(7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40004200, 0x00000000, 0x00000000, 0x00000000) { rs = 0; } /* php, plp, and interrupts. */ \ t(0, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000001, 0x00000000, 0x00000000, 0x00000000) { *reg = pull(cpu, rs, thread); } /* Pull value off the stack. */ \ t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00010000, 0x00000000, 0x00000000) { cpu->pc = pull(cpu, (rs) ? rs : 7, thread); } /* Pull return address off the stack. */ \ t(7, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000200, 0x00000001, 0x00010000, 0x00000000) { push(cpu, cpu->pc, (rs) ? rs : 7, thread); } /* Push return address onto the stack. */ \ - t(7, 0x00001000, 0x10000000, 0x00000000, 0x00000000, 0x00000200, 0x00000001, 0x00010001, 0x00010000) { cpu->pc = addr; } /* Set program counter to supplied address. */ \ t(7, 0x00004000, 0x00004000, 0x00004000, 0x00004000, 0x00004200, 0x00000000, 0x00000000, 0x00000000) { push(cpu, *reg, rs, thread); } /* Push value onto the stack. */ \ /* Setting/Testing/Clearing flags, and bitwise operations. */ \ - t(7, 0x00010001, 0x00010001, 0x00010001, 0x00010001, 0x00010200, 0x00000200, 0x02000200, 0x02000200) { tmp = 1; } \ + t(7, 0x00011001, 0x10010001, 0x00010001, 0x00010001, 0x00010201, 0x00010201, 0x02010201, 0x02010200) { tmp = 1; } \ t(0, 0x00000000, 0x00000001, 0x00010000, 0x00000001, 0x00010000, 0x00000000, 0x00000000, 0x00000000) { tmp <<= 1; } \ t(7, 0x00000001, 0x00010000, 0x00000000, 0x00000001, 0x00010200, 0x00000200, 0x02000200, 0x00000000) { tmp <<= 2; } \ t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00010000, 0x00000000, 0x00000000, 0x00000000) { tmp <<= 4; } \ @@ -1842,8 +1841,9 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size, t(0, 0x00000001, 0x00010001, 0x00010001, 0x00010001, 0x00010000, 0x00220222, 0x00000200, 0x00000200) { tmp &= *reg; } /* AND, and clear/test flag. */ \ t(0, 0x00000000, 0x00000000, 0x00000000, 0x00220022, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { tmp ^= *reg; } /* xor. */ \ /* Conditional branches. */ \ - t(0, 0x00010000, 0x00010000, 0x00010000, 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { if (tmp) { cpu->pc = addr; } } /* Flag is 1. */ \ - t(0, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000) { if (!tmp) { cpu->pc = addr; } } /* Flag is 0. */ \ + /* Set program counter to supplied address */ \ + t(7, 0x00011000, 0x10010000, 0x00010000, 0x00010001, 0x00000201, 0x00010001, 0x00010001, 0x00010000) { if (tmp) { cpu->pc = addr; } } /* If flag is 1. */ \ + t(0, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000) { if (!tmp) { cpu->pc = addr; } } /* If flag is 0. */ \ } #undef ORTHO_1CC |