summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-02-02 14:46:41 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2022-02-02 14:47:27 -0400
commit2bf356950e14d26885b9a87a274770216f6e99b7 (patch)
tree26e26d4ff148d75636cee555e22213626c723a45
parentdb1fafcfbad0ba8e10f130c09d47f0ebac869bfd (diff)
sux.h: Corrected some typos, and fixed some bugs in
the bitmasks.
-rw-r--r--sux.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/sux.h b/sux.h
index 3bee301..b344913 100644
--- a/sux.h
+++ b/sux.h
@@ -1823,14 +1823,14 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size,
t(7, 0x07561370, 0x17561570, 0x14161560, 0x10161160, 0x11161360, 0x51165161, 0x51175161, 0x01171160) { idx = 0; } /* Reset index. */ \
t(0, 0x00010001, 0x00010001, 0x00010001, 0x00010001, 0x00010000, 0x00000000, 0x00000000, 0x00000000) { addr = rel_addr(cpu, prefix, inc_clk, inc_pc); } /* Relative addressing (used by conditonal branches). */ \
/* Load Source. */ \
- t(0, 0x02220022, 0x03760576, 0x00220432, 0x00661076, 0x00660066, 0x04660066, 0x55665066, 0x04660066) { reg = &cpu->a; } /* Most operations use the accumulator as an operand */ \
- t(0, 0x05540354, 0x04000000, 0x04000200, 0x02000000, 0x10000000, 0x51005000, 0x00000000, 0x00100510) { reg = &cpu->b; } /* ldb, stb, cpb, inb, deb, tab */ \
- t(0, 0x00000000, 0x00001200, 0x12000000, 0x00001400, 0x01101510, 0x00000400, 0x00100110, 0x00000000) { reg = &cpu->x; } /* ldx, stx, cpx, inx, dex, tax, tyx, tsx */ \
- t(0, 0x00000000, 0x00000000, 0x00041044, 0x10001200, 0x06000000, 0x00100110, 0x00000400, 0x01001000) { reg = &cpu->y; } /* ldy, sty, cpy, iny, dey, tay, txy */ \
+ t(0, 0x02220022, 0x03760576, 0x00220432, 0x40665076, 0x00660066, 0x04660066, 0x55665066, 0x04660066) { reg = &cpu->a; } /* Most operations use the accumulator as an operand */ \
+ t(0, 0x05540354, 0x04000000, 0x44004200, 0x02000000, 0x10000000, 0x51005000, 0x00000000, 0x00100510) { reg = &cpu->b; } /* ldb, stb, cpb, inb, deb, tab */ \
+ t(0, 0x40004000, 0x00001200, 0x12000000, 0x00001400, 0x01101510, 0x00000400, 0x00100110, 0x00000000) { reg = &cpu->x; } /* ldx, stx, cpx, inx, dex, tax, tyx, tsx */ \
+ t(0, 0x00000000, 0x40004000, 0x00041044, 0x10001200, 0x06000000, 0x00100110, 0x00000400, 0x01001000) { reg = &cpu->y; } /* ldy, sty, cpy, iny, dey, tay, txy */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x04000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { reg = &cpu->sp; } /* txs */ \
- t(7, 0x00010001, 0x00010001, 0x00010001, 0x00010001, 0x00014200, 0x00000200, 0x02000200, 0x02000201) { reg = &cpu->ps[thread]; } /* php, test/set/clear flags, and interrupts. */ \
- t(0, 0x07561370, 0x17561570, 0x14161560, 0x10161160, 0x11161160, 0x51165161, 0x51175161, 0x01171160) { tmp = read_value(cpu, 0, addr, rs, inc_clk, 1); } /* Read data from memory. */ \
- t(0, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000016, 0x00000016, 0x00000016, 0x00000016) { tmp = read_value(cpu, 0, cpu->pc, rs, inc_clk, 0); cpu->pc += rs; } /* Immediate data. */ \
+ t(7, 0x00010001, 0x00010001, 0x00010001, 0x00010001, 0x40014200, 0x00000200, 0x02000200, 0x02000201) { reg = (uint64_t *)&cpu->ps.u8[thread]; } /* php, test/set/clear flags, and interrupts. */ \
+ t(0, 0x07470371, 0x03470171, 0x14171561, 0x00171161, 0x10170160, 0x00160160, 0x00160160, 0x00160160) { tmp = read_value(cpu, 0, addr, rs, inc_clk, 1); } /* Read data from memory. */ \
+ t(0, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000016, 0x00000016, 0x00000016, 0x00000016) { tmp = read_value(cpu, 0, cpu->pc, rs, inc_clk, 0); cpu->pc += rs+1; } /* Immediate data. */ \
/* Setup register transfers. */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000400, 0x00000400, 0x00000400) { reg2 = &cpu->a; } /* tab, tax, tay. */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040044, 0x00000000, 0x04000000) { reg2 = &cpu->b; } /* tba, div. */ \
@@ -1838,7 +1838,7 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size,
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000400, 0x00000000, 0x04000000, 0x00000000) { reg2 = &cpu->y; } /* tya, tyx. */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000400, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { reg2 = &cpu->sp; } /* tsx. */ \
/* Operations that mogrify (overwrite) memory directly. */ \
- t(0, 0x00000000, 0x00000200, 0x02000210, 0x02000210, 0x02000000, 0x00000000, 0x00000000, 0x00000000) { tmp = *reg; } /* Mogrifying register. */ \
+ t(0, 0x00100000, 0x04101600, 0x02000210, 0x12000210, 0x03001000, 0x51005000, 0x51005000, 0x01001000) { tmp = *reg; } /* Mogrifying registers, and stores. */ \
t(0, 0x00000000, 0x00000200, 0x00100310, 0x00000200, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { ++tmp; } /* inc */ \
t(0, 0x00000000, 0x00000000, 0x02000000, 0x02100110, 0x02000000, 0x00000000, 0x00000000, 0x00000000) { --tmp; } /* dec */ \
/* Store modified value into memory. */ \
@@ -1850,7 +1850,7 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size,
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, 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, 0x00011001, 0x10010001, 0x00010001, 0x00010001, 0x00010201, 0x00010201, 0x02010201, 0x02010200) { tmp = 1; } \
+ t(7, 0x00011001, 0x10010001, 0x00010001, 0x00010001, 0x00010200, 0x00000201, 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; } \
@@ -1860,7 +1860,7 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size,
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00220022, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { tmp ^= *reg; } /* xor. */ \
/* Conditional branches. */ \
/* 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(7, 0x00011000, 0x10010000, 0x00010000, 0x00010001, 0x00000200, 0x00000001, 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. */ \
/* Arithmetic operations. */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00440044, 0x00000000, 0x00000000, 0x00000000) { sign = -(uint64_t)(*reg >> (msb-1)) << (msb-1)-tmp2; } /* asr. */ \
@@ -1873,11 +1873,11 @@ static /*inline*/ void inst_##op(struct sux *cpu, uint8_t prefix, uint8_t size,
t(0, 0x00220022, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { rotate(tmp, *reg, tmp2, <<, >>, carry & 1, carry << (tmp2-1)); } /* rol. */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00440044) { rotate(tmp, *reg, tmp2, >>, <<, carry << (msb-1), carry << (msb-tmp2)); } /* ror. */ \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00440044, 0x00000000) { tmp *= *reg; } /* mul. */ \
- t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00440044, 0x00000000, 0x00000000) { tmp /= *reg; *reg2 %= tmp2; } /* div. */ \
+ t(0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00440044, 0x00000000, 0x00000000) { tmp = *reg / tmp; *reg2 = *reg % tmp2; } /* div. */ \
t(0, 0x00220022, 0x00000000, 0x00220022, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { carry = (*reg >> (msb-(tmp2+!tmp2))) & 1; } /* rol, lsl. */ \
t(0, 0x00000000, 0x00220022, 0x00000000, 0x00000000, 0x00440044, 0x00000000, 0x00000000, 0x00440044) { carry = (*reg >> tmp2-(tmp2 != 0)) & 1; } /* ror, lsr, asr. */ \
/* Store modified value into register. */ \
- t(7, 0x07660376, 0x03660376, 0x16261676, 0x02661276, 0x12760376, 0x00760376, 0x02760376, 0x02760377) { *reg = tmp; } \
+ t(7, 0x01660376, 0x03660376, 0x12261276, 0x02220232, 0x02760376, 0x00660266, 0x02660266, 0x02660267) { *reg = tmp; } \
t(0, 0x00000000, 0x00000000, 0x00000000, 0x04000400, 0x04000400, 0x04000400, 0x04000400, 0x04000400) { *reg = *reg2; } /* Register transfers. */ \
/* Update status flags. */ \
t(0, 0x00000000, 0x00000000, 0x00100100, 0x00100100, 0x00000000, 0x00000000, 0x00000000, 0x00000000) { msb = rs*8; } /* inc, dec memory. */ \