调用传递32位系统的约定和参数 [英] Calling convention and argument passing on 32 bits systems

查看:414
本文介绍了调用传递32位系统的约定和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello

我正在研究一个VC ++程序,它需要包含一些程序集并传递一些参数。浏览网页我找到了x64调用约定的文档,但是找不到32位的内容。

I am working on a VC++ program that requires to include some assembly and pass some arguments to it. Browsing the web I found documentation for the x64 calling convention, but can find nothing about 32 bits.

任何人都知道有助于理解参数如何通过的网站,文档或教程在这样的系统上?

Anybody knows of a site, document or tutorial that could help to understand how the parameters are passed on such systems?

还有一个额外的问题......随着新系统进入64位,对32位和64位系统进行开发有多重要,直到32位衰落为止过去?

And one extra question... As newer systems come in 64 bits, how important could be to develop for both 32 and 64 bits systems until the 32 bits fade in the past?

提前致谢

推荐答案

参数被扩展为32位并从右向左推入堆栈:

https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions
。寄存器
EAX EDX ,用于返回结果,不必保留。

Arguments are widened to 32 bits and are pushed onto the stack from right to left: https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions. The registers EAX and EDX, which are used to return the results, do not have to be preserved.

在找到足够的文档之前,您可以尝试这样做:在C或C ++中创建一个类似的函数,使用正确的
__ stdcall __ cdecl __ fastcall 声明,访问一些参数,调用它,并在项目属性中添加"使用源代码组装(/ Fas)"选项。

Before you find sufficient documentation, you can try this: create a similar function in C or C++, use a proper __stdcall, __cdecl or __fastcall declaration, access some parameters, call it, and add the "Assembly With Source Code (/Fas)" option in Project Properties.

编译项目并调查生成的.asm文件。 (您也可以暂时删除"仅支持我的代码调试"和"基本运行时检查"选项,还可以使用
'extern"C"'声明)。您将看到如何使用 EBP 来访问参数以及如何清理堆栈。

Compile the project and investigate the generated .asm files. (You can also temporarily remove the "Support Just My Code Debugging" and "Basic Runtime Checks" options, and also use ‘extern "C"’ declarations). You will see how EBP is used to access the parameters and how the stack is cleaned, for example.


这篇关于调用传递32位系统的约定和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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