uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit f997c5f56437f17824c77f1b5224dcf95303ce0a
parent 71c0b357ce4a55e0dea61f2209736857db923845
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue, 16 Mar 2021 10:54:07 -0700

Added missing stack balances

Diffstat:
Mbuild.sh | 2+-
Mprojects/tests/cond.usm | 6+++++-
Muxn.c | 14+++++---------
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/build.sh b/build.sh @@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # run -./bin/assembler projects/software/nasu.usm bin/boot.rom +./bin/assembler projects/software/left.usm bin/boot.rom ./bin/emulator bin/boot.rom diff --git a/projects/tests/cond.usm b/projects/tests/cond.usm @@ -1,10 +1,14 @@ ( tests/cond ) |0100 @RESET - + + #1234 POP2 + #00 DUP2? BRK + + |c000 @FRAME |d000 @ERROR diff --git a/uxn.c b/uxn.c @@ -103,12 +103,12 @@ void (*ops[])(Uxn *u) = { Uint8 opr[][4] = { /* wstack-/+ rstack-/+ */ {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,1,0,0}, {3,0,0,0}, {1,0,0,0}, {1,0,0,2}, {0,0,2,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, - {1,0,0,0}, {1,2,0,0}, {2,2,0,0}, {2,3,0,0}, {3,3,0,0}, {0,0,0,0}, {1,0,0,1}, {0,1,1,0}, + {1,0,0,0}, {0,2,0,0}, {2,2,0,0}, {2,3,0,0}, {3,3,0,0}, {0,0,0,0}, {1,0,0,1}, {0,1,1,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {2,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0}, /* 16-bit */ {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,2,0,0}, {4,0,0,0}, {2,0,0,0}, {2,0,0,0}, {0,0,0,0}, /* TODO */ - {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, /* TODO */ - {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,0,0,2}, {0,2,2,0}, /* TODO */ + {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, /* TODO */ + {0,2,0,0}, {0,2,0,0}, {1,1,0,0}, {4,6,0,0}, {6,6,0,0}, {0,0,0,0}, {2,0,0,2}, {0,2,2,0}, /* TODO */ {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {4,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,2,0,0} }; @@ -156,12 +156,8 @@ opcuxn(Uxn *u, Uint8 instr) return haltuxn(u, "Return-stack overflow", instr); if(!fcond || (fcond && pop8(&u->wst))) (*ops[op])(u); - else { - if(freturn) - u->src->ptr -= opr[op][2] - opr[op][3]; - else - u->src->ptr -= opr[op][0] - opr[op][1]; - } + else + u->src->ptr -= opr[op][freturn ? 2 : 0] - opr[op][freturn ? 3 : 1]; return 1; }