Author Topic: Assembly Programmers - Help Axe Optimize!  (Read 82985 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55881
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Assembly Programmers - Help Axe Optimize!
« Reply #60 on: June 09, 2010, 11:41:29 pm »
I've further optimized that grayscale command and its basically the same size as my original now except way faster which is excellent.
Cool to hear :D I can't wait to see the difference :)

Now I wonder how easy it would be to make a grayscale version of the 3D racing game that comes with Axe

calc83manic
You downgraded calc84maniac to 6 MHz hardware :(

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Assembly Programmers - Help Axe Optimize!
« Reply #61 on: June 09, 2010, 11:53:09 pm »
calc83manic
You downgraded calc84maniac to 6 MHz hardware :(

He also downgraded him to having a mood disorder.

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55881
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Assembly Programmers - Help Axe Optimize!
« Reply #62 on: June 09, 2010, 11:55:49 pm »
calc83manic
You downgraded calc84maniac to 6 MHz hardware :(

He also downgraded him to having a mood disorder.
oh crap I didn't notice x.x. I hope he still finishes all his projects including the 8 level grayscale raycaster D: *runs*

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Assembly Programmers - Help Axe Optimize!
« Reply #63 on: June 10, 2010, 07:44:46 am »
It's awesome that you were able to further optimize the grayscale, this makes me very happy! :D
calc83manic
You downgraded calc84maniac to 6 MHz hardware :(

He also downgraded him to having a mood disorder.
oh crap I didn't notice x.x. I hope he still finishes all his projects including the 8 level grayscale raycaster D: *runs*
LOL, you guys... :P

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: Assembly Programmers - Help Axe Optimize!
« Reply #64 on: June 10, 2010, 08:41:26 am »
Maybe you could use ixl/ixh to avoid the shadow reg? It is 9 clocks for ld iirc tho :S.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55881
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Assembly Programmers - Help Axe Optimize!
« Reply #65 on: June 10, 2010, 09:31:50 am »
It's awesome that you were able to further optimize the grayscale, this makes me very happy! :D
calc83manic
You downgraded calc84maniac to 6 MHz hardware :(

He also downgraded him to having a mood disorder.
oh crap I didn't notice x.x. I hope he still finishes all his projects including the 8 level grayscale raycaster D: *runs*
LOL, you guys... :P
lol :P

Maybe you could use ixl/ixh to avoid the shadow reg? It is 9 clocks for ld iirc tho :S.
Aren't those incompatible with the Nspire, though? Or am I confusing them?

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: Assembly Programmers - Help Axe Optimize!
« Reply #66 on: June 10, 2010, 10:07:44 am »
LOL you guys. :P

Maybe you could use ixl/ixh to avoid the shadow reg? It is 9 clocks for ld iirc tho :S.
Aren't those incompatible with the Nspire, though? Or am I confusing them?
I'm pretty sure they're not compatible, since they are undocumented. :(

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2898
  • Rating: +467/-17
    • View Profile
    • TI-Boy CE
Re: Assembly Programmers - Help Axe Optimize!
« Reply #67 on: June 10, 2010, 10:54:43 am »
Also, you can't use bit-shift instructions on ixh/ixl.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2898
  • Rating: +467/-17
    • View Profile
    • TI-Boy CE
Re: Assembly Programmers - Help Axe Optimize!
« Reply #68 on: June 10, 2010, 04:38:40 pm »
*bump* (excuse the double post, I didn't really read this before)

Hmm, remember when I suggested you could use IX as a pointer to the variables for easier access when doing 8-bit operations? That would be too much of a hassle, we agreed. But what if you moved the variables to the END of savesscreen? Then they would be within the range of the IY register (which points 4 bytes after the end of savesscreen). Just something to consider :)
Hmm... interesting proposition.  Although it would optimize some operations like addition and subtraction, there is still one key advantage to using the existing variable slots.  By using only the least significant bytes of those variables, you never need to do "conversions" when you switch from word to byte mode.  You have to get input and output somehow otherwise there's not much advantage to the new mode.  By being able to skip the conversions, I think that will save more memory in the long run than by using the iy or ix registers.
What are these "conversions" you are talking about, and why are they affected by using the IY register? You can keep using normal memory loads/stores as much as you want, IY is just a bonus optimization (especially once you add 8-bit math mode). I'd imagine being able to directly add, subtract, and, or, xor variables in only 3 bytes is worth moving the variables to the end of the buffer.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Assembly Programmers - Help Axe Optimize!
« Reply #69 on: June 11, 2010, 04:22:57 pm »
Oh, I see!  So you mean move all the variables to the end, not separate 8-bit variables.  That's actually a really good idea then.  And I don't think this would cause any compatibility issues assuming no one is abusing the Asm() feature.  The only drawback is that buffer overflows will flow into the A-Z variables making debugging that difficult, but that's really a non-issue.  In fact, its probably far safer than overflowing into some random ram values as far as stability.

I'll wait until I add the feature before moving the variables though.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2898
  • Rating: +467/-17
    • View Profile
    • TI-Boy CE
Re: Assembly Programmers - Help Axe Optimize!
« Reply #70 on: July 09, 2010, 04:21:39 pm »
Here is a speed optimization for the length() command (the size turned out to be the same):
Code: [Select]
xor a
ld b,a
ld c,a
cpir
ld hl,-1
sbc hl,bc
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Assembly Programmers - Help Axe Optimize!
« Reply #71 on: July 09, 2010, 04:35:59 pm »
Thanks! I thought about doing it that way, but I couldn't figure it out, its smart to use the negative. ;D
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2898
  • Rating: +467/-17
    • View Profile
    • TI-Boy CE
Re: Assembly Programmers - Help Axe Optimize!
« Reply #72 on: September 22, 2010, 01:21:17 pm »
Oh, how I love to bump this thread! :D

I'm thinking it would be neat for the commands that return booleans to not always have to calculate the 0 or 1 value directly. I was thinking instead that the command will set an internal compiler variable that tells which condition code to use. Then, the following command can either optimize according to the condition or otherwise generate a 0 or 1 as usual.

The most common application for this is the If statement. Take, for example, If A=5:
Code: [Select]
  ld hl,(var_a)
  ld de,5
  or a
  sbc hl,de
  ;The Z condition code is set to correspond to 1
  jp nz,end

Or how about B<10+A->A:
Code: [Select]
  ld hl,(var_b)
  ld de,-10
  add hl,de
  ;The NC condition code is set to correspond to 1
  ld hl,(var_a)
  jp c,no_inc
  inc hl
no_inc:

I imagine the "=0" command, when applied while condition code is active, will invert the condition variable and generate no code.

And... I guess that is all for now. Good day!
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Assembly Programmers - Help Axe Optimize!
« Reply #73 on: September 22, 2010, 04:24:15 pm »
I'm thinking it would be neat for the commands that return booleans to not always have to calculate the 0 or 1 value directly. I was thinking instead that the command will set an internal compiler variable that tells which condition code to use. Then, the following command can either optimize according to the condition or otherwise generate a 0 or 1 as usual.

How do you surmise that the compiler would know when to use which? For instance, A≠5 or (B≠6) could be optimized to A-5 or (B-6), but A≠5 and (B≠6) could not be similarly optimized.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2898
  • Rating: +467/-17
    • View Profile
    • TI-Boy CE
Re: Assembly Programmers - Help Axe Optimize!
« Reply #74 on: September 22, 2010, 04:32:51 pm »
A≠5 and (B≠6) would be something like:
Code: [Select]
  ld hl,(var_a)
  ld de,5
  or a
  sbc hl,de
  ;The NZ condition code is set to correspond to 1
  ld hl,1
  jp nz,_
  ld hl,(var_b)
  ld de,6
  or a
  sbc hl,de
  ;The NZ condition code is set to correspond to 1
  ld hl,1
  jr nz,_
  dec hl
_
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman