0

I was learning ASM basics on Assembly "hello, world" for OS X when I saw that:

    sub esp, 4                ; OS X (and BSD) system calls needs "extra space" on stack

I'm wondering if the space is dedicated to local variables or somehow related to the syscall.

Thanks to you.

Post-Scriptum: if you'll have any docs or books recommended, please tell me

eldten
  • 3
  • 1
  • 2
    IIRC that extra space comes from the fact that the syscall is intended to be placed in its own function, and that space is the return address in that case. In your code you probably have it inlined, thus need to make that space manually. I might be completely wrong though :) – Jester Mar 30 '16 at 22:35
  • 2
    Yep @Jester. I recently wrote as part of this [answer](http://stackoverflow.com/a/36106091/3857942) this passage _After pushing arguments on the stack in reverse order for int 0x80 you must allocate an additional 4 bytes (a DWORD) on the stack. The value in that memory location on the stack doesn't matter. This requirement is an artifact from an [old UNIX convention](https://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/x86-system-calls.html)_ – Michael Petch Mar 30 '16 at 22:49

0 Answers0