From c6d71bcf0e545a490fdeb0dfcafea2d5a02157c6 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 13 Dec 2019 13:14:24 -0500 Subject: Added support for specifying the number of bytes as the suffix. I added this because BieHDC said the already existing notation glowed in the dark too much. --- sux.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sux.c') diff --git a/sux.c b/sux.c index 19263c3..452c8fa 100644 --- a/sux.c +++ b/sux.c @@ -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 -- cgit v1.2.3-13-gbd6f