On 14/01/2024 14:40, Philipp Klaus Krause wrote:
The adjustStack helper function in code generation uses add. It works for both negative and nonnegative stack pointer adjutsments, no point writing a version that uses sub.

Fair enough. Was just curious. :)

Well, padding of unspecified value. Practially, it will often flag bits, since push af tends an efficient efficient way to push a byte as 16-bit value with unspecified upper byte. But this is not guaranteed, and the callee shouldn't rely on it.

Oh, of course. I can't even imagine why anyone would want to look at flags previously saved on the stack. So yes, effectively padding, albeit of typically non-arbitrary value.

Hmm... what you said made me wonder if, given the flag register is writeable, whether you could actually use "push af" to store an arbitrary 16-bit value on the stack. But no, the top 4 bits of flag aren't writeable, and the docs say they always read as '1', so I presume any value in that register will be 0b1111xxxx when saved to the stack. An interesting thought experiment nonetheless.

Regards,
Basil Hussain


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to