什么是参数推送顺序 [英] What is argument push order

查看:27
本文介绍了什么是参数推送顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习汇编语言.究竟什么是参数推送顺序?我理解它是如何将参数推入堆栈的,但左右部分是什么意思?左边还是右边什么?或者这仅仅是与命令的语义编写方式有关,即:

mov ebp, esp ;esp 移动到 ebp,从右到左.

这是正确的还是有人可以启发我?

非常感谢!

解决方案

处理器不知道函数参数".因此,当您想编写 f(a,b,c) 时,您确实需要将参数推送到某处".

这是惯例.我知道在大多数 x86 机器上,函数参数是从右到左压入堆栈的,即首先是 c,然后是 b,然后是 a.

push c推b推一个呼叫 f

现在被调用的函数可以对a使用ebx -1,对b使用ebx - 2,对c使用ebx - 3.>

你也可以建立一个约定:前两个参数在寄存器 ebxecx 中,其余在堆栈中.只要调用方和被调用方同意,你就没事.

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!

解决方案

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.

这篇关于什么是参数推送顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