Am 13.01.24 um 19:42 schrieb Basil Hussain:
By the way, one thing I have noticed about SDCC's PDK code generation is
that it seems to prefer "add"-ing a negative number rather than using
the "sub" instruction. Why is that? Do not all PDK instruction sets have
"sub"? I'm pretty certain they do.
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.
sp-3 point to the padding byte that we need to ensure that sp is
always even, sp-4 points to the data byte of the argument.
Are you sure? Won't SP-3 be a copy of the flag register, not padding?
The push af instruction pushes two bytes: the a register and the flag
register.
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.
You mean using that byte at adress 1 in some assembler code? That
could work, but you'd have to reset it back to zero before it is used
by any SDCC-generated code. So you'd have to disable interrupts before
using the byte (and then reeenable them again after zeroing the byte).
Yes, precisely. I hadn't thought about interrupts attempting to use P,
thanks for that tip. So other than that, it's all good?
Yes, should be.
Philipp
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user