On 12/01/2024 19:27, Philipp Klaus Krause wrote:
Currently, the calling convention does not pass arguments in
registers. They are either passed at those names you mentioned, or on
the stack. The latter is done for __reentrant functions and when
--stack-auto is used.
I am trying to understand the stack arguments scheme. I don't understand
what is going on with the assembly code SDCC generates when accessing a
single 8-bit argument on the stack:
mov.io a, sp
add a, #0xfc
mov p, a
idxm a, p
What is the addition operation for? It's subtracting 4? Why? But if idxm
instruction needs a word address, why not divide by two (with a shift
right)?
P is an 8-bit pseudoregister, and the byte following P is always 0x00.
Ah, I assumed P was 16-bits. Given that P is allocated two bytes
(presumably then only for reason of alignment of subsequent data), is it
okay to use the upper byte of P for arbitrary purposes, so long as that
byte is always reset back to zero afterwards?
Regards,
Basil Hussain
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user