Konvertieren Sie Inline-Assembly-Code in C ++
Ich arbeite an einem CPP-Projekt. Das Projekt muss auf 64 Bit migriert werden. Es enthält Inline-Assemblycode, der unter x64 nicht kompiliert werden kann. Dies ist die Funktion, die den Assembler-Code enthält:
void ExternalFunctionCall::callFunction(ArgType resultType, void* resultBuffer)
{
#if defined(_NT_) || defined(__OS2__)
// I386
// just copy the args buffer to the stack (it's already layed out correctly)
int* begin = m_argsBegin;
int* ptr = m_argsEnd;
int arr[1000], i=0;
while (ptr > begin) {
int val = *(--ptr);
__asm push val
}
void* functionAddress = m_functionAddress;
// call the function & handle the return value. use __stdcall calling convention
switch (resultType) {
case voidType:
__asm {
call functionAddress
}
break;
case pointerType:
case int32Type:
__asm {
call functionAddress
mov ebx, resultBuffer
mov dword ptr [ebx],eax
}
break;
case floatType:
__asm {
call functionAddress
mov ebx, resultBuffer
fstp dword ptr [ebx]
}
break;
case doubleType:
__asm {
call functionAddress
mov ebx, resultBuffer
fstp qword ptr [ebx]
}
break;
}
Ich habe dieses "asm push val" mit stack, array migriert, aber es hat nicht funktioniert. Es wird zwar kein Kompilierungsfehler ausgegeben, aber die Logik hat nicht funktioniert.
Also möchte ich fragen, was ich in C ++ anstelle von "__asm push val" verwenden kann. Jede Hilfe wird geschätzt.