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

Re: [MiNT] Scratch registers

Hi Vincent,

thanks for your reply.

i.e. TOS utilizes only d0/a0 as the scratch registers

When calling GEMDOS? Yes, it is often the case. But it does not mean that d1/d2/a1/a2 will always be preserved. They must be backuped before any trap #1, just in case.
Well, yes, this is what I meant. 

Do you mean "preserved" when you write your own trap #1 hook?

No, C functions compiled with GCC only trash d0/d1/a0/a1.
Ah, right.

If this is true, this should be documented.
But I believe that the rule varies across TOS versions *and* different function numbers.
ggn wrote me: My copy of ST Internals (circa 1988) states that for GEMDOS "In regard to all GEMDOS calls, it must be noted that registers D0 and A0 are changed in all cases. If a value is returned, it is returned in D0, or D0 may contain an error number, and after the call A0 (usually) points to the stack address of the function number. Any parameters required in D0 or A0 must be placed there before GEMDOS is called."

So it is documented. I guess the reason why it hasn't showed up before is that it's visible only when mixing C and asm code.

Now as I think of it, it's not about the way mintlib marks the scratch registers -- even if there's no single gemdos call in the C function called from my asm handler, gcc guaranties to preserve only registers a2/d2 and up. So I must fix it in my code anyway.

Thanks for pointing me to the right direction!

MiKRO / Mystic Bytes