[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Scratch registers



Hi,

I've bumped into an interesting issue (thanks ggn!) -- it's not a secret that TOS uses a0-a2/d0-a2 as so called scratch registers. Meaning that you don't have to back them up when calling a GEMDOS call, for example.

However, this seems to be not true for TOS earlier than 2.x, i.e. TOS utilizes only d0/a0 as the scratch registers and the other registers must be preserved.

In practice, it doesn't pose much problems as there are very few people running gcc+mintlib apps on TOS 1.x machines but it is a problem in general.

For me the use case is a GEMDOS driver/handler -- I call a C function from my asm code, d1/d2/a1/a2 get trashed, I pass execution back to TOS and bam, crash because the original TOS handler expected the regs wouldn't change.

Of course, I could (and will) store the regs before calling the C function but in general, it's a bug, not so well known, as the rule for scratch registers had changed after TOS 2.x release.

--
MiKRO / Mystic Bytes
http://mikro.atari.org