diff --git a/README.md b/README.md index 0e4d81b..5743009 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn - Implement addressing - Implement 16 bits operations +## Notes + +- Forth logic operators pop 2 items and add a bool to the stack, is that viable in uxn? + ## Refs https://code.9front.org/hg/plan9front/file/a7f9946e238f/sys/src/games/nes/cpu.c diff --git a/build.sh b/build.sh index d6e648f..1df615f 100755 --- a/build.sh +++ b/build.sh @@ -14,5 +14,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c -o uxn # run -./uxnasm examples/arithmetic.usm boot.rom +./uxnasm examples/core.usm boot.rom ./uxn boot.rom diff --git a/examples/core.usm b/examples/core.usm index 7fcfab1..030e6f6 100644 --- a/examples/core.usm +++ b/examples/core.usm @@ -1,4 +1,6 @@ < core > -0102 +34 34 EQU .label JSZ ff BRK + +:label ee RTS diff --git a/examples/subcond.usm b/examples/subcond.usm new file mode 100644 index 0000000..eca9ed0 --- /dev/null +++ b/examples/subcond.usm @@ -0,0 +1,2 @@ +< subcond > + diff --git a/examples/subroutines.usm b/examples/subroutines.usm index 2d11a15..4a450e7 100644 --- a/examples/subroutines.usm +++ b/examples/subroutines.usm @@ -1,25 +1,9 @@ < subroutines > -:begin - .addall JSI ADD ADD - 06 EQU .isequal JSI - BRK +.part1 JSI 44 BRK -:add1 - 01 RTS +:part1 11 .part2 JSI RTS -:add2 - 02 RTS +:part2 22 .part3 JSI RTS -:add3 - 03 RTS - -:addall - .add1 JSI - .add2 JSI - .add3 JSI - RTS - -:isequal - .addall JSI ff - RTS +:part3 33 RTS \ No newline at end of file diff --git a/uxn.c b/uxn.c index 7e9e44c..c0d32e7 100644 --- a/uxn.c +++ b/uxn.c @@ -123,12 +123,14 @@ reset(void) int i; cpu.status = 0x00; cpu.counter = 0x00; + cpu.literal = 0x00; cpu.rom.ptr = 0x00; cpu.wst.ptr = 0x00; - cpu.literal = 0x00; cpu.rst.ptr = 0x00; - for(i = 0; i < 256; i++) + for(i = 0; i < 256; i++) { cpu.wst.dat[i] = 0x00; + cpu.rst.dat[i] = 0x00; + } } int