summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/sux.c b/sux.c
index 62ef371..c53e7b8 100644
--- a/sux.c
+++ b/sux.c
@@ -100,6 +100,43 @@ static inline uint8_t isrw(uint8_t opcode) {
return 1; /* Reading. */
}
}
+static inline uint8_t isread(uint8_t opcode) {
+ switch (opcode) {
+ case LDA_IMM: /* LDA Immediate. */
+ case LDA_AB: /* LDA Absolute. */
+ case LDA_Z: /* LDA Zero Matrix. */
+ case LDA_ZX: /* LDA Zero Matrix, Indexed with X. */
+ case LDA_ZY: /* LDA Zero Matrix, Indexed with Y. */
+ case LDA_IN: /* LDA Indirect. */
+ case LDA_IX: /* LDA Indexed Indirect. */
+ case LDA_IY: /* LDA Indirect Indexed. */
+ case LDB_IMM: /* LDB Immediate. */
+ case LDB_AB: /* LDB Absolute. */
+ case LDB_Z: /* LDB Zero Matrix. */
+ case LDB_ZX: /* LDB Zero Matrix, Indexed with X. */
+ case LDB_ZY: /* LDB Zero Matrix, Indexed with Y. */
+ case LDB_IN: /* LDB Indirect. */
+ case LDB_IX: /* LDB Indexed Indirect. */
+ case LDB_IY: /* LDB Indirect Indexed. */
+ case LDY_IMM: /* LDY Immediate. */
+ case LDY_AB: /* LDY Absolute. */
+ case LDY_Z: /* LDY Zero Matrix. */
+ case LDY_IN: /* LDY Indirect. */
+ case LDX_IMM: /* LDX Immediate. */
+ case LDX_AB: /* LDX Absolute. */
+ case LDX_Z: /* LDX Zero Matrix. */
+ case LDX_IN: /* LDX Indirect. */
+ case JMP_AB: /* JMP Absolute. */
+ case JMP_Z: /* JMP Zero Matrix. */
+ case JMP_IN: /* JMP Indirect. */
+ case JSR_IN: /* JSR Indirect. */
+ case JSR_AB: /* Jump to SubRoutine. */
+ case JSR_Z: /* JSR Zero Matrix. */
+ return 0;
+ default:
+ return 1;
+ }
+}
void *run(void *args) {
struct suxthr *thr = (void *)args;
@@ -200,8 +237,8 @@ void *run(void *args) {
addr[STEP_ADDR] = 1;
step = 1;
}
- if (isrw(opcode) && am != REL) {
- value.u64 = read_value(cpu, address.u64, size, 1, check_io);
+ if (isrw(opcode) && am != REL && isread(opcode)) {
+ value.u64 = read_value(cpu, 0, address.u64, size, 1, check_io);
}
}
switch(opcode) {
@@ -361,7 +398,7 @@ void *run(void *args) {
case LDB_IN: /* LDB Indirect. */
case LDB_IX: /* LDB Indexed Indirect. */
case LDB_IY: /* LDB Indirect Indexed. */
- cpu->b = load(cpu, value.u64, thread);
+ cpu->b = load(cpu, cpu->b, address.u64, size, thread);
break;
case LDA_IMM: /* LDA Immediate. */
case LDA_AB: /* LDA Absolute. */
@@ -371,19 +408,19 @@ void *run(void *args) {
case LDA_IN: /* LDA Indirect. */
case LDA_IX: /* LDA Indexed Indirect. */
case LDA_IY: /* LDA Indirect Indexed. */
- cpu->a = load(cpu, value.u64, thread);
+ cpu->a = load(cpu, cpu->a, address.u64, size, thread);
break;
case LDY_IMM: /* LDY Immediate. */
case LDY_AB: /* LDY Absolute. */
case LDY_Z: /* LDY Zero Matrix. */
case LDY_IN: /* LDY Indirect. */
- cpu->y = load(cpu, value.u64, thread);
+ cpu->y = load(cpu, cpu->y, address.u64, size, thread);
break;
case LDX_IMM: /* LDX Immediate. */
case LDX_AB: /* LDX Absolute. */
case LDX_Z: /* LDX Zero Matrix. */
case LDX_IN: /* LDX Indirect. */
- cpu->x = load(cpu, value.u64, thread);
+ cpu->x = load(cpu, cpu->x, address.u64, size, thread);
break;
case BEQ_REL: /* BEQ Relative. */
if (getflag(Z)) {