From 25a8d7b49734fb8dbcd559cb6ab39ad0b99e3a57 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 31 May 2018 12:47:28 -0400 Subject: [PATCH] entropy: shave another byte off thanks to Nick Westgate --- two-liners/README.entropy | 2 +- two-liners/entropy.dsk | Bin 143360 -> 143360 bytes two-liners/entropy.s | 22 ++++++++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/two-liners/README.entropy b/two-liners/README.entropy index aa03cdb1..726c5554 100644 --- a/two-liners/README.entropy +++ b/two-liners/README.entropy @@ -52,7 +52,7 @@ This sound simple, but it leads to some neat patterns. ======================= I thought it would be neat to see how small I could make this in assembly -language. Currently I have it down to 119 bytes (the executable is 123 +language. Currently I have it down to 118 bytes (the executable is 122 bytes because DOS33 includes size/address filesystem metadata in the file itself). diff --git a/two-liners/entropy.dsk b/two-liners/entropy.dsk index ec237394a8703bd65f5ae4cebe5b4a42ee866aa8..dfb654a028677e8b4daceca4258497a27c178e9d 100644 GIT binary patch delta 90 zcmV-g0Hyzc;0S==2!ON!9xeegw;wJ6;{p|W03g`&q6miksRT%=1cm*g0EYhPml!bt wHUV&#PcZ=%8nS3<1Hjf diff --git a/two-liners/entropy.s b/two-liners/entropy.s index ecffaa09..a33fdbef 100644 --- a/two-liners/entropy.s +++ b/two-liners/entropy.s @@ -2,7 +2,7 @@ ; by Dave McKellar of Toronto ; Two-line BASIC program ; Found on Beagle Brother's Apple Mechanic Disk -; Converted to 6502 Assembly by Vince Weaver +; Converted to 6502 Assembly by Deater (Vince Weaver) vince@deater.net ; 24001 ROT=0:FOR I=1 TO 15: READ A,B: POKE A,B: NEXT: DATA ; 232,252,233,29,7676,1,7678,4,7679,0,7680,18,7681,63, @@ -26,9 +26,12 @@ ; 126 bytes: nextx: simplify by using knowledge of possible x/y vals ; 124 bytes: qkumba noticed we can bump yloop up to include the ; pha, letting us remove two now unneeded stack ops -; 123 byts: qkumba noticed XDRAW0 always exits with X==0 so +; 123 bytes: qkumba noticed XDRAW0 always exits with X==0 so ; we can move some things to use X instead and ; can get a "1" value simply by using INX +; 122 bytes: Nick Westgate noticed that we could save a byte +; in eloop by pushing the stx ELOOP to the beginning +; rather than the end. ;BLT=BCC, BGE=BCS @@ -69,11 +72,14 @@ XDRAW0 = $F65D entropy: jsr HGR2 ; Hi-res graphics, no text at bottom + ; Y=0, A=$60 after this call - lda #8 ; Unlike the BASIC, our loop is *100 - sta EPOS ; 8 to 15 rather than .08 to .15 - + ldx #8 ; Unlike the BASIC, our loop is *100 + ; 8 to 15 rather than .08 to .15 eloop: + stx EPOS ; EPOS was temporarily in X + + lda #4 ; FOR Y=4 to 189 STEP 6 yloop: pha ; YPOS stored on stack @@ -196,9 +202,9 @@ nexty: ; NEXT Y bcc yloop ; if so, loop nexte: ; NEXT E - inc EPOS - lda EPOS - cmp #15 + ldx EPOS + inx ; EPOS saved at beginning og eloop + cpx #15 bcc eloop ; branch if <15 bcs entropy