Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: bored_student on October 31, 2012, 12:22:17 pm

Title: static vars
Post by: bored_student on October 31, 2012, 12:22:17 pm
I wanted to make my program code more clear.
So I decided to use static vars that replace some L1+... commands:
example:
Code: [Select]
L1+12 -> GDB0XVAL
L1+14 -> GDB0YVAL
...
X -> {GDB0XVAL}R
Y -> {GDB0YVAL}R

Is this slower than this:
Code: [Select]
X -> {L1+12}R
Y -> {L1+14}R
or is it the same after compiling
Title: Re: static vars
Post by: Eeems on October 31, 2012, 12:29:58 pm
If it is a static var then I would assume that it would be the same speed. Static variables should be replaced by the actual value on compile if it's anything like static variables in other languages.
Title: Re: static vars
Post by: Hayleia on October 31, 2012, 12:49:52 pm
If you want to make it even clearer, you can do that:

L1+12→°XVAL
L1+14→°YVAL
...
X→XVAL
Y→YVAL

What you did there is declare two new custom variables, XVAL and YVAL, whose bytes are located at L1+12 and L1+14 ;)

edit
note that the ° is the degree symbol in Angle (2nd Apps).
Title: Re: static vars
Post by: bored_student on October 31, 2012, 01:03:40 pm
thank you a lot  ;D

I have never read that you can do something like that   O.O
So I can easily make new vars.
How many characters can I use to name them and
from where do you know such things?
Title: Re: static vars
Post by: Eeems on October 31, 2012, 01:24:25 pm
You might find reading the documents here useful: http://axe.eeems.ca/
Title: Re: static vars
Post by: Hayleia on October 31, 2012, 02:39:43 pm
How many characters can I use to name them and
from where do you know such things?
You can have up to 5 characters. I think the first one has to be an uppercase letter but maybe I am wrong.
And I know this kind of things by asking questions on this awesome website that is Omnimaga ;)
Title: Re: static vars
Post by: bored_student on November 01, 2012, 02:53:44 pm
You might find reading the documents here useful: http://axe.eeems.ca/
This are the files included in the Axe download but I cant find something like
const -> °Var 

however now I know it
thank you both you have helped me a lot :)
Title: Re: static vars
Post by: shmibs on November 01, 2012, 06:31:35 pm
if you are storing the value to a variable then i am fairly certain it will be slower. i think the axe compiler simplifies L1+whatever to a single, in-line constant value, while accessing the other will first store the value to a different position in RAM during execution and then have to recall that value from the position in RAM when it is calling the value later.
Title: Re: static vars
Post by: squidgetx on November 01, 2012, 08:48:49 pm
The custom variable method was created to make creating custom variables relatively easily.
x->{L1+2}r is the same speed and size as L1+2->oVAR : x->VAR

Note that you can abuse the custom variable system to create named constants, similar to finals in java, only you can actually notice the speed difference. For example, 32->oMapW allows you to use oMapW in place of 32, anywhere in your code. Useful for debugging and clarity :)