summaryrefslogtreecommitdiff
path: root/sux.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-12-08 10:42:10 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-12-09 11:43:33 -0500
commita232e9f691187fdb05c35c14d4152d17f4babaf5 (patch)
tree9fdf364ce91506ed4490cd95ced6355459d7e8b5 /sux.h
parent50875a80729eaf3be2b1473e385eca1102fce4e6 (diff)
- Implemented support for the Orthogonal extension into
both the assembler, and the emulator. I finally figured out how I could get support for the Ortho extension implemented into the old assembler. The only reason for doing this, is to buy me some while I start work on the new assembler, and to help me get an idea for how to do the same in the new assembler.
Diffstat (limited to 'sux.h')
-rw-r--r--sux.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/sux.h b/sux.h
index d267755..c532c6e 100644
--- a/sux.h
+++ b/sux.h
@@ -34,8 +34,8 @@ static const uint64_t mem_size = 0x04000000; /* Size of address space. */
extern uint8_t step;
extern uint8_t end;
-#define setflag(flag, bit) ((flag)) ? (cpu->ps.u8[thread] |= bit) : (cpu->ps.u8[thread] &= ~bit)
-#define getflag(bit) (cpu->ps.u8[thread] & bit)
+#define setflag(flag, bit) ((flag)) ? (cpu->ps.u8[thread] |= (bit)) : (cpu->ps.u8[thread] &= ~(bit))
+#define getflag(bit) (cpu->ps.u8[thread] & (bit))
#define ORTHO_1CC(mne, cc) \
mne##_R##cc: case mne##_M##cc
@@ -856,7 +856,7 @@ static /*inline*/ uint64_t mov(struct sux *cpu, uint64_t src, uint64_t size, uin
}
static /*inline*/ uint64_t set(struct sux *cpu, uint8_t flag, uint8_t thread) {
- return flag;
+ return (flag != 0);
}
static /*inline*/ uint64_t inc_dec(struct sux *cpu, uint64_t value, uint8_t size, uint8_t inc, uint8_t thread) {
@@ -1032,8 +1032,8 @@ static /*inline*/ void exec_ortho_inst(struct sux *cpu, uint8_t opcode, uint8_t
push(cpu, address, 7, thread);
} while (0);
break;
- case ORTHO_1OP(INC): dst = inc_dec(cpu, dst, size, 1, thread); break;
- case ORTHO_1OP(DEC): dst = inc_dec(cpu, dst, size, 0, thread); break;
+ case ORTHO_1OP(INC): dst = inc_dec(cpu, dst, (op[0].type) ? size+1 : 8, 1, thread); break;
+ case ORTHO_1OP(DEC): dst = inc_dec(cpu, dst, (op[0].type) ? size+1 : 8, 0, thread); break;
case ORTHO_1OP(PSH): push(cpu, dst, size, thread); break;
case ORTHO_1OP(PUL): dst = pull(cpu, size, thread); break;
case ORTHO_1OP(NOT): dst = ~dst; break;
@@ -1391,7 +1391,7 @@ static /*inline*/ void exec_base_inst(struct sux *cpu, uint8_t opcode, uint8_t p
case ADC_IMM: /* ADC Immediate. */
case ADC_AB: /* ADC Absolute. */
case ADC_Z: /* ADC Zero Matrix. */
- cpu->a = adc(cpu, cpu->a, value, 8, getflag(C), thread);
+ cpu->a = adc(cpu, cpu->a, value, getflag(C), 8, thread);
break;
case PHP_IMP: push(cpu, cpu->ps.u8[thread], 0, thread); break; /* PusH Processor status to stack. */
case PHA_IMP: push(cpu, cpu->a , size, thread); break; /* PusH Accumulator to stack. */
@@ -1419,7 +1419,7 @@ static /*inline*/ void exec_base_inst(struct sux *cpu, uint8_t opcode, uint8_t p
case SBC_IMM: /* SBC Immediate. */
case SBC_AB: /* SBC Absolute. */
case SBC_Z: /* SBC Zero Matrix. */
- cpu->a = adc(cpu, cpu->a, ~value, 8, getflag(C), thread);
+ cpu->a = adc(cpu, cpu->a, ~value, getflag(C), 8, thread);
break;
case PLP_IMP: cpu->ps.u8[thread] = pull(cpu, 0, thread); break; /* PuLl Processor status from stack. */
case PLA_IMP: cpu->a = pull(cpu, size, thread); break; /* PuLl Accumulator from stack. */