From 481a318732f4c349ee7b1acaad5f061ef2211d75 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 14 Mar 2021 15:17:00 -0700 Subject: [PATCH] Optimized some example files --- README.md | 1 + projects/examples/dev.screen.usm | 30 +++++++++++++----------- projects/tests/loop.usm | 40 +++++++++++++++++++++++++------- 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 28102c9..435e98d 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ RTN - Don't brk when return stack is not zeroed - LDRS should load from the zeropage? - Keep ref counts in macros +- A fast way(2 bytes) to read from the zero page #aa LDR. ### Macros diff --git a/projects/examples/dev.screen.usm b/projects/examples/dev.screen.usm index 923634e..d82902e 100644 --- a/projects/examples/dev.screen.usm +++ b/projects/examples/dev.screen.usm @@ -2,7 +2,6 @@ ;center { x 2 y 2 } ;timer { byte 1 } -;i { byte 1 } |0100 @RESET @@ -12,26 +11,31 @@ ( draw hor line ) #0000 =Screen.x ~center.y =Screen.y - $draw-hor + #0000 ~Screen.width ( from/to ) + $draw-hor NOP ( draw ) #01 =Screen.color - ( incr ) ~Screen.x #0002 ADD2 =Screen.x - ,$draw-hor ~Screen.x ~Screen.width LTH2 JMP2? POP2 + ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2 + OVR2 OVR2 LTH2 ^$draw-hor SWP JMPS? POP + POP2 POP2 ( draw ver line ) ~center.x =Screen.x #0000 =Screen.y - $draw-ver + #0000 ~Screen.height ( from/to ) + $draw-ver NOP ( draw ) #02 =Screen.color - ( incr ) ~Screen.y #0002 ADD2 =Screen.y - ,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2? POP2 + ( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2 + OVR2 OVR2 LTH2 ^$draw-ver SWP JMPS? POP + POP2 POP2 ( draw blending modes ) - #00 =i #0020 =Sprite.x #0020 =Sprite.y ,icon =Sprite.addr - $draw-blends - ( draw ) #00 ~i ADD =Sprite.color - ( incr ) ~Sprite.x #0008 ADD2 =Sprite.x - ( incr ) ~i #01 ADD =i - ,$draw-blends ~i #10 LTH JMP2? POP2 + #00 #10 + $draw-blends NOP + ( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x + ( draw ) OVR =Sprite.color + ( incr ) SWP #01 ADD SWP + DUP2 LTH ^$draw-blends SWP JMPS? POP + POP POP BRK diff --git a/projects/tests/loop.usm b/projects/tests/loop.usm index 5a56fbb..a9dd801 100644 --- a/projects/tests/loop.usm +++ b/projects/tests/loop.usm @@ -4,38 +4,60 @@ |0100 @RESET - ,type1 JSR2 - ,type2 JSR2 - ,type3 JSR2 + ,slow-muljmp JSR2 + ,slow-jmppop JSR2 + ,slow-jmppop-rel JSR2 + ,fast-byte JSR2 + ,fast-short JSR2 BRK -@type1 ( type: padded muljmp ) +|0200 @slow-muljmp ( type: padded muljmp ) $loop NOP ~a #01 ADD =a ~a #d0 LTH ^$loop MUL JMPS ~a =Console.byte -RTS +RTN -@type2 ( type: jmppop ) +|0300 @slow-jmppop ( type: jmppop ) $loop ~b #01 ADD =b ,$loop ~b #d0 LTH JMP2? POP2 ~b =Console.byte -RTS +RTN -@type3 ( type: padded jmppop ) +|0400 @slow-jmppop-rel ( type: padded jmppop ) $loop NOP ~c #01 ADD =c ~c #d0 LTH ^$loop SWP JMPS? POP ~c =Console.byte -RTS +RTN + +|0500 @fast-byte ( fast byte ) + + #00 #d0 + $loop NOP + ( incr ) SWP #01 ADD SWP + DUP2 LTH ^$loop SWP JMPS? POP + POP =Console.byte + +RTN + +|0600 @fast-short ( fast short ) + + #0000 #0d00 + $loop NOP + ( incr ) SWP2 #0001 ADD2 SWP2 + OVR2 OVR2 LTH2 ^$loop SWP JMPS? POP + POP2 =Console.short + +RTN |c000 @FRAME |d000 @ERROR