From 101a518db2c0d57ece4fe95269917b2c0c1ca2e7 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 21 Jan 2022 14:58:17 -0400 Subject: 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. --- sux.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sux.h b/sux.h index 1358192..e042569 100644 --- a/sux.h +++ b/sux.h @@ -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 -- cgit v1.2.3-13-gbd6f