Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Raylin on March 23, 2010, 01:48:50 pm

Title: [Axe Parser] Bytes?
Post 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. :)
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 01:59:13 pm
Do you know how hexidecimal works?
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:00:36 pm
What do you mean?
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:01:25 pm
If I said, what does 0A represent, you would say...
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:03:02 pm
It looks like a memory address... Or 10 in Base-10.
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:05:15 pm
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?
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:07:16 pm
Oooooohhh. I get it. So, how would you store more than that to something?
*Prophet thinks about making an animated sprite
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:07:44 pm
Instead of [010203, do [01020304 ;)
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:10:06 pm
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?
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:15:35 pm
{GDB1}r->A
Puts 0102 into A
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:18:09 pm
So, 01 is actually one byte... And 0102 would be two bytes...
This means that everything involving bytes would be in hex.
Correct?
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:18:30 pm
Yes.

*EDIT*
Unless you do
5->{GDB1}
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:24:09 pm
What happened there?
Are you allowed to drop the zeros?
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:25:39 pm
Not hex
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:26:32 pm
Ahh. That would make sense.
Axe allows you to access all memory to store data...
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:29:33 pm
...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.
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:32:40 pm
Explain that one a bit. o_o
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:35:24 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 02:37:22 pm
How would you retrieve that data?
A little more clarity is needed... :(
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 23, 2010, 02:38:53 pm
Hex:
E0A->{GDB1}
{GDB1}->A    ; A now equals ten

Decimal
10->{GDB1}
{GDB1}->A
Title: Re: [Axe Parser] Bytes?
Post by: Quigibo on March 23, 2010, 03:07:49 pm
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).
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 03:51:18 pm
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...
Title: Re: [Axe Parser] Bytes?
Post by: DJ Omnimaga on March 23, 2010, 04:35:58 pm
lol nice ^^

weren't you supposed to finish Lemonade Tycoon in 24 hours, though? :P /me runs `-` 
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 04:38:47 pm
*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
Title: Re: [Axe Parser] Bytes?
Post by: DJ Omnimaga on March 23, 2010, 04:48:15 pm
aw that sucks about the BSOD x.x

Glad you won though
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 05:47:31 pm
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? ???
Title: Re: [Axe Parser] Bytes?
Post by: DJ Omnimaga on March 23, 2010, 05:49:41 pm
blue screen of death
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 06:23:12 pm
Ah, ya, that makes sense. That always sucks :(
Title: Re: [Axe Parser] Bytes?
Post by: Gale on March 23, 2010, 06:47:04 pm
my dad was the one who taught me that term (BSOD).. xD
Title: Re: [Axe Parser] Bytes?
Post by: Builderboy on March 23, 2010, 06:58:26 pm
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 :)
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 07:03:17 pm
Ohhhhhhhhhhhhhhhhhhhhhh, so basically this is just about storing numbers to variables then?
Title: Re: [Axe Parser] Bytes?
Post by: Builderboy on March 23, 2010, 07:06:48 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 07:09:39 pm
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.))
Title: Re: [Axe Parser] Bytes?
Post by: Builderboy on March 23, 2010, 07:17:51 pm
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 ^^
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 07:31:23 pm
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?
Title: Re: [Axe Parser] Bytes?
Post by: DJ Omnimaga on March 23, 2010, 07:32:23 pm
Except L3 through L6 are not as safe as L1 and L2. You need to read the doc carefully before using them, in case
Title: Re: [Axe Parser] Bytes?
Post by: calc84maniac on March 23, 2010, 07:33:07 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: Builderboy on March 23, 2010, 07:36:24 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 07:42:52 pm
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 :)
Title: Re: [Axe Parser] Bytes?
Post by: Builderboy on March 23, 2010, 07:48:31 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 08:03:10 pm
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?
Title: Re: [Axe Parser] Bytes?
Post by: Builderboy on March 23, 2010, 08:05:11 pm
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...
Title: Re: [Axe Parser] Bytes?
Post by: Eeems on March 23, 2010, 08:05:16 pm
not yet really, but it's going to be added soon
although you can implement program writeback (see routines thread)
EDIT: ninja!
Title: Re: [Axe Parser] Bytes?
Post by: meishe91 on March 23, 2010, 08:17:59 pm
Oh ok, that makes sense :)
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 23, 2010, 08:47:54 pm
So, since I'm still a noob on bytes and Axe...
Could someone show me a way or a workaround for save files...?
Title: Re: [Axe Parser] Bytes?
Post by: Quigibo on March 23, 2010, 09:46:37 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 25, 2010, 02:10:21 pm
Hmm...

I looked at the program writeback function.
Quote from: SirCmpwn
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?
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 25, 2010, 02:11:32 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 25, 2010, 02:24:22 pm
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?
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 25, 2010, 02:29:11 pm
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.
Title: Re: [Axe Parser] Bytes?
Post by: Raylin on March 25, 2010, 02:30:56 pm
Okay.
Good.
:)

I can work with that.
Also, THANK YOU for your help with bytes.
It has helped IMMENSELY.
Title: Re: [Axe Parser] Bytes?
Post by: SirCmpwn on March 25, 2010, 02:34:56 pm
Of course.