uxn

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

commit 60cbe91cdefc307543491c62c1b3ba79da02dba0
parent 560ead0e329dce51aa58028b67699e24e6706f27
Author: neauoire <aliceffekt@gmail.com>
Date:   Fri,  5 Feb 2021 20:18:30 -0800

Fixed issue with addr offset

Diffstat:
MREADME.md | 16+++++++++-------
Mexamples/core.usm | 12++++++++----
Muxn.c | 5++---
Muxnasm.c | 14+++-----------
4 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/README.md b/README.md @@ -40,18 +40,21 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn @loop ,dev1w STR - ,iterator LDR - ,01 ADD - ,iterator STR - ,iterator LDR + ,incr JSU ( call incr ) ,05 NEQ ,loop ROT JSC BRK ( RESET ) +@incr + ,iterator LDR + ,01 ADD + ,iterator STR + ,iterator LDR + RTS + |c000 @FRAME BRK |d000 @ERROR BRK |FFFA .RESET .FRAME .ERROR - ``` ## Mission @@ -82,4 +85,4 @@ https://code.9front.org/hg/plan9front/file/a7f9946e238f/sys/src/games/nes/cpu.c http://www.w3group.de/stable_glossar.html http://www.emulator101.com/6502-addressing-modes.html http://forth.works/8f0c04f616b6c34496eb2141785b4454 -https://justinmeiners.github.io/lc3-vm/ -\ No newline at end of file +https://justinmeiners.github.io/lc3-vm/ diff --git a/examples/core.usm b/examples/core.usm @@ -10,14 +10,18 @@ @loop ,dev1w STR - ,iterator LDR - ,01 ADD - ,iterator STR - ,iterator LDR + ,incr JSU ( call incr ) ,05 NEQ ,loop ROT JSC BRK ( RESET ) +@incr + ,iterator LDR + ,01 ADD + ,iterator STR + ,iterator LDR + RTS + |c000 @FRAME BRK |d000 @ERROR BRK |FFFA .RESET .FRAME .ERROR diff --git a/uxn.c b/uxn.c @@ -164,7 +164,7 @@ reset(void) int error(char *name) { - printf("Error: %s\n", name); + printf("Error: %s, at 0x%04x\n", name, cpu.counter); return 0; } @@ -195,8 +195,7 @@ eval(void) if(instr > 0x10) setflag(FLAG_ZERO, 0); if(cpu.counter == 128) { - printf("REACHED COUNTER\n"); - return 0; + return error("Reached bounds"); } cpu.counter++; return 1; diff --git a/uxnasm.c b/uxnasm.c @@ -108,12 +108,6 @@ shex(char *s) /* string to num */ } int -ismarker(char *w) -{ - return w[0] == '[' || w[0] == ']' || w[0] == '{' || w[0] == '}'; -} - -int iscomment(char *w, int *skip) { if(w[0] == ')') { @@ -173,7 +167,7 @@ findlabel(char *s) int error(char *name, char *id) { - printf("Error: %s(%s)\n", name, id); + printf("Error: %s[%s]\n", name, id); return 0; } @@ -241,9 +235,7 @@ pass1(FILE *f) else if(w[0] == '"') addr += slen(w + 1) + 2; else if(w[0] == ',') - addr += 4; - else if(ismarker(w)) - addr += 0; + addr += 2 + (sihx(w + 1) && slen(w + 1) == 2 ? 1 : 2); else return error("Unknown label", w); } @@ -262,7 +254,7 @@ pass2(FILE *f) if(w[0] == '@') continue; if(w[0] == ';') continue; suca(w); - if(iscomment(w, &skip) || ismarker(w)) continue; + if(iscomment(w, &skip)) continue; if(w[0] == '|') p.ptr = shex(w + 1); else if(w[0] == ':')