commit abee68f5059e7b6da51c009d555403b07b936ec8
parent c1bffc1f8a0f3f05a6b46ecc5b0922aba8358ebc
Author: neauoire <aliceffekt@gmail.com>
Date: Wed, 10 Feb 2021 11:59:26 -0800
Various fixes
Diffstat:
5 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/assembler.c b/assembler.c
@@ -169,7 +169,7 @@ pass1(FILE *f)
case '#': addr += 4; break;
case '.': addr += 2; break;
case ',':
- addr += (slen(w + 1) == 2 ? 1 : 2);
+ addr += (sihx(w + 1) && slen(w + 1) == 2 ? 1 : 2);
addr += (sihx(w + 1) ? slen(w + 1) / 2 : 2);
break;
default: return error("Unknown label", w);
diff --git a/build.sh b/build.sh
@@ -24,5 +24,5 @@ rm -f ./bin/emulator
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 emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator
# run
-./bin/assembler examples/mouse.usm bin/boot.rom
+./bin/assembler examples/test.usm bin/boot.rom
./bin/emulator bin/boot.rom
diff --git a/examples/hello.usm b/examples/hello.usm
@@ -7,7 +7,7 @@
@word1 "hello_world ( len: 0x0b )
@loop
- ,00 IOW ( write to device#0 )
+ IOW ( write to device#0 )
,incr JSR ( increment itr )
,word1 ,strlen JSR ( get strlen )
NEQ ,loop ROT JSR? ( loop != strlen )
diff --git a/examples/test.usm b/examples/test.usm
@@ -3,35 +3,26 @@
:dev/r fff8 ( std read port )
:dev/w fff9 ( std write port )
+;i ;x0 ;x1 ;y0 ;y1
+
|0100 @RESET
- ,02 ,dev/r STR ( set dev/read mouse#02 )
- ,01 ,dev/w STR ( set dev/write screen#01 )
-
- ,00 ,01 ,0001 ,0000 ,putpixel JSR
- ,00 ,01 ,0000 ,0001 ,putpixel JSR
- ,00 ,01 ,0002 ,0001 ,putpixel JSR
- ,01 ,02 ,0001 ,0002 ,putpixel JSR
+ ,01 ,dev/w STR ( set dev/write screen#01 )
BRK
-|c000 @FRAME
+|c000 @FRAME
+
+ ,i LDR ,01 ADD ,i STR ( incr i )
+
+ ,i LDR ,x1 STR ( set x )
- ( get mouse button, or break )
- ,04 IOR
- ,01 NEQ
- BRK?
-
- ( paint a white pixel )
- ,01 ,01
- ,getmouse JSR
- ,putpixel JSR
+ ,01 ,02 ,x0 LDR^ ,y0 LDR^ ,putpixel JSR
BRK
-@getmouse
- ,02 IOR^ ( get mouse y )
- ,00 IOR^ ( get mouse x )
+@onrow
+ ,y1 LDR ,01 ADD ,y1 STR
RTS
@putpixel
diff --git a/uxn.c b/uxn.c
@@ -157,6 +157,7 @@ stepuxn(Uxn *u, Uint8 instr)
int
evaluxn(Uxn *u, Uint16 vec)
{
+ u->literal = 0;
u->ram.ptr = vec;
setflag(&u->status, FLAG_HALT, 0);
while(!(u->status & FLAG_HALT)) {