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

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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]
hengck23Author Commented:
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.
Then you need to save and restore ebx or ebp to get proper param1 value.
Can you show your code ?
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.