diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-12-09 11:28:59 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-12-09 11:28:59 -0500 |
commit | b1cf9d8a524edab9363bb53c0fd70457a8bdbd76 (patch) | |
tree | db1c1f9eeb95d112ec4a7337bd53b4c7dad8880e /sux.h | |
parent | 464130cf4b19578f45fc51a6a37453261bdf37f9 (diff) |
- Implemented support for the `set` instruction in the
assembler.
The main thing I had to do was implement the parsing
of the condition code token, but that wasn't hard to
do, since I had already done the lexing part already.
The next thing to do, will be to design a calling
convention for Sux.
Diffstat (limited to 'sux.h')
-rw-r--r-- | sux.h | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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. */ |