From 4e9ca47e383b897f6604fa48cfde6face0ef56fd Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 10 Feb 2021 19:05:40 -0800 Subject: [PATCH] Cleaned up examples --- examples/blank.usm | 3 +++ examples/hello.usm | 32 ++++++++++++++------------------ examples/pixel.usm | 2 +- examples/pixels.usm | 24 +++++++++++------------- examples/test.usm | 4 +--- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/examples/blank.usm b/examples/blank.usm index 663a0e9..ee7a26a 100644 --- a/examples/blank.usm +++ b/examples/blank.usm @@ -1,5 +1,8 @@ ( blank ) +:dev/r fff8 ( std read port ) +:dev/w fff9 ( std write port ) + |0100 @RESET BRK |c000 @FRAME BRK |d000 @ERROR BRK diff --git a/examples/hello.usm b/examples/hello.usm index 6ca78b5..0af0fbd 100644 --- a/examples/hello.usm +++ b/examples/hello.usm @@ -1,29 +1,25 @@ -( hello world ) +( hello world, to console ) -;iterator +:dev/w fff9 ( const write port ) +;i 1 ( var iterator ) |0100 @RESET -@word1 "hello_world ( len: 0x0b ) + ,00 ,dev/w STR ( set dev/write to console ) -@loop - IOW ( write to device#0 ) - ,incr JSR ( increment itr ) - ,word1 ,strlen JSR ( get strlen ) - NEQ ,loop ROT JSR? ( loop != strlen ) + @word1 "hello_world ( len: 0x0b ) + + @loop + IOW ( write to device#0 ) + ,incr JSR ( increment itr ) + ,i LDR ( a = i ) + ,word1 ,strlen JSR ( b = string length ) + NEQ ,loop ROT JSR? ( a != b ? loop ) BRK -@strlen - ,0001 ADD^ LDR - RTS - -@incr - ,iterator LDR - ,01 ADD - ,iterator STR - ,iterator LDR - RTS +@strlen ,0001 ADD^ LDR RTS +@incr ,i LDR ,01 ADD ,i STR RTS |c000 @FRAME BRK |d000 @ERROR BRK diff --git a/examples/pixel.usm b/examples/pixel.usm index 4311eaa..7c6409f 100644 --- a/examples/pixel.usm +++ b/examples/pixel.usm @@ -1,4 +1,4 @@ -( draw pixel ) +( draw a single pixel ) :dev/w fff9 ( keep write port in a const ) ;x 2 diff --git a/examples/pixels.usm b/examples/pixels.usm index 4e7d897..8ac23bb 100644 --- a/examples/pixels.usm +++ b/examples/pixels.usm @@ -3,7 +3,7 @@ :dev/r fff8 ( std read port ) :dev/w fff9 ( std write port ) -;x 2 ;y 2 ;color 1 +;x 2 ;y 2 ;color 1 ;alive 1 |0100 @RESET @@ -11,36 +11,34 @@ ,01 ,color STR ( set color ) ,0020 ,x STR^ ( set x-pos ) ,0030 ,y STR^ ( set y-pos ) + ,01 ,alive STR ( set alive = true ) BRK |c000 @FRAME - ,colorize JSR - ,move JSR - ( draw ) + ,alive LDR ,00 EQU BRK? ,01 ,color LDR ,x LDR^ ,y LDR^ ,putpixel JSR + ,move JSR BRK -@colorize - ,color LDR ,01 ADD ,color STR ( incr color ) - ,color LDR ,04 LTH RTS? - ,01 ,color STR - RTS - @move ,x LDR^ ,0001 ADD^ ,x STR^ ( incr x ) - ,x LDR^ ,0060 LTH^ RTS? ( if x > 60 ) + ,x LDR^ ,0040 LTH^ RTS? ( if x > 60 ) ,0020 ,x STR^ ( x = 0x0020 ) ,y LDR^ ,0001 ADD^ ,y STR^ ( incr y ) + + ,y LDR^ ,0050 LTH^ RTS? ( y > 50 ) + ,00 ,alive STR ( alive = 0 ) + RTS @putpixel IOW^ ( y short ) IOW^ ( x short ) - IOW ( color byte ) - IOW ( redraw byte ) + IOW ( color byte ) + IOW ( redraw byte ) RTS |d000 @ERROR BRK diff --git a/examples/test.usm b/examples/test.usm index 7de7ebd..89d472b 100644 --- a/examples/test.usm +++ b/examples/test.usm @@ -1,11 +1,9 @@ -( my default test file ) +( my test file, junk ) :dev/r fff8 ( std read port ) :dev/w fff9 ( std write port ) |0100 @RESET - - ,01 ,dev/w STR ( set dev/write screen#01 ) BRK