Jump to content
IGNORED

Post processing assembly to optimize accumulator usage


Recommended Posts

http://calc6502.com/RobotGame/summary.html


Basically this guy wrote a python interpreter that finds locality use of the accumulator and can decide when to use page 0 instead for a "local variable" freeing up the accumulator.

 

His gains are 5-10% versus his raw assembly - also compares equivalent code generated from cc65 and forth (blast from the past!).

 

He spent a LOT of time on this. Original purpose is a game for a calculator on 65c02, so it's a little more efficient code wise due to the PHX etc instructions. But generally this should work for 6502 as well.

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Interesting... but sort of a pity he used a 65C02 given it's lack of representation in the real world.

 

I've just skimmed through but there could be other issues like the fact you can only devote so much z-page to such variables and it can impact on some absolute variables that could otherwise achieve savings by using z-page.

 

But a valid study... in the grand scheme of things games and programs probably underutilize zero page.  Partially by just not doing efficiency runs and partially by not knowing which OS locations you can borrow.

Link to comment
Share on other sites

12 hours ago, Rybags said:

Interesting... but sort of a pity he used a 65C02 given it's lack of representation in the real world.

 

I've just skimmed through but there could be other issues like the fact you can only devote so much z-page to such variables and it can impact on some absolute variables that could otherwise achieve savings by using z-page.

 

But a valid study... in the grand scheme of things games and programs probably underutilize zero page.  Partially by just not doing efficiency runs and partially by not knowing which OS locations you can borrow.

 

He's 65C02 because he the target is a hand held calculator, so he needs the power efficiency. But yeah, rare comparatively.

 

I've sometimes wondered if you couldn't build a 6502 evaluator engine into an emulator - a form of profile guided optimization. 6502 is usually written by hand with the human building data structures and reference models in their head; the actually running code will not necessarily follow the original vision. A long time ago I was helping a friend with a game on the 8-bit and pointed out to him that some of his setup code before gameplay could be copied into page 0 from a net perspective run faster, since it was short and only ran once (but looped repeatedly). That kind of pattern is something a profile optimizer could recognize pretty easily.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...