What is argument push order

后端 未结 2 1341
别跟我提以往
别跟我提以往 2021-02-07 21:15

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

2条回答
  •  长情又很酷
    2021-02-07 21:55

    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.

提交回复
热议问题