المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C++ with in-code Assembly



C++ Programming
09-24-2009, 10:22 AM
Hi everyone,

Quick question about inline assembler with C++ code.

I was just wondering if, when using inline assembler in a class method, it is necessary to push all registers I am going to use onto the stack and then pop them off after I'm done. I thought this might be necessary because the C compiler might require their contents after the _asm{} code execution.

For example;

void MyClass::MyFunction(){
int a, b, c; // for example

// maybe have some C code here

_asm{
// *
// assembler code using a number of registers (eax, ebx, ecx, for example)
// **
}

// maybe have some more C code here
}

My question is: should I push (at //*) those registers I'm going to utilize, and then pop them (at //**) in the above code.

Help would be much appreciated.

Many thanks,
Paul