Various fixes

This commit is contained in:
neauoire 2021-02-10 11:59:26 -08:00
parent c1bffc1f8a
commit abee68f505
5 changed files with 15 additions and 23 deletions

View File

@ -169,7 +169,7 @@ pass1(FILE *f)
case '#': addr += 4; break; case '#': addr += 4; break;
case '.': addr += 2; break; case '.': addr += 2; break;
case ',': 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); addr += (sihx(w + 1) ? slen(w + 1) / 2 : 2);
break; break;
default: return error("Unknown label", w); default: return error("Unknown label", w);

View File

@ -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 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 # run
./bin/assembler examples/mouse.usm bin/boot.rom ./bin/assembler examples/test.usm bin/boot.rom
./bin/emulator bin/boot.rom ./bin/emulator bin/boot.rom

View File

@ -7,7 +7,7 @@
@word1 "hello_world ( len: 0x0b ) @word1 "hello_world ( len: 0x0b )
@loop @loop
,00 IOW ( write to device#0 ) IOW ( write to device#0 )
,incr JSR ( increment itr ) ,incr JSR ( increment itr )
,word1 ,strlen JSR ( get strlen ) ,word1 ,strlen JSR ( get strlen )
NEQ ,loop ROT JSR? ( loop != strlen ) NEQ ,loop ROT JSR? ( loop != strlen )

View File

@ -3,35 +3,26 @@
:dev/r fff8 ( std read port ) :dev/r fff8 ( std read port )
:dev/w fff9 ( std write port ) :dev/w fff9 ( std write port )
;i ;x0 ;x1 ;y0 ;y1
|0100 @RESET |0100 @RESET
,02 ,dev/r STR ( set dev/read mouse#02 )
,01 ,dev/w STR ( set dev/write screen#01 ) ,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
BRK BRK
|c000 @FRAME |c000 @FRAME
( get mouse button, or break ) ,i LDR ,01 ADD ,i STR ( incr i )
,04 IOR
,01 NEQ
BRK?
( paint a white pixel ) ,i LDR ,x1 STR ( set x )
,01 ,01
,getmouse JSR ,01 ,02 ,x0 LDR^ ,y0 LDR^ ,putpixel JSR
,putpixel JSR
BRK BRK
@getmouse @onrow
,02 IOR^ ( get mouse y ) ,y1 LDR ,01 ADD ,y1 STR
,00 IOR^ ( get mouse x )
RTS RTS
@putpixel @putpixel

1
uxn.c
View File

@ -157,6 +157,7 @@ stepuxn(Uxn *u, Uint8 instr)
int int
evaluxn(Uxn *u, Uint16 vec) evaluxn(Uxn *u, Uint16 vec)
{ {
u->literal = 0;
u->ram.ptr = vec; u->ram.ptr = vec;
setflag(&u->status, FLAG_HALT, 0); setflag(&u->status, FLAG_HALT, 0);
while(!(u->status & FLAG_HALT)) { while(!(u->status & FLAG_HALT)) {