diff options
Diffstat (limited to 'sux.c')
-rw-r--r-- | sux.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -1119,10 +1119,8 @@ void *run(void *args) { case RTS: /* ReTurn from Subroutine. */ for (uint8_t i = 0; i < 32; i+=8) { cpu->sp[thread]++; - if (i < 24) + if (i) cpu->pc[thread] += addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; - else if (i == 24) - cpu->pc[thread] += addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i +1; else cpu->pc[thread] = addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]]; } @@ -1214,10 +1212,8 @@ void *run(void *args) { cpu->ps = addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << 8*thread; for (uint8_t i = 0; i < 64; i+=8) { cpu->sp[thread]++; - if (i < 56) + if (i) cpu->pc[thread] += addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; - else if (i == 56) - cpu->pc[thread] += addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i +1; else cpu->pc[thread] = addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]]; } @@ -1359,7 +1355,7 @@ void *run(void *args) { addr[address]--; break; case BRK: /* BReaK. */ - for (uint8_t i = 56; i >= 0; i-=8) { + for (int8_t i = 56; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread]-1 >> i; else @@ -1369,7 +1365,12 @@ void *run(void *args) { addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->ps >> 8*thread; cpu->sp[thread]--; cpu->i[thread] = 1; - setps(cpu, thread); + (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); + (cpu->i[thread]) ? (cpu->ps |= (I << 8*thread)) : (cpu->ps &= ~(I << 8*thread)); + (cpu->s[thread]) ? (cpu->ps |= (S << 8*thread)) : (cpu->ps &= ~(S << 8*thread)); + (cpu->v[thread]) ? (cpu->ps |= (V << 8*thread)) : (cpu->ps &= ~(V << 8*thread)); + (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); cpu->pc[thread] = (uint64_t)addr[0xFFE0] | (uint64_t)addr[0xFFE1] << 8 | (uint64_t)addr[0xFFE2] << 16 |