Re: Question about AMD64 ABI

From: Daniel Cervus <DanieltheDeer_at_outlook.com>
Date: Tue, 15 Nov 2022 02:11:13 UTC
If there's even the slightest chance that the function body acts upon the entirety of the register, then you _should_ ensure it's zero padded appropriately.

How much is this chance for C libraries that come with the FreeBSD? So it is not mandatory that the function body should only acts upon the bits that it should consider in comply of ABI?

Again, most compilers are smart enough to perhaps `and reg, 0x0FFFF` or simply ignore the high bits on its own, but ultimately you do feed it the entire register in which if the callee expects to operate on 16-bits or smaller it better do so.

So I had better zero-extend it to 32 bit, right? Why not 64, because it’s already safe enough?

As an aside to the above, feel free to start writing something, and send me some personal emails with snippets and examples of what you might have in mind.
I'm happy to critique and provide comments as necessary.  I also have a treasure trove of asm related things that I wrote that could potentially help with your asm endeavors.
Fair warning though, this isn't for the faint of heart.  There's seldom a case where I've been able to out-wit a compiler.  They are THAT good nowadays.

Yeah, I do have the ambition of programming in assembly,  because it gives me a sense of ultimate control. And, yes, even though I know we can’t outrival the compiler, we are still the masters of the computer.

Regards,
Daniel