aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-09 00:33:47 +1300
committerAndrew Chambers <[email protected]>2021-10-09 00:33:47 +1300
commitee80372abea5d9a2ff100f1ddb8be08470cc272d (patch)
tree4904b7d3deb3ae5289acaa4c4461a78d45caabf6 /main.c
parenta8cc59047d02d5c5b352b10a630f73249dc24a5d (diff)
Refactor.
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.c b/main.c
index cb6c685..9fc57f6 100644
--- a/main.c
+++ b/main.c
@@ -439,15 +439,16 @@ static void assemblebasicop(Instr *instr, uint8_t opcode, uint8_t immreg) {
}
static void assemblexchg(Instr *xchg) {
- static uint8_t variant2op[14] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x86,
- 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87};
+ static uint8_t variant2op[18] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x86, 0x87, 0x87, 0x87, 0x86, 0x87,
+ 0x87, 0x87, 0x86, 0x87, 0x87, 0x87};
uint8_t opcode = variant2op[xchg->variant];
- if (xchg->variant <= 5) {
+ if (xchg->variant < 6) {
assembleplusr(opcode,
(xchg->variant % 2) ? xchg->src->kind : xchg->dst->kind);
} else {
/* Uses a pattern in the variant table. */
- uint8_t opsz = 1 << (((xchg->variant - 6) / 2) % 4);
+ uint8_t opsz = 1 << ((xchg->variant - 6) % 4);
assemblerrm(xchg, opcode, opsz);
}
}