- Axe Parser Programs optimization tricks
- 15 Jan 2013 10:48:03 am
- Last edited by Guest on 16 Jan 2013 10:18:59 am; edited 1 time in total
So I have been working with Axe lately, and I've made a random walk generator.
Here's the code:
Code:
This program compiles to 494 bytes (Axe Fusion on DCS7, Axe Parser 1.2.1a)
Originally it compiled to about 653 bytes under the same specs because I used ElseIf commands instead of Else commands at the ends of the loops.
For instance, I used this at first:
Code:
instead of:
Code:
and I used this at first:
Code:
instead of this:
Code:
I was wondering, if just changing the last command of a loop from ElseIf to Else can save so much memory, what else can I do to optimize this program (and others) further?
Here's the code:
Code:
.BROWNIAN
#ExprOff
sub(RS)
Repeat getKey(15)
If getKey(41)
ClrDraw
sub(RS)
End
rand^8->R
If R=0
Y--
ElseIf R=1
Y++
ElseIf R=2
X--
ElseIf R=3
X++
ElseIf R=4
X++:Y++
ElseIf R=5
X++:Y--
ElseIf R=6
X--:Y--
Else
X--:Y++
End
If X=96:0->X
ElseIf X=-1:95->X
End
If Y=64:0->Y
ElseIf Y=-1:63->Y
End
pxl-Test(X,Y)->A
If A
Pxl-Off(X,Y)
Else
Pxl-On(X,Y)
End
DispGraph
End
Lbl RS
48->X:32->Y
This program compiles to 494 bytes (Axe Fusion on DCS7, Axe Parser 1.2.1a)
Originally it compiled to about 653 bytes under the same specs because I used ElseIf commands instead of Else commands at the ends of the loops.
For instance, I used this at first:
Code:
ElseIf R=7
X--:Y++
instead of:
Code:
Else
X--:Y++
and I used this at first:
Code:
If A=1
Pxl-Off(X,Y)
ElseIf A=0
Pxl-On(X,Y)
End
instead of this:
Code:
If A
Pxl-Off(X,Y)
Else
Pxl-On(X,Y)
End
I was wondering, if just changing the last command of a loop from ElseIf to Else can save so much memory, what else can I do to optimize this program (and others) further?