This particular function:
Code: Select all
void key_press(registers_t regs)
{
terminal_writestring("\nKey Code: ");
terminal_writeNumber(inb(0x60));
}
For the moment, I've solved the problem with a few attribute flags:
Code: Select all
__attribute((optimize(0)))
void key_press(__attribute((unused)) registers_t regs)
{
terminal_writestring("\nKey Code: ");
terminal_writeNumber(inb(0x60));
}
My question to you lovely folks is: Is this the correct way to solve this problem?
I can't help but feel that this shouldn't be happening. It seems like the compiler should know better than to underflow the stack. Of course, there are a couple factors I see that make this a more interesting case:
- The uber-stack structure is being passed as a copy rather than a pointer. I can't help but think a pointer would fair better.
- The C compiler isn't aware of the assembly messing with the stack just below it. It may think it's cleaning house correctly.