summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-05-06 14:10:46 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-05-06 14:10:46 -0400
commit11c8d71babb0210d070dd6ab12a255a5fa3159a5 (patch)
treebdd895bb0f6a148445178f46cd67274ca570ca10 /sux.c
parent9ccba5e624319becd9a85822e60b15b6355f19cd (diff)
Removed some duplicate code in the assembler, and made
the processor status register, a union now.
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sux.c b/sux.c
index 1299432..3c84425 100644
--- a/sux.c
+++ b/sux.c
@@ -102,10 +102,10 @@ void *run(void *args) {
, cpu->y[thread]);
wprintw(scr,
", sp: $%04X"
- ", ps: $%02"PRIX64
+ ", ps: $%02X"
", inst: "
, cpu->sp[thread]
- , cpu->ps);
+ , cpu->ps.u8[thread]);
#if keypoll
pthread_mutex_unlock(&mutex);
#endif
@@ -148,7 +148,7 @@ void *run(void *args) {
#endif
switch(opcode) {
case CPS: /* Clear Processor Status. */
- cpu->ps = 0;
+ cpu->ps.u64 = 0;
break;
case AAB: /* Add Accumulator with carry by B register. */
value.u64 = cpu->b[thread]; /* Falls Through. */
@@ -461,8 +461,8 @@ void *run(void *args) {
case NOP: /* No OPeration. */
break;
case RTI: /* ReTurn from Interrupt routine. */
- cpu->sp[thread] +=1;
- cpu->ps = addr[(cpu->stk_st[thread] << 16)+(cpu->sp[thread])] << (thread << 3); /* Falls through. */
+ cpu->sp[thread] += 1;
+ cpu->ps.u8[thread] = addr[(cpu->stk_st[thread] << 16)+(cpu->sp[thread])]; /* Falls through. */
case RTS: /* ReTurn from Subroutine. */
case RTL: /* ReTurn from subroutine Long. */
cpu->sp[thread] += 8;
@@ -500,7 +500,7 @@ void *run(void *args) {
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]-5] = value.u8[2];
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]-6] = value.u8[1];
addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]-7] = value.u8[0];
- addr[(cpu->stk_st[thread] << 16)+(cpu->sp[thread]-8)] = (uint64_t)cpu->ps >> (thread << 3);
+ addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]-8] = cpu->ps.u8[thread];
cpu->sp[thread] -= 9;
setflag(1, I);
if (opcode == BRK) {