Borland公司的x86汇编内联;得到一个标签的地址? [英] Borland x86 inlined assembler; get a label's address?
问题描述
我使用Borland的Turbo C ++的一些内联汇编code,所以presumably涡轮汇编(TASM)风格汇编code。我要做到以下几点:
无效美孚::酒吧(无效)
{
__asm
{
MOV EAX,SomeLabel
// ...
}
// ...
SomeLabel:
// ...
}
所以SomeLabel的地址被放置到EAX。这并不工作,编译器抱怨:未定义的符号'SomeLabel
在微软汇编程序(MASM)美元符号($)作为当前位置计数器,这将是我的目的。但同样这似乎并不在Borlands汇编程序(如pression语法错误)工作。
更新:要成为一个更具体一点,我需要编译器生成它编译期间移动到EAX为一个常数地址/联系起来,而不是在运行时间,所以它将编译像MOV EAX,0x00401234<。 / p>
任何人可以建议如何得到这个工作?
更新:为了响应大同的问题(见注释),如果基地址是由Windows在运行时改变加载程序的DLL / EXE PE映像仍将由Windows加载器被重新定位和标签地址将在修补由加载程序运行时使用基于重地址,以便使用一个编译/链接时间值,以便在标签地址是不是一个问题。
提前非常感谢。
我最后一次试图使一些汇编code Borland的兼容我遇到的限制,你不能转发引用标签来了。不知道这是你正在运行的到这里。
I am using Borland Turbo C++ with some inlined assembler code, so presumably Turbo Assembler (TASM) style assembly code. I wish to do the following:
void foo::bar( void )
{
__asm
{
mov eax, SomeLabel
// ...
}
// ...
SomeLabel:
// ...
}
So the address of SomeLabel is placed into EAX. This doesn't work and the compiler complains of: Undefined symbol 'SomeLabel'.
In Microsoft Assembler (MASM) the dollar symbol ($) serves as the current location counter, which would be useful for my purpose. But again this does not seem to work in Borlands Assember (expression syntax error).
Update: To be a little more specific, I need the compiler to generate the address it moves into eax as a constant during compilation/linking and not at run time, so it will compile like "mov eax, 0x00401234".
Can anybody suggest how to get this working?
UPDATE: To respond to Pax's question (see comment), If the base address is changed at run time by the Windows loader the DLL/EXE PE image will still be relocated by the Windows loader and the labels address will be patched at run time by the loader to use the re-based address so using a compile/link time value for the label address is not an issue.
Many thanks in advance.
Last time I tried to make some assembly code Borland-compatible I came across the limitation that you can't forward-reference labels. Not sure if that's what you're running into here.
这篇关于Borland公司的x86汇编内联;得到一个标签的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!