Author Topic: Axe Q&A  (Read 591176 times)

0 Members and 3 Guests are viewing this topic.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #195 on: March 20, 2011, 07:54:31 pm »
EDIT:

Code: [Select]


When do you use that? ???

Pretty much never. But it's a valid character/token. ASCII CFh, token BBEDh.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Q&A
« Reply #196 on: March 20, 2011, 08:38:01 pm »
Not to shove my routine down anyone's throat, but I believe it's still a very good option:
Spoiler For Quote:
Darl, you could try something like this:

:"Test"->Str1
:"Try"
:[00]
:"Moar"
:[00]
:"Text"
:[00]
:"Trial"
:[00]
:
:3->A  // Spot in Data, so it would be "Text" if A=3
:
:Str1->C
:For(B,1,A)
:length(C)+C+1->C
:End
Now C should point to your string. ;D

Good luck! :)
The way I suggested would just take a little bit more time on fetching the string (but not much, since Axe is so fast), plus it's easier to code and smaller than the massive Data() structure if you are using many strings.  My routine works by looping through the array and jumping from null-byte to null-byte with the length command and returning with a pointer to the string.

Please note: I think Runer and Deep's routines are great, it just seems like mine was just disregarded for easier to understand routines, so I figured I'd bring it to the limelight again. ;)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #197 on: March 20, 2011, 09:52:22 pm »
Yeah, that method would work. Let me compare and contrast the available methods so we can find which one would be best in which scenarios. I'll also optimize your routine while I'm at it. :P


LUT Method

Code: (Example) [Select]
.Data
"This"→Str000
"is"→Str001
"a"→Str002
"test."→Str003
Data(Str000ʳ,Str001ʳ,Str002ʳ,Str003ʳ)→GDB0

.Example call
5sub(SF)

.String fetching routine
Lbl SF
  {*2+GDB0}ʳ
Return







  • Size: 2n+10 bytes, n=number of strings; smaller for n≤18
  • Speed: 83 cycles; always faster
  • Symbols used: n+2 for easy method, 3 for manual string length counting method

Final verdict: The fastest solution, and the smallest for a low number of strings. As the number of strings goes up, it will become larger than the search method and will consume many symbols, requiring you to start manually calculating the length of strings to put in the LUT. Suggested if speed is important or if using a low number of strings (≤18).
       
Search Method

Code: (Example) [Select]
.Data
"This"→Str0
"is"[00]
"a"[00]
"test."[00]


.Example call
5sub(SF)

.String fetching routine
Lbl SF
  →r₁
  Str0
  Goto SF0
  While 1
    -1→r₁
    length(r₂)+r₂+1
    Lbl SF0
    →r₂
  End!If r₁
  r₂
Return

  • Size: 47 bytes; smaller for n>18
  • Speed: 21m+157n+129, m=number of bytes searched, n=string index; always slower
  • Symbols used: 3

Final verdict: Uses only 3 symbols without requiring the programmer to manually enter the length of the strings in a table. A smaller solution for a larger number of strings, but will quickly become many times slower than the LUT method with more and longer strings (e.g. getting the pointer to the name of a first generation Pokemon might take on average 20,000 cycles). Suggested if speed is not important for a larger number of strings (>18) or if you are tight on symbols and do not want to tally up the string lengths to put in a LUT.
« Last Edit: March 20, 2011, 09:54:40 pm by Runer112 »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #198 on: March 20, 2011, 10:05:03 pm »
There is another advantage to the LUT method, you can have data that contains zeros :) Also, if you do the manual tally method, you can leave off the terminating zero's that Axe automatically adds when you do ->Symbol, saving a byte for every entry.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #199 on: March 20, 2011, 10:27:27 pm »
Well they might want all the terminating zeros on the strings. But if not, you can always avoid that by doing something like the following:

Code: [Select]
.Will have a terminating zero
"Test"→Str0
.Will not have a terminating zero
"Test"[]→Str0

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axe Q&A
« Reply #200 on: March 20, 2011, 10:45:50 pm »
You can also use length-prefixed data, for a more optimized search loop. Removes a lot of unnecessary calls to length().
Code: [Select]
.Data
[]→Str0
[04]"This"
[02]"is"
[01]"a"
[05]"test."


.Example call
2sub(SF)

.String fetching routine
Lbl SF
  →r₁
  Str0
  Goto SF0
  While 1
    -1→r₁
    r₂+{}+1
    Lbl SF0
    →r₂
  End!If r₁
  r₂
Return
Of course, you can't display such strings with the built-in routines. It's fairly simple to display char-by-char in a loop though.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Camdenmil

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +4/-0
    • View Profile
Re: Axe Q&A
« Reply #201 on: March 27, 2011, 04:54:46 pm »
Does anyone have a small routine to convert a hex string to a number.
It is bad luck to be superstitious.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Q&A
« Reply #202 on: March 27, 2011, 06:32:55 pm »
Might this work for you?
http://ourl.ca/4129/124589
Good luck. :)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #203 on: March 27, 2011, 06:35:00 pm »
I think he wants conversion the other way around. :P
« Last Edit: March 27, 2011, 06:57:32 pm by Runer112 »

Offline Camdenmil

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +4/-0
    • View Profile
Re: Axe Q&A
« Reply #204 on: March 27, 2011, 11:25:21 pm »
Yeah, I'm getting user input as a hex string and I need to convert the string to a number I can use in the program.
It is bad luck to be superstitious.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Axe Q&A
« Reply #205 on: March 28, 2011, 02:46:57 am »
What about something that converts a sprite into a string?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Camdenmil

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +4/-0
    • View Profile
Re: Axe Q&A
« Reply #206 on: March 28, 2011, 11:54:13 pm »
I think the routines ztrumpet suggested could be used for sprite to hex. Just convert each byte to a hex character, there's probably a faster/smaller way floating around here somewhere.

http://ourl.ca/4129/124589
« Last Edit: March 28, 2011, 11:55:06 pm by Camdenmil »
It is bad luck to be superstitious.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Axe Q&A
« Reply #207 on: March 29, 2011, 09:54:12 pm »
Ho could I decompile a program into hex and run it in an axe program?
(prgmALCDFIX) :P
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #208 on: March 29, 2011, 11:25:21 pm »
Code: (Axe) [Select]
.UNSQUISH
5->{L1}^^r
"0123456789ABCDEF"->GDB0
ClrHome
Disp "To unsquish:    >prgm"
!If sub(INP)
Disp "Program not found!"
Return
End
->P
Disp "Save as:",[i],">prgm"
If sub(INP)
Disp "Program exists! Overwrite? (y/n)>"
Input ->R
!If {}-'Y'
Goto YES
End
!If -|E20
Goto YES
End
Return
End
Lbl YES
GetCalc(L1,{P-2}^^r->S*2)->Q
For(I,0,S-1)
{P+I}->J^16sub(GC)->{J/16sub(GC)->{I*2+Q}+1}
End
Disp "Program has beensuccessfully    unsquished."
Return
Lbl GC
{+GDB0}
Return
Lbl INP
Fill(0->{(L1+1)},7)
Copy(Input ->I,L1+1,{I-2}^^r)
GetCalc(L1)
Return

Remember to remove the BB6D in the beginning of the program.

Pointers may be thrown off, though, so make sure you deal with fixed addresses appropriately.
« Last Edit: March 29, 2011, 11:26:09 pm by Deep Thought »




Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Axe Q&A
« Reply #209 on: April 01, 2011, 12:27:26 am »
How do I use Indata?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!