Browse code

Various fixes

neauoire authored on 10/02/2021 19:59:26
Showing 5 changed files
... ...
@@ -169,7 +169,7 @@ pass1(FILE *f)
169 169
 			case '#': addr += 4; break;
170 170
 			case '.': addr += 2; break;
171 171
 			case ',':
172
-				addr += (slen(w + 1) == 2 ? 1 : 2);
172
+				addr += (sihx(w + 1) && slen(w + 1) == 2 ? 1 : 2);
173 173
 				addr += (sihx(w + 1) ? slen(w + 1) / 2 : 2);
174 174
 				break;
175 175
 			default: return error("Unknown label", w);
... ...
@@ -24,5 +24,5 @@ rm -f ./bin/emulator
24 24
 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
25 25
 
26 26
 # run
27
-./bin/assembler examples/mouse.usm bin/boot.rom
27
+./bin/assembler examples/test.usm bin/boot.rom
28 28
 ./bin/emulator bin/boot.rom
... ...
@@ -7,7 +7,7 @@
7 7
 @word1 "hello_world ( len: 0x0b )
8 8
 
9 9
 @loop
10
-	,00 IOW ( write to device#0 )
10
+	IOW ( write to device#0 )
11 11
 	,incr JSR ( increment itr )
12 12
 	,word1 ,strlen JSR ( get strlen )
13 13
 	NEQ ,loop ROT JSR? ( loop != strlen )
... ...
@@ -3,35 +3,26 @@
3 3
 :dev/r fff8 ( std read port )
4 4
 :dev/w fff9 ( std write port )
5 5
 
6
+;i ;x0 ;x1 ;y0 ;y1
7
+
6 8
 |0100 @RESET 
7 9
 	
8
-	,02 ,dev/r STR ( set dev/read mouse#02 )
9
-	,01 ,dev/w STR ( set dev/write screen#01 )
10
-
11
-	,00 ,01 ,0001 ,0000 ,putpixel JSR
12
-	,00 ,01 ,0000 ,0001 ,putpixel JSR
13
-	,00 ,01 ,0002 ,0001 ,putpixel JSR
14
-	,01 ,02 ,0001 ,0002 ,putpixel JSR
10
+	,01 ,dev/w STR ( set dev/write screen#01 ) 
15 11
 
16 12
 BRK
17 13
 
18
-|c000 @FRAME
14
+|c000 @FRAME 
15
+	
16
+	,i LDR ,01 ADD ,i STR ( incr i )
17
+
18
+	,i LDR ,x1 STR ( set x )
19 19
 
20
-	( get mouse button, or break )
21
-	,04 IOR
22
-	,01 NEQ
23
-	BRK?
24
-		
25
-	( paint a white pixel )
26
-	,01 ,01 
27
-	,getmouse JSR
28
-	,putpixel JSR
20
+	,01 ,02 ,x0 LDR^ ,y0 LDR^ ,putpixel JSR
29 21
 
30 22
 BRK
31 23
 
32
-@getmouse
33
-	,02 IOR^ ( get mouse y )
34
-	,00 IOR^ ( get mouse x )
24
+@onrow
25
+	,y1 LDR ,01 ADD ,y1 STR
35 26
 	RTS
36 27
 
37 28
 @putpixel 
... ...
@@ -157,6 +157,7 @@ stepuxn(Uxn *u, Uint8 instr)
157 157
 int
158 158
 evaluxn(Uxn *u, Uint16 vec)
159 159
 {
160
+	u->literal = 0;
160 161
 	u->ram.ptr = vec;
161 162
 	setflag(&u->status, FLAG_HALT, 0);
162 163
 	while(!(u->status & FLAG_HALT)) {