uxnrepl

uxn interpreter
git clone git://bvnf.space/uxnrepl.git
Log | Files | Refs | LICENSE

commit a0e6f872c95f1d7149225f127edf90b507999527
parent 34df73e83962ecc8f4b0a2f6e8cae6d67000a5a3
Author: phoebos <ben@bvnf.space>
Date:   Wed,  1 Jun 2022 22:58:52 +0100

move stack opcodes

Diffstat:
Atodo | 1+
Muxntrp.c | 12++++++------
2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/todo b/todo @@ -0,0 +1 @@ +#3456 #1234 GTH2 should evaluate to #01 not #0001 diff --git a/uxntrp.c b/uxntrp.c @@ -48,7 +48,7 @@ int parse_macro(char *s); uint8_t ops[][4] = { - "LIT", "INC", "POP", "DUP", "NIP", "SWP", "OVR", "ROT", + "LIT", "INC", "POP", "NIP", "SWP", "ROT", "DUP", "OVR", "EQU", "NEQ", "GTH", "LTH", "JMP", "JCN", "JSR", "STH", "LDZ", "STZ", "LDR", "STR", "LDA", "STA", "DEI", "DEO", "ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT" @@ -108,11 +108,11 @@ run_op(uint8_t op) { case 0x00: /* LIT */ Global_State.lit = 1; Global_State.litr = (int)r; break; case 0x01: /* INC */ POP(a); PUSH(src, a+1); break; case 0x02: /* POP */ POP(a); break; - case 0x03: /* DUP */ POP(a); PUSH(src, a); PUSH(src, a); break; - case 0x04: /* NIP */ POP(a); POP(b); PUSH(src, a); break; - case 0x05: /* SWP */ POP(a); POP(b); PUSH(src, a); PUSH(src, b); break; - case 0x06: /* OVR */ POP(a); POP(b); PUSH(src, b); PUSH(src, a); PUSH(src, b); break; - case 0x07: /* ROT */ POP(a); POP(b); POP(c); PUSH(src, b); PUSH(src, a); PUSH(src, c); break; + case 0x03: /* NIP */ POP(a); POP(b); PUSH(src, a); break; + case 0x04: /* SWP */ POP(a); POP(b); PUSH(src, a); PUSH(src, b); break; + case 0x05: /* ROT */ POP(a); POP(b); POP(c); PUSH(src, b); PUSH(src, a); PUSH(src, c); break; + case 0x06: /* DUP */ POP(a); PUSH(src, a); PUSH(src, a); break; + case 0x07: /* OVR */ POP(a); POP(b); PUSH(src, b); PUSH(src, a); PUSH(src, b); break; case 0x08: /* EQU */ POP(a); POP(b); PUSH(src, a == b); break; case 0x09: /* NEQ */ POP(a); POP(b); PUSH(src, a != b); break; case 0x0a: /* GTH */ POP(a); POP(b); PUSH(src, b>a); break;