summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-12-13 13:14:24 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2019-12-13 13:14:24 -0500
commitc6d71bcf0e545a490fdeb0dfcafea2d5a02157c6 (patch)
tree559eefbfde2cdddfe33a6b59950f3db56a3def78
parent9526483f93b5950ecfa81a93f30b617bec22dfe1 (diff)
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.
-rw-r--r--asmmon.c6
-rw-r--r--sux.c17
-rw-r--r--test/asr.s2
-rw-r--r--test/hello-world.s1
4 files changed, 15 insertions, 11 deletions
diff --git a/asmmon.c b/asmmon.c
index 43811f7..7467985 100644
--- a/asmmon.c
+++ b/asmmon.c
@@ -570,11 +570,11 @@ int asmmon() {
}
}
if (postfix != NULL && !(done & 8)) {
- if (strcasecmp(postfix, "w") == 0) {
+ if (!strcasecmp(postfix, "w") || !strcasecmp(postfix, "2")) {
addr[address++] = 0x17;
- } else if (strcasecmp(postfix, "d") == 0) {
+ } else if (!strcasecmp(postfix, "d") || !strcasecmp(postfix, "4")) {
addr[address++] = 0x27;
- } else if (strcasecmp(postfix, "q") == 0) {
+ } else if (!strcasecmp(postfix, "q") || !strcasecmp(postfix, "8")) {
addr[address++] = 0x37;
} else {
done |=8;
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
diff --git a/test/asr.s b/test/asr.s
index 6377875..ca5eff1 100644
--- a/test/asr.s
+++ b/test/asr.s
@@ -14,6 +14,8 @@ signshft:
beq start
jmp signshft
+.org $FFC0
+.qword reset
.org $0
done
diff --git a/test/hello-world.s b/test/hello-world.s
index fef5a46..465583c 100644
--- a/test/hello-world.s
+++ b/test/hello-world.s
@@ -41,6 +41,7 @@ spin:
nop
jmp spin
+
.org $FFC0
.qword reset