Partial answer, but maybe this will help you track down the problem:
subl $0, %esp
would grow the stack if the constant wasn't zero. The top of the stack is usually at the lowest memory address in x86, that is, stacks grow downwards.
leal -4(%ebp), %eax
loads the absolute address %ebp - 4
into %eax
. This is the pointer to the memory location where the scanf
d integer should be stored.
Why you're push
ing the base pointer is indeed a relevant question. You usually do that because you modify it afterwards, do stuff, and then pop
it when you're done - which it seems you don't. It is usually used with functions that you call
though. This might well be the problem here, you call inout
a method, but you're using it as a label for jmp
only. The code as you have posted it now has no chance of returning to where it was jmp
ed to from.
Wikibooks has a fairly concise introduction to x86 stack frames.