Browse code

Minor cleanup

neauoire authored on 12/03/2021 04:41:35
Showing 3 changed files
... ...
@@ -22,43 +22,9 @@ evaluxn(u, u->vreset); /* Once on start */
22 22
 evaluxn(u, u->vframe); /* Each frame
23 23
 ```
24 24
 
25
-## Assembly Syntax
25
+## Uxambly
26 26
 
27
-### Define
28
-
29
-- `@label`, assign the current address to a label.
30
-- `$label`, assign the current address to a local label.
31
-- `;variable 2`, assign an address to a label automatically.
32
-- `:const 1a2b`, assign an address to a label manually.
33
-- `&macro { x 2 y 2 }`, define a macro named `macro`.
34
-
35
-### Program
36
-
37
-- `ADD`, push an opcode.
38
-- `.address`, push label address to memory.
39
-- `,literal`, push label address to stack, prefixed with `LIT LEN`.
40
-- `#1a`, push a literal byte/short.
41
-- `+1a`, push a literal signed byte/short.
42
-- `-1a`, push a literal signed byte/short(negative).
43
-- `|0010`, move to position in the program.
44
-
45
-### Helpers
46
-
47
-- `=label`, helper to STR, equivalent to `,label STR`, or `label STR2`.
48
-- `~label`, helper to LDR, equivalent to `,label LDR2`, or `,label LDR2`.
49
-
50
-### Blocks
51
-
52
-- `( comment )`, toggle parsing on/off.
53
-- `[ 0123 abcd ]`, write shorts to memory.
54
-- `[ Hello World ]`, write text to memory.
55
-
56
-### Operator modes
57
-
58
-- `#1234 #0001 ADD2`, 16-bits operators have the short flag `2`.
59
-- `#12 #11 GTH JMP?`, conditional operators have the cond flag `?`.
60
-- `+21 -03 MULS`, signed operators have the cond flag `S`.
61
-- `ADDS2?`, modes can be combined.
27
+Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
62 28
 
63 29
 ```
64 30
 ( hello world )
... ...
@@ -107,7 +73,6 @@ RTS
107 73
 
108 74
 - Includes
109 75
 - Defines
110
-- Local loops
111 76
 - Jump helpers
112 77
 
113 78
 ## Notes
... ...
@@ -14,7 +14,7 @@ WITH REGARD TO THIS SOFTWARE.
14 14
 
15 15
 #include "uxn.h"
16 16
 
17
-#define HOR 64
17
+#define HOR 48
18 18
 #define VER 32
19 19
 #define PAD 2
20 20
 #define RES (HOR * VER * 16)
... ...
@@ -211,9 +211,9 @@ RTS
211 211
 
212 212
 	( get file length )
213 213
 	,document.body =document.eof
214
-	@load-file-loop NOP
214
+	$loop NOP
215 215
 		( incr ) ~document.eof #0001 ADD2 =document.eof
216
-	~document.eof LDR #00 NEQ ^load-file-loop MUL JMPS
216
+	~document.eof LDR #00 NEQ ^$loop MUL JMPS
217 217
 
218 218
 RTS
219 219
 
... ...
@@ -221,10 +221,10 @@ RTS
221 221
 
222 222
 	=i
223 223
 	~selection.from #0001 SUB2 =j ( start -> end )
224
-	@shift-left-loop NOP
224
+	$loop NOP
225 225
 		( move ) ~j ~i ADD2 LDR ~j STR
226 226
 		( incr ) ~j #0001 ADD2 =j
227
-		~j ~document.eof LTH2 ^shift-left-loop MUL JMPS
227
+		~j ~document.eof LTH2 ^$loop MUL JMPS
228 228
 	~document.eof ~i SUB2 =document.eof
229 229
 
230 230
 RTS
... ...
@@ -250,11 +250,11 @@ RTS
250 250
 
251 251
 @goto-linestart
252 252
 
253
-	@goto-linestart-loop NOP
253
+	$loop NOP
254 254
 		~selection.from #0001 SUB2 LDR #0a EQU RTS?
255 255
 		~selection.from #0001 SUB2 LDR #0d EQU RTS?
256 256
 		( decr ) ~selection.from DUP2 =selection.to #0001 SUB2 =selection.from
257
-	~selection.from LDR #00 NEQ ^goto-linestart-loop MUL JMPS
257
+	~selection.from LDR #00 NEQ ^$loop MUL JMPS
258 258
 	( clamp at document body )
259 259
 	~selection.from ,document.body GTH2 RTS?
260 260
 	,document.body DUP2 =selection.from #0001 ADD2 =selection.to
... ...
@@ -263,11 +263,11 @@ RTS
263 263
 
264 264
 @goto-lineend
265 265
 	
266
-	@goto-lineend-loop NOP
266
+	$loop NOP
267 267
 		~selection.from LDR #0a EQU RTS?
268 268
 		~selection.from LDR #0d EQU RTS?
269 269
 		( incr ) ~selection.from #0001 ADD2 DUP2 #0001 ADD2 =selection.to =selection.from
270
-		~selection.from LDR #00 NEQ ^goto-lineend-loop MUL JMPS
270
+		~selection.from LDR #00 NEQ ^$loop MUL JMPS
271 271
 	( clamp at document body )
272 272
 	~selection.from ,document.eof LTH2 RTS?
273 273
 	,document.eof #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
... ...
@@ -277,13 +277,13 @@ RTS
277 277
 @find-wordstart
278 278
 
279 279
 	~selection.to =j
280
-	@find-wordstart-loop NOP
280
+	$loop NOP
281 281
 		( decr ) ~j #0001 SUB2 =j
282
-		,find-wordstart-end ~j LDR #20 EQU JMP2? POP2
283
-		,find-wordstart-end ~j LDR #0a EQU JMP2? POP2
284
-		,find-wordstart-end ~j LDR #0d EQU JMP2? POP2
285
-		~j ,document.body GTH2 ^find-wordstart-loop MUL JMPS
286
-	@find-wordstart-end 
282
+		,$end ~j LDR #20 EQU JMP2? POP2
283
+		,$end ~j LDR #0a EQU JMP2? POP2
284
+		,$end ~j LDR #0d EQU JMP2? POP2
285
+		~j ,document.body GTH2 ^$loop MUL JMPS
286
+	$end 
287 287
 	( return ) ~j #0001 SUB2
288 288
 
289 289
 RTS
... ...
@@ -291,13 +291,13 @@ RTS
291 291
 @find-wordend
292 292
 	
293 293
 	~selection.to =j
294
-	@find-wordend-loop NOP
294
+	$loop NOP
295 295
 		( incr ) ~j #0001 ADD2 =j
296
-		,find-wordend-end ~j LDR #20 EQU JMP2? POP2
297
-		,find-wordend-end ~j LDR #0a EQU JMP2? POP2
298
-		,find-wordend-end ~j LDR #0d EQU JMP2? POP2
299
-		~j ,document.body GTH2 ^find-wordend-loop MUL JMPS
300
-	@find-wordend-end 
296
+		,$end ~j LDR #20 EQU JMP2? POP2
297
+		,$end ~j LDR #0a EQU JMP2? POP2
298
+		,$end ~j LDR #0d EQU JMP2? POP2
299
+		~j ,document.body GTH2 ^$loop MUL JMPS
300
+	$end 
301 301
 	( return ) ~j #0001 ADD2
302 302
 
303 303
 RTS
... ...
@@ -305,12 +305,12 @@ RTS
305 305
 @find-lineoffset ( return character offset from linestart )
306 306
 
307 307
 	#0000 =j
308
-	@find-lineoffset-loop NOP
308
+	$loop NOP
309 309
 		( incr ) ~j #0001 ADD2 =j
310
-		,find-lineoffset-end ~selection.from ~j SUB2 LDR #0a EQU JMP2? POP2
311
-		,find-lineoffset-end ~selection.from ~j SUB2 LDR #0d EQU JMP2? POP2
312
-		~selection.from ~j SUB2 ,document.body GTH2 ^find-lineoffset-loop MUL JMPS
313
-	@find-lineoffset-end 
310
+		,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2? POP2
311
+		,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2? POP2
312
+		~selection.from ~j SUB2 ,document.body GTH2 ^$loop MUL JMPS
313
+	$end 
314 314
 	( return ) ~j
315 315
 
316 316
 RTS
... ...
@@ -318,14 +318,14 @@ RTS
318 318
 @find-line ( position -> addr )
319 319
 
320 320
 	,document.body =j #0000 =pt.y
321
-	@find-line-loop NOP
322
-		,find-line-end ~pt.y ~position.y #0001 SUB2 GTH2 JMP2? POP2
323
-		,find-line-no-space ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
321
+	$loop NOP
322
+		,$end ~pt.y ~position.y #0001 SUB2 GTH2 JMP2? POP2
323
+		,$no-space ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
324 324
 			( incr ) ~pt.y #0001 ADD2 =pt.y
325
-		@find-line-no-space
325
+		$no-space
326 326
 		( incr ) ~j #0001 ADD2 =j
327
-	~j LDR #00 NEQ ^find-line-loop MUL JMPS
328
-	@find-line-end
327
+	~j LDR #00 NEQ ^$loop MUL JMPS
328
+	$end
329 329
 	( return ) ~j
330 330
 
331 331
 RTS
... ...
@@ -336,12 +336,12 @@ RTS
336 336
 
337 337
 	#0000 =pt.x
338 338
 
339
-	@find-selection-loop NOP
340
-		,find-selection-end ~j ~pt.x ADD2 LDR #0a EQU JMP2? POP2
341
-		,find-selection-end ~j ~pt.x ADD2 LDR #0d EQU JMP2? POP2
339
+	$loop NOP
340
+		,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2? POP2
341
+		,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2? POP2
342 342
 		( incr ) ~pt.x #0001 ADD2 =pt.x
343
-		~pt.x ~position.x #0001 SUB2 LTH2 ^find-selection-loop MUL JMPS
344
-	@find-selection-end
343
+		~pt.x ~position.x #0001 SUB2 LTH2 ^$loop MUL JMPS
344
+	$end
345 345
 	( return ) ~pt.x ADD2
346 346
 
347 347
 RTS
... ...
@@ -350,18 +350,18 @@ RTS
350 350
 	
351 351
 	,document.body =selection.from #0000 =pt.x #0000 =pt.y
352 352
 
353
-	@select-loop
354
-		,no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2? POP2
353
+	$loop
354
+		,$no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2? POP2
355 355
 			( incr ) ~pt.y #0001 ADD2 =pt.y
356 356
 			#0000 =pt.x
357
-		@no-space
358
-		,no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2? POP2
357
+		$no-space
358
+		,$no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2? POP2
359 359
 			~selection.from #0001 ADD2 =selection.to
360 360
 			RTS
361
-		@no-reached
361
+		$no-reached
362 362
 		( incr ) ~pt.x #0001 ADD2 =pt.x
363 363
 		( incr ) ~selection.from #0001 ADD2 =selection.from
364
-	,select-loop ~selection.from LDR #00 NEQ JMP2? POP2
364
+	,$loop ~selection.from LDR #00 NEQ JMP2? POP2
365 365
 
366 366
 RTS
367 367
 
... ...
@@ -392,17 +392,17 @@ RTS
392 392
 	
393 393
 	#0000 =j
394 394
 	#0000 =SPRT.x #0000 =SPRT.y
395
-	@draw-lines-loop
395
+	$loop
396 396
 		~scroll.y ~j ADD2 =addr
397 397
 		#0000 =SPRT.x
398 398
 		,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
399
-		( draw ) #02 ~addr ~position.y EQU2 #06 MUL ADD =SPRT.color
399
+		( draw ) #02 ~addr ~position.y EQU2 #0c MUL ADD =SPRT.color
400 400
 		#0008 =SPRT.x
401 401
 		,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
402
-		( draw ) #02 ~addr ~position.y EQU2 #06 MUL ADD =SPRT.color
402
+		( draw ) #02 ~addr ~position.y EQU2 #0c MUL ADD =SPRT.color
403 403
 		( incr ) ~j #0001 ADD2 =j
404 404
 		( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
405
-		,draw-lines-loop ~j ~SCRN.height #0008 SUB2 #0008 DIV2 NEQ2 JMP2? POP2
405
+		,$loop ~j ~SCRN.height #0008 SUB2 #0008 DIV2 NEQ2 JMP2? POP2
406 406
 
407 407
 RTS
408 408
 
... ...
@@ -469,9 +469,9 @@ RTS
469 469
 
470 470
 	#0018 =SPRT.x
471 471
 
472
-	@draw-textarea-loop
472
+	$loop
473 473
 
474
-		,draw-textarea-end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2
474
+		,$end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2
475 475
 
476 476
 		( get character )
477 477
 		,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr
... ...
@@ -481,29 +481,29 @@ RTS
481 481
 		~j ~selection.to LTH2 #0101 EQU2
482 482
 		#05 MUL ADD =SPRT.color
483 483
 
484
-		,no-linebreak ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
484
+		,$no-linebreak ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
485 485
 			( draw linebreak )
486 486
 			,linebreak_icn =SPRT.addr
487
-			( draw ) #03
487
+			( draw ) #02
488 488
 			~j ~selection.from #0001 SUB2 GTH2 
489 489
 			~j ~selection.to LTH2 #0101 EQU2
490
-			#05 MUL ADD =SPRT.color
490
+			#06 MUL ADD =SPRT.color
491 491
 			( fill clear )
492
-			@fill-clear
492
+			$fill-clear
493 493
 				( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
494 494
 				,font =SPRT.addr
495 495
 				#01 =SPRT.color
496
-				,fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2
496
+				,$fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2
497 497
 			#0010 =SPRT.x
498 498
 			( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
499
-		@no-linebreak
499
+		$no-linebreak
500 500
 
501 501
 		( incr ) ~j #0001 ADD2 =j
502 502
 		( incr ) ~SPRT.x #0007 ADD2 =SPRT.x
503 503
 
504
-	,draw-textarea-loop ~j LDR #00 NEQ JMP2? POP2
504
+	,$loop ~j LDR #00 NEQ JMP2? POP2
505 505
 
506
-	@draw-textarea-end
506
+	$end
507 507
 
508 508
 RTS
509 509
 
... ...
@@ -513,10 +513,10 @@ RTS
513 513
 	#0000 =SPRT.y
514 514
 	,scrollbar_bg =SPRT.addr
515 515
 
516
-	@draw-scrollbar-loop
516
+	$loop
517 517
 	( draw ) #08 =SPRT.color
518 518
 	( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
519
-	,draw-scrollbar-loop ~SPRT.y ~SCRN.height LTH2 JMP2? POP2
519
+	,$loop ~SPRT.y ~SCRN.height LTH2 JMP2? POP2
520 520
 
521 521
 	#0000 =SPRT.y
522 522
 	,arrowup_icn =SPRT.addr
... ...
@@ -536,16 +536,14 @@ RTS
536 536
 @draw-titlebar
537 537
 	
538 538
 	#0018 ~SCRN.height #0008 SUB2 #09 ,filepath 
539
-
540 539
 	( load ) =label.addr =label.color =SPRT.y =SPRT.x 
541 540
 	~label.addr
542
-	@draw-titlebar-loop NOP
541
+	$loop NOP
543 542
 		( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =SPRT.addr ~label.color =SPRT.color
544 543
 		( incr ) #0001 ADD2
545 544
 		( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
546
-		DUP2 LDR #00 NEQ ^draw-titlebar-loop MUL JMPS
545
+		DUP2 LDR #00 NEQ ^$loop MUL JMPS
547 546
 	POP2
548
-
549 547
 	( selection )
550 548
 	~selection.from ,document.body SUB2 ,draw-short JSR2
551 549
 
... ...
@@ -625,8 +623,8 @@ RTS
625 623
 @arrowdown_icn [ 0010 1010 fe7c 3810 ]
626 624
 @load_icn      [ feaa d6aa d4aa f400 ]
627 625
 @save_icn      [ fe82 8282 848a f400 ]
628
-@filepath1     [ projects/examples/jumptest.usm 00 ]
629
-@filepath      [ projects/software/left.usm 00 ]
626
+@filepath      [ projects/examples/gui.hover.usm 00 ]
627
+@filepath1     [ projects/software/left.usm 00 ]
630 628
 
631 629
 |4000 ;document Document
632 630
 
... ...
@@ -641,4 +639,4 @@ RTS
641 639
 |FF60 ;FILE File
642 640
 
643 641
 |FFF0 .RESET .FRAME .ERROR ( vectors )
644
-|FFF8 [ a0fe a0f7 a0f2 ] ( palette )
642
+|FFF8 [ 30ff e0f3 b0f3 ] ( palette )