problems with using ebx and ebp registers in inline assembler of MSVC

Posted on 2004-11-07
Last Modified: 2008-03-06
Dear all,

Because i am running out of registers, i am forced to use ebx and ebp.
However, i run into problems in MSVC inline assember whenever i need to reference to memory location. Eg)
void fun(
  int* param1,
) {

.... i change ebx and ebp

__asm mov eax, [param1]  <-- error here (assembly listing shows _$param1[ebx]

How can i resolve this problem?

thank you
Question by:hengck23
    LVL 11

    Expert Comment

    I think it is the same problem you have in previous question.
    You need to do the next:
    __asm mov ebx, param1
    __asm mov eax, [ebx]

    Author Comment

    Thanks for the answer.
    I made a mistake. It should have been:

    __asm mov eax, param1  <-- error here (assembly listing shows _$param1[ebx] )
    __asm mov edx, [eax]

    since ebx has already been changed, "__asm mov eax, param1 " is incorrect.
    LVL 11

    Expert Comment

    Then you need to save and restore ebx or ebp to get proper param1 value.
    Can you show your code ?
    LVL 22

    Accepted Solution

    You can't change bp AND access local variables.  BP points to the local variables on the stack, so you can't mess with bp and still automatically address local variables.

    Alsp note if you use bp as an address register, it uses the stack segment by default, which may not be what you want


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
    Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the fileā€¦

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now