Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: ACagliano on September 02, 2010, 01:19:16 pm

Title: A Few Questions
Post by: ACagliano on September 02, 2010, 01:19:16 pm
lets say im using axe to move a string from Str1A to an appvar. How do i find out how many bytes the string is? This is a typical text string, not limited to hex or numbers, but can range from 0 to Z.

And, any issues with separating things with commas in that string? If yes, how should I separate them?


And, has Quigbo resolved the interrupt issue yet? The one where the Lbl was inconsistent with Goto?

 if you use asm to create a custom interrupt routine and keep that routine enabled when you exit to the TI-OS, should it continue to operate?
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 01:47:24 pm
lets say im using axe to move a string from Str1A to an appvar. How do i find out how many bytes the string is? This is a typical text string, not limited to hex or numbers, but can range from 0 to Z.

Well, strings like Str1A aren't really variables. They're just data inside the executable, just like all the other commands, except that it's not executed as a sequence of commands. Basically, you could put random command junk in the middle of the program and call it a string.

In ASM, strings like that "end" when the TI-OS or whatever you're using to read the string hits the value 0. When you put a string by itself in Axe like

Code: (Axe) [Select]
:"Hello"

all the parser does is add the sequence of hex digits [48656C6C6F] somewhere in the executable. But when you "store" it to a name, like

Code: (Axe) [Select]
:"Hello"→Str1A

Axe adds [48656C6C6F00] instead (with the extra zero byte). This is because commands like Disp display each hex value as a character until it hits the zero. So if you want to know how long a string is in Axe, you just have to count each digit in the string until you hit a zero.

And, any issues with separating things with commas in that string? If yes, how should I separate them?

Sorry, don't understand there.

And, has Quigbo resolved the interrupt issue yet? The one where the Lbl was inconsistent with Goto?

No idea. I haven't exactly been keeping my version of Axe up to date, unfortunately :P

if you use asm to create a custom interrupt routine and keep that routine enabled when you exit to the TI-OS, should it continue to operate?

Okay, that gets complicated. First of all, many things in the TI-OS need TI's default interrupt. To give you a picture of how screwed your calc would be if you didn't restore it, these include flashing the cursor and waiting for a keypress.

EDIT: I think there's a way to have the TI-OS go through your custom interrupt, then go through its own interrupt routine, so there aren't any problems. To do that, you add a Goto 58 at the end.
Title: Re: A Few Questions
Post by: DJ Omnimaga on September 02, 2010, 01:51:18 pm
Keep in mind that lowercase letters are 2 byte tokens, though, and that each will take two spots in memory rather than one.
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 01:52:41 pm
Keep in mind that lowercase letters are 2 byte tokens, though, and that each will take two spots in memory rather than one.

But for strings, I think they're converted to their characters by Axe before they're added to the executable.
Title: Re: A Few Questions
Post by: ACagliano on September 02, 2010, 01:53:03 pm
Am I correct in assuming that I could simply use Axe's length( command to get the size of the string?
Title: Re: A Few Questions
Post by: DJ Omnimaga on September 02, 2010, 01:54:53 pm
Keep in mind that lowercase letters are 2 byte tokens, though, and that each will take two spots in memory rather than one.

But for strings, I think they're converted to their characters by Axe before they're added to the executable.
I am confused what you mean, could you explain in more details ???
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 01:55:18 pm
Am I correct in assuming that I could simply use Axe's length( command to get the size of the string?

Yeah, I guess that would work. I'm still using Axe 0.2.6, so I haven't gotten there yet :D

Keep in mind that lowercase letters are 2 byte tokens, though, and that each will take two spots in memory rather than one.

But for strings, I think they're converted to their characters by Axe before they're added to the executable.
I am confused what you mean, could you explain in more details ???

Well, lowercase letters and 2-byte tokens are made up of characters, all of which are one byte. So in BASIC, the string "Hello" would be [48BBB4BBBCBBBCBBBF], since lowercase letters are two-byte tokens starting with BB. But in Axe, when you're storing a string like "Hello", you're storing the characters of each token, not the token itself. So in Axe, it'd be [48656C6C6F].

On a side note, I think a newer version of Axe allows you to add an actual token with the T command, but that's separate from these strings.

Here (http://tibasicdev.wikidot.com/83lgfont)'s a list of the TI-OS characters.

EDIT: 444th post! :D
Title: Re: A Few Questions
Post by: DJ Omnimaga on September 02, 2010, 02:05:46 pm
Aah ok I see. I thought they would also be stored in two memory addresses. I swear there were 2 byte tokens in Axe too, though.
Title: Re: A Few Questions
Post by: ACagliano on September 02, 2010, 02:14:33 pm
It's partially working. But not entirely. But its working to the point where i know the concept is right, just the technicals are wrong. Its displaying part of the string correctly, when I go to recall, then starts getting garbage, then crashes.
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 02:15:46 pm
Whoa, can you give us the code (if it's not a contest entry)?
Title: Re: A Few Questions
Post by: ACagliano on September 02, 2010, 02:27:34 pm
Code: [Select]
"appvBDefs"->Str2A
GetCalc(Str2A)->D
!If D
"AHA,AAHAA,BEEF,BEAT,CRASH,FAIL,HAHA,OFFBY1,PRANK,VIRUS,WINXX,XXX"->Str9Z
length(Str9Z)->V
GetCalc(Str2A,V)->D
conj(Str9Z,D,V)
End

Produces an 80 byte appvar, BDefs. Perfect.
Now, to recall

Code: [Select]
If D
length(D)->V
"0"->Str9Y
conj(D,Str9Y,V)
Disp Str9Y

Displays this: "AHA,AAHAA,BEEF,BEAT,CRASH,FAIL,HAHA,OFFBY1,P...garbage starts here...then

OOPS! Ram Cleared.
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 02:32:33 pm
Okay, I see your problem(s).

First of all, you can't just move 80 bytes into Str9Y. Str9Y isn't a string; it's just a label at the end of the program. If you copy stuff over to it, you're not expanding the size of the program. You're just overwriting the data after the program, which could be bad.

Secondly, "0" is not the same as [00]. The character '0' actually has value [30], which is a problem, as the Disp command you're using wouldn't stop there. Instead, it would keep going after the "0" until it hits an actual [00].
Title: Re: A Few Questions
Post by: ACagliano on September 02, 2010, 02:34:41 pm
So, can I just read from the appvar's pointer directly?
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 02:35:28 pm
Yeah, of course, if it's in RAM. If not, you have to change to the flash page, and I don't know how to do that in Axe.

EDIT: But most importantly, change that "0" to a [00].
Title: Re: A Few Questions
Post by: ACagliano on September 02, 2010, 02:36:54 pm
im not changing to flash anything with Axe. I'll work in RaM. Last time i inadvertently wrote to flash i almost f***ed over my certificate and actually did wipe an OS sector. Wasn't fun. lol. Thanks for the help.
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 02:39:56 pm
im not changing to flash anything with Axe. I'll work in RaM. Last time i inadvertently wrote to flash i almost f***ed over my certificate and actually did wipe an OS sector. Wasn't fun. lol. Thanks for the help.

Lol :D Nearly did the same with my first *useful* ASM program. Good thing it was on Wabbit :P

But what if the user archives the appvar (unless you're going to delete it when done)?
Title: Re: A Few Questions
Post by: ACagliano on September 02, 2010, 02:42:02 pm
Program will automatically unarchive it when it opens.
Title: Re: A Few Questions
Post by: Runer112 on September 02, 2010, 03:07:34 pm
For the storing code to work better, you should change the line that stores the length to:
Code: [Select]
length(Str9Z)+1->V
The length() command returns the number of characters in the string, not including the null byte that actually terminates the string. Without that last byte, it doesn't actually store the end of the string signifier to the appvar, so calling length() or trying to display the string would result in garbage being added to the end until a zero byte is reached in RAM.

For the reading code, the easiest thing to do would be to simply display the string from the appvar, without copying it out, like this:
Code: [Select]
Disp D
Title: Re: A Few Questions
Post by: Deep Toaster on September 02, 2010, 06:57:54 pm
For the storing code to work better, you should change the line that stores the length to:
Code: [Select]
length(Str9Z)+1->V
The length() command returns the number of characters in the string, not including the null byte that actually terminates the string. Without that last byte, it doesn't actually store the end of the string signifier to the appvar, so calling length() or trying to display the string would result in garbage being added to the end until a zero byte is reached in RAM.

I think he's adding a zero at the end, separately.

For the reading code, the easiest thing to do would be to simply display the string from the appvar, without copying it out, like this:
Code: [Select]
Disp D

That.

EDIT: 42nd post today!

And I finally reach an average of one post per day, after a year of not posting at all and exactly 100 days of posts! :D
Title: Re: A Few Questions
Post by: Runer112 on September 02, 2010, 11:26:05 pm
If he wants to be able to just do Disp D, the zero ending byte needs to be in the appvar. That's why I suggested the modification to the storing method.
Title: Re: A Few Questions
Post by: Deep Toaster on September 03, 2010, 05:35:14 pm
If he wants to be able to just do Disp D, the zero ending byte needs to be in the appvar. That's why I suggested the modification to the storing method.

Oh, got it.