Hi all,
I was modifing a routine I found on the web to work with some programs I am doing. But my modifications needed more two 8 bit registers. So, to avoid a lot of pushs and pops, I was thinking about using IXl and IXh (specially because of their accumulator properties). But I was wondering if it would turn to be a big trouble, compatibility-wise.And there's always the option to use the alternative register set - 100% documented and safe
Yeah, I could use them, but this routine belongs to a lib I am doing while I work on the main program. And I don't think it is good for a "general" routine to use exx. If so, every "general" routine should use them and main programs should never.
Yeah, I could use them, but this routine belongs to a lib I am doing while I work on the main program. And I don't think it is good for a "general" routine to use exx. If so, every "general" routine should use them and main programs should never. Documentation is the key here. You're also using the normal registers - all of them, apparently. Does that imply that main programs should never do that? No, it means that if the main program uses the registers, it has the responsibility to save their values somewhere - e.g. on the stack - before calling your lib function, and restore them afterwards. The same holds for the alternative register set: if the main program uses it, it will have the responsibility to save the contents.
Your lib documentation will just note that this particular routine uses the alternative registers and you're done
But that's just my 2cts... (Plus: who else is going to use that lib and which other program than the one you're currently working on uses this lib? )
In my experience, exx is rarely a solution for the problem because you lose the current values of bc, de, hl as well. Which you don't really want because you were out of registers for a reason. In that case it's a very good solution to use ixl, ixh, iyl and iyh for storage of 8 bit values or counters. In many cases it's the faster solution. I use them quite a lot myself. Much more than exx. I haven't heard of any compatibility issue with any msx machine.
NYYRIKKI: do you obfuscate your tax forms as well, like that?
In my experience, exx is rarely a solution for the problem because you lose the current values of bc, de, hl as well. Which you don't really want because you were out of registers for a reason. In that case it's a very good solution to use ixl, ixh, iyl and iyh for storage of 8 bit values or counters. In many cases it's the faster solution. I use them quite a lot myself. Much more than exx. I haven't heard of any compatibility issue with any msx machine.
I agree: most people under-estimate the index registers claiming that they are slow, but exchanging register bank could be even slow or more slow, especially if you need to have on-line all the register values (normal+switched). this usually need a lot of EXX where storing values in ix (H/L) and iy (H/L) does not need anything.
the trick is to use ix/iy for rare-changing values...
Of course, always depends to the use you need to do.
Yeah, I could use them, but this routine belongs to a lib I am doing while I work on the main program. And I don't think it is good for a "general" routine to use exx. If so, every "general" routine should use them and main programs should never. Documentation is the key here. You're also using the normal registers - all of them, apparently. Does that imply that main programs should never do that? No, it means that if the main program uses the registers, it has the responsibility to save their values somewhere - e.g. on the stack - before calling your lib function, and restore them afterwards. The same holds for the alternative register set: if the main program uses it, it will have the responsibility to save the contents.
Your lib documentation will just note that this particular routine uses the alternative registers and you're done
But, IMHO, saving all registers and the alternate ones would need so many push'es and pop's that it is not worth it. I prefer to save exx registers to routines that have any sort of (semi-)parallel processing.
Also, I couldn't agree more with Edwin. This routine mine, I can't switch actual bc, de and hl values, because they all need to be used. It would be very tricky to use exx all the time and correctly.
But that's just my 2cts... (Plus: who else is going to use that lib and which other program than the one you're currently working on uses this lib? )
Probably, none after me is going to use it. But when it is done, I will share it on internet . And no other program uses it, but the intention is that my next projects will rely on them.
In my experience, exx is rarely a solution for the problem because you lose the current values of bc, de, hl as well. Which you don't really want because you were out of registers for a reason.Good point. On the other hand, if you just want some register space for an extra loop counter, exx may still be an option. It's probably just me, but using undocumented instructions grates my nerves a bit
short message of unimportance: Chardson's post was a quote-mess.. Plz do read what you post within the edit-time. Now and then some oddness flips through that wouldn't have been there if we all check what we post. Tnx!
short message of unimportance: Chardson's post is a quote-mess.. but now it's all correct-mess eh... correctness, thanx to wolfness