What is argument push order

16,093

The processor knows no 'function arguments'. Therefore when you want to write f(a,b,c), you really need to push the arguments 'somewhere'.

This is convention. I know that on most x86 machines, function arguments are pushed on the stack from right to left, i.e. first c, then b, then a.

push c
push b
push a
call f

Now the called function can use ebx -1 for a, ebx - 2 for b and ebx - 3 for c.

You could as well establish a convention that says: first two arguments are in registers ebx and ecx, rest are on the stack. As long as the caller and callee agree, you're fine.

Share:
16,093
Axolotl
Author by

Axolotl

Updated on June 04, 2022

Comments

  • Axolotl
    Axolotl about 2 years

    I'm learning Assembly language. What exactly is argument push order? i understand its how arguments are pushed to the stack but what does the left and right part mean? left or right of what? Or is this merely to do with the way the command is semantically written, i.e.:

    mov ebp, esp ;esp is moved into ebp, right to left.

    Is this correct or could someone enlighten me?

    Many thanks!