Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Runer112 on January 10, 2011, 01:09:23 pm

Title: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on January 10, 2011, 01:09:23 pm
TL;DR : An Axe command list with size, speed, and notes for Axe commands. Good for optimizing.



I'd say I'm fairly decent at optimizing Axe programs. This stems partially from my good amount of experience with Axe. After having used Axe for a long time, I know all of the commands and options available, so when trying to make code to do something, I can usually think of many different ways to do it. Knowing offhand the sizes of a decent number of commands helps me eliminate a large number of these options, and between what's left, I often just try each option one by one, compiling the program with each option and seeing which is the smallest.

What helps even more to optimize my code is my experience with z80 assembly. When thinking about the smallest or fastest way to do something, I could think of the assembly code that Axe commands break down into and actually count bytes and cycles for a very exact comparison.

The Auto Opts.txt file included in Axe releases helped me learn a lot, but it only lists the sizes of what its name would suggest, the automatic optimizations. And although those often help to produce the smallest sizes, what about speed? And what about commands that aren't listed there? I often had to resort to methods like I talked about above, such as brute force testing all the options or trying to step through the assembly in my head. But those can be difficult and time consuming, even for someone with a lot of experience.

So I decided to make a list, detailing some specifications about every Axe command. This means basic loading and saving, auto optimizations, math routines, graphic routines, everything. For every command, I listed the command's size and equivalent Axe code. With this file, you could determine the exact size of anything you can do in Axe. It also lists the exact or approximate time that most commands take, so you can optimize for speed as well, something which is much harder to determine than size without examining the underlying machine code for every command. But I did just this, so others who are able to don't have to spend the lengthy amount of time doing so, and so others who aren't able to don't have to be able to.

I am missing the speed of some commands, as the remaining ones are some of the more challenging ones to test. I hope to test all of these eventually, but for now I'll release what I have. But for the commands that do have speed documented, you can learn some interesting things. Like how Pt-Off() is faster than Pt-On() and Pt-Change() for drawing aligned sprites (x and y are multiples of 8), but slower for unaligned sprites. Or how, on my calculator's hardware at least, DispGraphr is actually faster than DispGraph.


Anyways, without further ado, I'll attach the file. I highly suggest viewing it in a text editor like Notepad. Without a monospaced font and an 8-character tab width, it won't look pretty. I'll try to keep it up to date and modify it as new versions of Axe come out so you can always have a copy you can know is accurate for the current version.


Tip: To search for a specific command, try using your text file viewer's find feature to search for the Axe source code equivalent.





If you see any errors or have any questions or suggestions, just post them here.

Current version: 0.5.3b

Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Hot_Dog on January 10, 2011, 01:37:15 pm
Wow, I never fully realized how close in speed Axe is to ASM.  Still not as fast, but in most respects it's pretty dang close
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Michael_Lee on January 10, 2011, 01:53:06 pm
Erm, I tried opening it in notepad, and I got normal text interspaced with a bunch of garbage/chinese characters.
Is there a particular encoding I should use?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on January 10, 2011, 03:05:02 pm
Oh yeah, it's a Unicode text file because it uses some special characters like → and ►. I thought stuff like that was saved in a file header or something, but I guess not. Is there a certain way to open a text file in Unicode format that I should tell people about?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Munchor on January 10, 2011, 03:15:42 pm
How to open this? xD Nice job Runer.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: thepenguin77 on January 10, 2011, 03:17:09 pm
Oh yeah, it's a Unicode text file because it uses some special characters like → and ►. I thought stuff like that was saved in a file header or something, but I guess not. Is there a certain way to open a text file in Unicode format that I should tell people about?

Try making the first few characters things that only exist in Unicode. I remember something like this with typing in "bush hid the facts"
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Quigibo on January 10, 2011, 04:54:52 pm
Very nice!  None of my text editors can read the file properly but I can still kind of see some of it.  This would definitely be better in the documentation than the AutoOps file.  It seems difficult to maintain and keep updated though since the commands change so often.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on January 10, 2011, 04:57:09 pm
Hmm it seems that lots of people are having trouble with this file... Let me try thepenguin77's suggestion. The first few characters in the file are now Unicode characters. Does this file render correctly?

