back

by josephcsible·6y ago·view on hn ↗
I agree that passing `ax` and `bx` as inputs is better than setting them in the inline asm, but I don't like the idea of setting registers that shouldn't get changed as outputs "just in case".
1 comments
It's not a theoretical consideration. It's quite common for BIOS and firmware code to clobber registers that it isn't supposed to; see the code I mentioned in the Linux kernel, which arose through real-world bugs that were incredibly hard to debug.
But where do you draw the line? What if it clobbers the stack pointer?
Then it won't be able to return at all, and people will notice more quickly.