Alternate register set usage

Other misc things
Post Reply
periata
New member
Posts: 6
Joined: Sat May 05, 2018 10:52 am

Alternate register set usage

Post by periata »

I understand from reading other forum posts that the alternate register set is used for certain operations including longs and some floating point ops. I'm currently building a firmware that would benefit from being able to reserve at least a couple of registers from the alternate set for its own usage, or at least detect if they've been overwritten ... are there any options to control what registers are used? Is there documentation of what's used in what circumstances (so I could potentially just avoid using the parts of the system that would overwrite certain registers)?
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

periata wrote:I understand from reading other forum posts that the alternate register set is used for certain operations including longs and some floating point ops. I'm currently building a firmware that would benefit from being able to reserve at least a couple of registers from the alternate set for its own usage, or at least detect if they've been overwritten ... are there any options to control what registers are used? Is there documentation of what's used in what circumstances (so I could potentially just avoid using the parts of the system that would overwrite certain registers)?
No.. the compilers are not using the exx set** however the library is. So the only way to avoid having the exx set altered is to avoid using library functions that alter the exx set or provide alternatives that don't use those registers.

You will have to drill into the library source code to ensure that functions you're using do not change the exx set but generally it will be functions to do with 32-bit integer math, 64-bit integer math, float and stdio. Using the exx set increases performance a great deal so it's probably a good compromise for the firmware not to reserve the exx set and simply have it pick up stored values from memory instead.

Classic library source code is rooted in z88dk/libsrc
Newlib library soure code is rooted in z88dk/libsrc/_DEVELOPMENT

**In rare circumstances sccz80 will use the exx set to fix the stack pointer after a function call but IIRC this is also connected to floats.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

It may be possible to use a disassembler on the code section generated by the compiler to perform a search for "exx" to verify that the exx set is used or not.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

af' is rarely used in graphics, but the intruction to look at is not exx, in that case. .
Post Reply