EDIT: Nope, definitely doesn't, I just tried it myself. I'll keep looking into this.

EDIT 2: Yay, looks like I got UTF-8 to work! I'll reattach the file to the first post immediately.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: DJ Omnimaga on January 10, 2011, 05:18:41 pm
The new version works fine in Notepad and Opera. I haven't tried in other softwares, though. Very nice Runer112, it should be useful for in-depth optimizations :D

I think it should be included with Axe.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: squidgetx on January 10, 2011, 05:50:46 pm
oh shi-

very nice, will def. be taking a look at this later :D
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on February 02, 2011, 01:41:14 pm
why isn't this stickied?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Eeems on February 02, 2011, 02:32:01 pm
Good question, why isn't it?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Munchor on February 02, 2011, 02:34:42 pm
Good question, why isn't it?

why isn't this stickied?

I totally agree.

Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: DJ Omnimaga on February 12, 2011, 07:38:46 pm
It wasn't because Quigibo hated having too many stickied threads. The last time I stickied many he sent me an e-mail so I unsticky them. However with the new sub-forum I guess it isn't a huge issue anymore.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Munchor on February 13, 2011, 01:03:20 pm
Also Runer, I was wondering, can I make a html version of it?

Since I have quite a few calculator programming databases in my website (Bcalls, hex instructions and prizm equates), could I host it at my website?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Deep Toaster on February 13, 2011, 01:04:09 pm
Also Runer, I was wondering, can I make a html version of it?

I've already started (Runer gave me permission on IRC a few weeks ago). You can help with that if you want.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Munchor on February 13, 2011, 02:57:10 pm
How you mean started? I'd do it in a hour maximum :S

Eitherway, yeah I can help.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: squidgetx on February 13, 2011, 03:40:21 pm
Printer friendly version
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on February 13, 2011, 05:33:38 pm
Attached an updated file for version 0.5.0 to the original post.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: squidgetx on February 13, 2011, 08:21:21 pm
Printer friendly version
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Builderboy on February 17, 2011, 04:03:40 pm
p_SubConst:         4 bytes      21 cycles      -1337
p_SubConst:         7 bytes      39 cycles      -A            Larger and slower than addition
p_SubExpr:         6 bytes      54 cycles      -()            Larger and slower than addition

5.0.0 has this small error, the second SubConst should read SUbVar if I am not mistaken
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on February 17, 2011, 04:23:16 pm
You are correct. I have fixed that now, but I probably won't bother to make a new release just for a silly text mistake. I will probably upload a new version/revision if I change any of the speed/size data, in which case this fix will be included.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on March 27, 2011, 05:18:37 pm
Updated for Axe 0.5.1. The file is attached to the first post. A very notable change is that, due to much pestering of Quigibo on my part, the DispGraph routine has been majorly changed. This means 2 things:


If your project is designed to run in 15MHz mode, I suggest replacing any instances of DispGraph with sub(DG). You would then want to insert this subroutine into your code:
Code: [Select]
Lbl DG
Normal
DispGraph
Full
Return
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on March 27, 2011, 05:20:54 pm
It works in full speed mode for me.  I find that strange because I tend to have many problems with my screen :/

Opps, I screwed up.  I didn't have a successful transfer :P
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: DJ Omnimaga on March 27, 2011, 05:23:57 pm
Could it depend of the LCD? Some 84+ calcs got different LCDs
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on March 27, 2011, 05:34:02 pm
So why does DispgraphClrdraw work in full speed mode?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on March 27, 2011, 05:43:00 pm
The DispGraphClrDraw routine was unchanged. Although it probably should have been changed, so I'm going to bug Quigibo about that and a few other things. :P

Anyway, here's why you need to make sure you're not running at full speed. These are the results of a simple program that fills L6 to be entirely black and then calls DispGraph. These images aren't actually from wabbitemu because it doesn't account for LCD delay and so this problem isn't present.

6MHz
   
15MHz
Before
(http://img.removedfromgame.com/imgs/DispGraph_Problem_Before.png)
   
Before
(http://img.removedfromgame.com/imgs/DispGraph_Problem_Before.png)
After
(http://img.removedfromgame.com/imgs/DispGraph_Problem_After_6MHz.png)
   
After
(http://img.removedfromgame.com/imgs/DispGraph_Problem_After_15MHz.png)
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: ZippyDee on March 30, 2011, 02:22:39 am
What causes this, if I may ask?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: leafy on March 30, 2011, 02:35:27 am
Is DispGraph in 6mHz still the same speed as DispGraph in 15mHz?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on March 30, 2011, 12:56:56 pm
The new DispGraph routine no longer works properly at 15MHz, so you can't really compare the speed of it running at 6MHz or 15MHz. However, you can compare the speed of the new DispGraph routine at 6MHz against the speed of the old routine at 15MHz. Depending upon the LCD's delay, it it will either be a bit slower or a bit faster than the old routine at 15MHz was. My calculator has a relatively small LCD delay, so the new routine at 6MHz is just a few percents slower than the old routine at 15MHz. On calculators with a larger LCD delay, the new routine at 6MHz should run just as fast or faster than the old routine at 15MHz.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: ZippyDee on March 30, 2011, 04:52:10 pm
But what causes it to not be usable at 15MHz?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Munchor on March 30, 2011, 04:53:08 pm
But what causes it to not be usable at 15MHz?

Its assembly code, somehow. Runer must have tried to optimize the code in a way that makes it impossible to 15MHz I guess.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: ZippyDee on March 30, 2011, 05:01:20 pm
I know it's assembly. I understand that some optimization makes it impossible with 15MHz. But what's different at 15MHz than 6MHz?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Freyaday on March 30, 2011, 05:06:11 pm
The screen needs a delay of about 10microseconds between inputs, otherwise it shows garbage (not the band, sadly). @6MHz the processor is slow enough that this isn't a problem, but @ the higher speed it's faster than that.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Deep Toaster on March 30, 2011, 11:16:32 pm
The screen needs a delay of about 10microseconds between inputs, otherwise it shows garbage (not the band, sadly). @6MHz the processor is slow enough that this isn't a problem, but @ the higher speed it's faster than that.

Yeah. Basically there is a delay included in the routine, and it's long enough in 6 MHz mode, but the 15 MHz processor goes through the delay too quickly.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: ZippyDee on March 31, 2011, 12:17:33 am
Is there no way to tell which mode it's in and only have it delay if it's at 16MHz?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on March 31, 2011, 12:18:44 am
In the next version of Axe, Quigibo will releasing a fix that puts the calculator in 6MHz mode before running the DispGraph routine and then returns it to the CPU speed it was previously running at when it finishes.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: ZippyDee on March 31, 2011, 01:05:14 am
Awesome :D That sounds like it'll make it much easier.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on May 16, 2011, 08:43:25 pm
Updated for Axe 0.5.2. As usual, the updated file is attached to the first post. I'm also going to start a more detailed changelog, in case people are interested in knowing what exactly changed between versions of Axe. [NEW] denotes new Axe commands, [CHG] denotes changed Axe commands, and [FIX] denotes commands that haven't changed but have corrected information.

Changes:
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: DJ Omnimaga on May 16, 2011, 08:46:48 pm
Nice, thanks for this :D
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Quigibo on May 17, 2011, 05:43:40 pm
Just wanted to mention one other thing to add to the list; I turned the DispStrApp and TextStrApp inline routines into subroutines.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on May 17, 2011, 06:01:29 pm
Ah, so you have. I checked for that because I know I had suggested that change, but after a quick glance and not seeing any returns on the end I figured they hadn't changed. I didn't think to look for the conditional returns in the middle of the routines.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on May 28, 2011, 01:06:16 pm
Updated for Axe 0.5.3. As usual, the updated command information document is attached to the first post.


Changelog:
[NEW] denotes new Axe commands, [CHG] denotes changed Axe commands, and [FIX] denotes Axe commands that haven't changed but have corrected information. Red denotes a bug. Green denotes a change that I deem to be awesome.

Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Munchor on May 28, 2011, 03:18:22 pm
Nice Runer112, cool you keep us updated :D

Also, is there a chance this can be released with Axe?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on May 28, 2011, 03:36:27 pm
If Quigibo wanted to release this with Axe, he'd either have to keep it up to date himself or give me new versions of Axe about a day in advance so I can update the file and give it back to him. Supposedly we're very close to Axe 1.0.0 though, for which he may or may not want a file like this being packaged into the sort of "final" version.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on May 28, 2011, 08:22:09 pm
Updated for Axe 0.5.3b. As usual, the updated command information document is attached to the first post.


Changelog:
[NEW] denotes new Axe commands, [CHG] denotes changed Axe commands, and [FIX] denotes Axe commands that haven't changed but have changed/corrected information. Red denotes a bug. Green denotes a change that I deem to be awesome.

Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on September 28, 2011, 08:28:07 pm
bump
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on September 28, 2011, 08:39:33 pm
Whoops, I guess I've sort of let my documentation fall behind since Axe left 0.X.X versions. A good deal of the information is still accurate, but I guess it's missing some changes and some additions.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on September 28, 2011, 09:32:29 pm
helped me save about 2000 cycles per frame.  thanks much
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Quigibo on October 03, 2011, 02:46:17 am
Keep in mind that the new peephole optimizations make most of the speed/size data for individual atoms of the language inaccurate without context.  But this is still a good guide for general optimization.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Freyaday on October 03, 2011, 10:33:46 am
How about the ? operators?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: epic7 on October 25, 2011, 08:31:30 pm
Is there one up to date with 1.0.5?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on December 11, 2011, 10:14:33 pm
Bump?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: epic7 on December 11, 2011, 10:16:01 pm
Will there be a new one for 1.1 ever?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on December 11, 2011, 10:23:21 pm
So many commands have changed since my last update of this, and now there are peephole optimizations to account for too. Although it would be a lot of work, I really should get this back up to date...
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: epic7 on December 11, 2011, 10:26:35 pm
Are cycles the unit used to measure speed?
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Happybobjr on December 11, 2011, 10:27:34 pm
yes.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: calc84maniac on December 11, 2011, 11:47:38 pm
To be more precise, it is a small length of time, around either 1/6000000 seconds for 6MHz mode or 1/15000000 seconds for 15MHz mode (and of course, these lengths vary between different calculators and operating conditions)
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: kindermoumoute on January 04, 2012, 08:01:44 am
Good job.
I hope it will be update soon ! :)
(at least can you indicate which part are available currently ?)
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: kindermoumoute on March 08, 2012, 04:41:42 pm
up ? ::)
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Xeda112358 on March 09, 2012, 07:14:48 pm
Hmm, I will have to take a look at this, finally... It seems very useful! I am very much not up to date with Axe .__.
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: kindermoumoute on March 10, 2012, 04:14:20 am
I am very much not up to date with Axe .__.
This list isn't too. :/
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: kindermoumoute on March 12, 2012, 05:10:45 pm
UP ? ???
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: Runer112 on March 12, 2012, 05:23:21 pm
I'm not sure if this ever going to get updated. :-\ Now that Axe has peephole optimizations, counting the speed and size of code is more complex and requires knowledge of assembly to take advantage of the peephole optimizations. But a big reason for creating this guide was so you didn't need knowledge of assembly to know how fast/large code will be.

Not counting peephole optimizations, most figures in the latest version of this guide (0.5.3) are still pretty accurate. If you have any questions about the speed/size of specific routines or blocks of code, feel free to ask.


EDIT: Maybe I should make a general Axe optimization help thread...
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: leafy on March 12, 2012, 07:27:45 pm
EDIT: Maybe I should make a general Axe optimization help thread...

DO IT :3
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: parserp on March 12, 2012, 08:55:05 pm
And then make a Runer Axe OptimizationTM thread. :P
Title: Re: Documentation of the Speed and Size of (Almost) Every Axe Command
Post by: kindermoumoute on March 13, 2012, 02:05:25 pm
If you have any questions about the speed/size of specific routines or blocks of code, feel free to ask.
I note that. :devil:
Spoiler For Spoiler:
Can you show me mains optimisations that show difference between size and speed optimisation. eg. i know A/2/2/2 is faster than A/8, but this last it smaller. Have you more exemples ?
EDIT: Maybe I should make a general Axe optimization help thread...
Yes, that's could be usefull ! :o
Together, can you make a list of all RAM area usable in Axe, no matter how small ?