Also if inline is the way to go, any good resources on that heh. Like what registers am I free to use? Or can I use them and just restore later?
Basically, in c++, if you wanted to create a pure asm function, using inline, you'd do something similar to this:
void __declspec(naked) AddTwoNumbers(int* storehere, int number1, int number2)
{
_asm {
mov eax, dword ptr ds:[esp+8]
mov ecx, dword ptr ds:[esp+0xC]
add eax, ecx
mov edx, dword ptr ds:[esp+4]
mov dword ptr ds:[edx], eax
retn
}
}
This function would work fine, as it does not modify ebx/edi/esi, as infamous said. However, if you needed to modify them for some reason or another, you could do this:
void __declspec(naked) AddThreeNumbers(int* Storehere, int num1, int num2, int num3)
{
_asm {
push esi
push edi
push ebx
mov esi, dword ptr ds:[esp+8]
mov edi, dword ptr ds:[esp+0xC]
mov ebx, dword ptr ds:[esp+0xF]
add esi, edi
add esi, ebx
mov edi, dword ptr ds:[esp+4]
mov dword ptr ds:[edi], esi
pop ebx
pop edi
pop esi
retn
}
}
Then, to call these functions, you simply just need to do this:
int* Store;
AddTwoNumbers(Store, 1, 3);
AddThreeNumbers(Store, 4, 7);
Hope that helped :o