寄存器是什么CPU在德尔福的ASM程序结束时恢复 [英] What CPU registers are to be restored at the end of an asm procedure in Delphi

查看:250
本文介绍了寄存器是什么CPU在德尔福的ASM程序结束时恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当编写汇编code,其注册必须在程序结束?

When writing a Delphi procedure or function in assembly code, which registers must be saved and restored to the original value at the end of the procedure?

当调用来自(内置)组装code另一个德尔福过程或函数,我能想到的其他功能与寄存器呢?哪些寄存器将恢复到其原始值,哪些不可以?

When calling another Delphi procedure or function from (inline) assembly code, what can I expect that other function to do with the registers? Which registers will be restored to their original values and which may not?

(显然,相同的答案也适用于这两个问题)

(Obviously, the same answer would apply to both questions)

我假设的默认调用的Delphi约定。我知道, EAX 用于32位的返回值。并期待在SysUtils.pas的ASM code,似乎 EBX ESI EDI 被压和恢复,但有些则没有。我找不到这个任何文件,但。

I am assuming the default calling convention of Delphi. I know that EAX is used for 32-bit return values. And looking at the asm code in SysUtils.pas, it seems that EBX, ESI and EDI are pushed and restored, but the others are not. I cannot find any documentation about this, though.

推荐答案

函数的三个第一论据 EAX 给出, EDX ECX ,分别为。额外的参数压入堆栈。为一个对象的方法,所述指针总是(不可见的)第一个参数。其结果应该是 EAX 。对于返回长字符串函数,则(不可见)的最后的函数的参数是指向结果字符串(这本身就是一个指向字符串的第一个字符)。

The three first arguments of a function are given in EAX, EDX, and ECX, respectively. Additional arguments are pushed on the stack. For a method of an object, the Self pointer is always the (invisible) first parameter. The result should be in EAX. For functions returning long strings, the (invisible) last parameter of the function is the pointer to the resulting string (which by itself is a pointer to the first character of the string).

EBX 不得改变(除非你的过程/函数结束之前恢复它),所以一定不能 ESP EBP ESI EDI 无论是。<一个href=\"http://docwiki.embarcadero.com/RADStudio/en/Using_Inline_Assembly_$c$c_(Win32_Only)\">(1)一个优秀的介绍德尔福内嵌ASM用来在这里找到:<一href=\"http://www.delphi3000.com/articles/article_3766.asp\">http://www.delphi3000.com/articles/article_3766.asp

EBX must not be altered (unless you restore it before the end of the procedure/function), and so must not ESP, EBP, ESI, or EDI either.(1) An excellent introduction to Delphi inline ASM used to be found here: http://www.delphi3000.com/articles/article_3766.asp

这篇关于寄存器是什么CPU在德尔福的ASM程序结束时恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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