Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: parserp on September 08, 2011, 09:17:50 pm

Title: programming help?
Post by: parserp on September 08, 2011, 09:17:50 pm
Could someone please direct me or explain to me what all the brackets, lists, and r1-6 's are? I am a basic programmer, currently making the switch to axe. Thank you!
Title: Re: programming help?
Post by: AngelFish on September 08, 2011, 09:28:36 pm
Quick summary before I'm ninja'd:

Brackets enclose Hexadecimal to be inserted directly into the program. For example:

Quote
[0123456789ABCDEF] →Str1

Stores the hexadecimal 0x0123456789ABCDEF somewhere in the program, then sets the value of Str1 equal to address of the memory location it's stored at (i.e. makes Str1 a pointer to the hex).

Lists are even more simple than brackets. Basically, they're sections of free memory that you can use in your program without explicitly allocating them. Just use L1-L6 as pointers to memory. The sizes of those sections (aka buffers) can be found in the html command documentation.

If any of the above is confusing or you aren't familiar with the terminology, just ask :)

Welcome to the forums.
Title: Re: programming help?
Post by: LincolnB on September 08, 2011, 09:28:56 pm
You may be interested in our extensive collection of Axe Parser Tutorials:

http://www.omnimaga.org/index.php?action=articles;cat=12

Browse around there, there really is a whole bunch of useful stuff.

Also, be sure to check out the Axe Documentation.pdf file, the Commands.html file, and stuff like that. The commands.html file isn't so thorough, but it explains all the commands you can use, and gets you started so you can experiment with test-like programs to really figure stuff out. I remember reading about r1-r6 in Commands.html and thinking, uh, what? But it was all I needed to know to experiment and figure out what it meant.

Good luck :)

EDIT: Also, in case you don't already know, r1-r6 are found by pressing [vars]
[3] or something like that.
Title: Re: programming help?
Post by: mrmprog on September 08, 2011, 09:49:13 pm
Welcome to the forums! The Axe documentation is a very good place to start. It can be overwhelming at first, especially some of the lower level stuff, but if you keep working at it, it will all become clear. The way I learned was by experimentation. I would look up something in the command list, and then try it. If you do this though, expect a few many ram clears  ;)
Title: Re: programming help?
Post by: Michael_Lee on September 08, 2011, 10:13:04 pm
I would highly recommend you look up pointers.  They're basically related to low-level manipulation of memory.  Googling it would pull up a bunch of explanations in C/C++, so ignore the specifics of the syntax and focus on trying to understand the concept.

Code: [Select]
.TEST

Text(0,0,L1>Dec)
Pause 1000

(The '>Dec' token can be found in the number menu).

L1 can be thought of as a constant that tells you the start of some free memory you can much around in.  Let's say (hypothetically speaking) that running the above program displayed the number '541'.  That means that starting from the 541th byte in RAM, you have (according to the documentation) about 700 bytes to play around in -- from the 541th byte to about the 1241th byte (give or take a little).

If you want to store anything to those bytes, you use curly brackets.

Code: [Select]
.TEST2

3->{L1}
4->{L1+5}

Text(0,0,{L1}>Dec)
Text(0,8,{L1+5}>Dec)
Pause 100

This would store the number '3' to the 541th byte, and the number '4' to the 546th byte, and display first the number '3' then the number '4'.

Finding a segment of free memory (by using this method, or by allocating program memory/making an appvar, which is more complicated), is the only way you can have lists or arrays in Axe.

Sometimes, though, you just don't have enough free RAM to be able to do anything complex.

You can use square brackets to store raw data directly into your program.

Code: [Select]
.TEST3

[01020A0B]->P
That would store a bunch of hex (in this case, exactly 4 bytes), and store the pointer to the variable P.

If I did...

Code: [Select]
.TEST4

[01020A0B]->P

Text(0,0,{P+2}>Dec)
Pause 1000
That would display the 3rd byte (indexes start at zero), which would be the number '10' (in hex, 0A is ten).

This is a good way to store and read, say, a tilemap or level data.

r1 to r6 are variables, just like A, B, C, and D.  If you pass values to functions, they'll be stored to r1 to r6.

Also, one thing that tripped me up when I started Axe -- you don't need curly braces to store and read from simple variables like A, B, or r1.
Title: Re: programming help?
Post by: Freyaday on September 09, 2011, 11:38:16 am
In fact, trying to do {A} will just get you the Ath byte. In case you're using 0.5.3b and run out of vars, There are Axe's secret Vars, X/Yt1-3, accessible under the Parametric section of the Y-VARS menu that comes up when you press the VARS button (sorry if I'm overexplaining)