Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Raylin on March 23, 2010, 01:48:50 pm
-
I've looked at a bunch of different programs and a lot of them use bytes explicitly.
I was just wondering...
How would a TI-BASIC programmer use these bytes?
What would I use them for?
Could you break it down to a level a noob (well... ASM noob) could understand?
For example, Builderboy was talking about how he used bytes in Portal X to do something...
Any clarity on the topic will be greatly appreciated. :)
-
Do you know how hexidecimal works?
-
What do you mean?
-
If I said, what does 0A represent, you would say...
-
It looks like a memory address... Or 10 in Base-10.
-
Or 10 in Base-10.
There you go! So, when you do this in Axe:
[010203
it stores three bytes to the end of the binary. They are as follows:
01
02
03
Who'd a thunk? ;) So, let's say you do this:
[010203->GDB1
Then, when you do this:
{GDB1}->A
01 is stored to A.
Also, if you do this:
{GDB1+1}->A, you get 02 stored to A. Kapeesh?
-
Oooooohhh. I get it. So, how would you store more than that to something?
*Prophet thinks about making an animated sprite
-
Instead of [010203, do [01020304 ;)
-
I mean, how do you have Axe extract more data than just those two values?
Instead of just 01, how do I make it take 0102 and evaluate it?
-
{GDB1}r->A
Puts 0102 into A
-
So, 01 is actually one byte... And 0102 would be two bytes...
This means that everything involving bytes would be in hex.
Correct?
-
Yes.
*EDIT*
Unless you do
5->{GDB1}
-
What happened there?
Are you allowed to drop the zeros?
-
Not hex
-
Ahh. That would make sense.
Axe allows you to access all memory to store data...
-
...and lets you store your own, too!
You can store at compile time using hex. You can store/retrieve at execution time using decimal or hex.
-
Explain that one a bit. o_o
-
So, in your source code, you can define data in terms of hex, like so:
[0102030A
This is taken at compile time and placed into the binary.
You can also specify in your source code:
E0A to use a hex digit or group of hex digits. You could also specify:
17 to use a decimal digit or group of decimal digits.
-
How would you retrieve that data?
A little more clarity is needed... :(
-
Hex:
E0A->{GDB1}
{GDB1}->A ; A now equals ten
Decimal
10->{GDB1}
{GDB1}->A
-
You retrieve data by naming it. If you store 100 bytes of data to memory and name that location "Str1" then you can access the entire 100 bytes with {Str1} for the first byte, {1+Str1} for the second byte, {2+Str1} for the third byte, or even {N+Str1} for the N-1th byte. Same as how you would in BASIC do L1(N).
-
Ahh.
Thank you so much.
Clarity is truly refreshing.
EDIT: OMG! Revelation!
*Prophet runs away to program
HINT: This has to do with ARMY.
Look below.
It is a project I had on hold...
Until now...
-
lol nice ^^
weren't you supposed to finish Lemonade Tycoon in 24 hours, though? :P /me runs `-`
-
*Prophet dive-tackles DJ
THE TRUTH MUST NOT BE KNOWN!
RAWR!
Yes, it was to be done in 48 HOURS.
But, a BSOD kicked my arse.
So... yeah...
LEMONADE TYCOON STILL WON GOLD!
>:D
-
aw that sucks about the BSOD x.x
Glad you won though
-
So I just read this whole thing, what exactly is meant by "using bytes" and such?
@Prophet
Congrats on the win, what is BSOD though? ???
-
blue screen of death
-
Ah, ya, that makes sense. That always sucks :(
-
my dad was the one who taught me that term (BSOD).. xD
-
Yeah there is often the misconception between bytes and numbers, and the thing is, Bytes are numbers! :) In Axe there are two ways to represent a byte (number), in Hex or in Decimal. Hex is easy to store bytes in because it is closely related to binary, and yet Decimal is easy for programmers to write in because we live in base 10 :)
-
Ohhhhhhhhhhhhhhhhhhhhhh, so basically this is just about storing numbers to variables then?
-
Right, if you wanted to store 10 to A, you could do
10->A
Or you could do
'0A->A
Because in Axe, the ' token means that you are in Hex, and 0A in Hex = 10 in Dec :). Currently the only way to store data into Ram is by Hex, like this:
[010AFF]->Str1
which ends up looking like this in Ram
{1,10,255}
Hopefully in the future you will be able to input data like this as well :) But no matter how you put the data in, it is always extracted as Decimal.
-
Ok, that makes this topic make a lot more sense to me :) Thanks Builderboy. What exactly do you mean storing data into RAM though? (Celtic III does something like this too? (Thought I remember something like that being said somewhere.))
-
Well since Axe compiles to Assembly, it means you have control over the entire calc, including allll the Ram ;) All the ram is is really just a long list of numbers. Each number ranges from 0 to 255 and there are thousands of these numbers in your Ram. Think of it like a list in Basic, except its a very very large List :) Well in order to access this list, all you need to do is do
{N}
And you will be able to store to or access the Nth byte in Ram, yay!
BUT WAIT!!!
Th calculator needs a lot of this Ram for itself, so that it can continue to run, so that there is someplace safe to store all your programs, and so that there is somewhere safe to store the current program. So you can't just go storing numbers to {0} you'll probably crash your calc :P. Luckily Axe provides us with some safe locations that are known to be safe to use. These locations are stored in L1-L6. So if you say 5->{L1}, you are actually storing to location 34594, but you would never know that it was safe to store there without being an asm guru :P So Axe provides you with these locations in the big List of Ram elements that it is safe to store to, and thats there you can keep all your bytes ^^
-
So basically doing {L1} is the same as doing {34594}? But one thing I don't get is why do you need to store to RAM exactly? Couldn't you just store to variable like "A" or is this different or what?
-
Except L3 through L6 are not as safe as L1 and L2. You need to read the doc carefully before using them, in case
-
So basically doing {L1} is the same as doing {34594}? But one thing I don't get is why do you need to store to RAM exactly? Couldn't you just store to variable like "A" or is this different or what?
If you want to make a list of numbers, it won't work too well to use A-Z to hold them. That's what all that RAM is for.
-
Well actually A is a number in RAM just like all the other variables. (Well its a combination of 2 numbers in RAM since its 16 bit, not 8 bit) And indeed you can store numbers to A or any of the other variables if you want :) But for circumstances where you need a variable amount of number (like an undefined amount of bullets on the screen) you would need a lot more numbers than just A-Z, and an easier way to access them.
-
Well now I'm a little confused again. Because from what calc84 said it sounded like RAM is used as like a list and variable in one. But then you, Builderboy, made it sound like its just like obtaining more variables to use. (I really need to learn more about this stuff some how haha.)
By the way, thanks you guys for help explaining this stuff :)
-
Hah, well then we're on the right track because it could be used as both :)
If you were already using 26 variables and needed more, we could easily substitute {L1} as a variable, and {L1+1} as another ect...
BUT
If you wanted a list, you could do {L1+N} where N is the element of your List (starting at 0) to access a lot of different numbers in the range from L1 to about L1+700.
-
Question.
Is there a way to make a file or a variable that will stay alive after the program dies?
Basically, is there a way to make a savefile?
-
Not yet (officially) but there is something that does write back on all stored Hex data so that it stays the same between excecutions. Its in another thread somewhere...
-
not yet really, but it's going to be added soon
although you can implement program writeback (see routines thread)
EDIT: ninja!
-
Oh ok, that makes sense :)
-
So, since I'm still a noob on bytes and Axe...
Could someone show me a way or a workaround for save files...?
-
Because in Axe, the ' token means that you are in Hex, and 0A in Hex = 10 in Dec :). Currently the only way to store data into Ram is by Hex, like this:
[010AFF]->Str1
which ends up looking like this in Ram
{1,10,255}
Hopefully in the future you will be able to input data like this as well :) But no matter how you put the data in, it is always extracted as Decimal.
You might have missed it in the new update. That was added already! Its the deltalist command.
-
Hmm...
I looked at the program writeback function.
L1: Asm(21788411E389010900EDB0) \ Asm(21E389E7EFF1421A4F131A4713131321959D0B0BEDB0)
L2: Asm(21788411448D010900EDB0) \ Asm(21448DE7EFF1421A4F131A4713131321959D0B0BEDB0)
How does it work?
I mean, if someone wrote to GBD1, Pic1, and Str1, are you saying that the program will save all of those values?
And, if that's the case, then how do you delete or clear out the data you don't need saved?
-
Yes, it would. And you can't clear out the data. Sorry.
At some point I will write a routine to let you save to a specific AppVar or something.
-
That would be nice...
And, are you serious when you say you can't clear out the data?
Not even in the Axe program itself?
You can't delete the data in the pointer?
-
Yes. You can delete the data, of course, but if you set {GDB1} from 0 to 1, it will stay at 1 until you change it back.
-
Okay.
Good.
:)
I can work with that.
Also, THANK YOU for your help with bytes.
It has helped IMMENSELY.
-
Of course.