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
I think the problem you're running into is that a label inside the __asm
block and the label in the C++ code are two completely different things. I wouldn't expect that you could reference a C++ label in that way from inline assembly, but I must say it's been a very long time since I've used Turbo C++.
Have you tried the lea
instruction instead of mov
?
This is a variant of Ivan's suggestion but give this a try:
void foo::bar( void )
{
__asm
{
mov eax, offset SomeLabel
// ...
}
// ...
__asm SomeLabel:
// ...
}
I don't know about your compiler / assembler specifically, but a trick I've used quite a bit is to call the next location and then pop the stack into your register. Be certain the call you make only pushes the return address.
Just guessing since I haven't used inline assembler with any C/++ compiler...
void foo::bar( void )
{
__asm
{
mov eax, SomeLabel
// ...
}
// ...
__asm
{
SomeLabel:
// ...
}
// ...
}
I don't know the exact syntax of TASM.
one of the options would be to use separate "naked" (prolog-less) procedure SomeLabel instead of label
Does the Turbo C++ environment have a way to set options for TASM (I know that some of the Borland IDEs did)?
If so, see if changing the option for "Maximum passes (/m)" to 2 or more helps (it might default to 1 pass).
Also, if you're using a long label name that might pose a problem - at least one IDE had the default set to 12. Change the "Maximum symbol length (/mv) option".
This information is based on Borland's RAD Studio IDE: