ASM In c++ project ...How this little asm code will be in c++
Hellow I found an asm code ... which was integrated in c++ project
templ开发者_JS百科ate <class T>
T returned;
BYTE *tem = buffer;
__asm
{
mov eax, tem
call eax
mov returned, eax
}
So As I don´t know asm It is hard To understood what this code means ... Can anyone convert this ASM code in c++ entirely and post here :) Ttanks...
It looks like it is executing code placed in a buffer and returning the contents of the EAX register. You might try this:
typedef T (*pfn)();
returned = ((pfn) buffer)();
The assembly code is essentially treating tem as a function pointer and calling it. It is then putting the return into returned.
mov eax, tem;
The contents of tem
is transferrer into the processor internal register eax
call eax
The contents of eax
is used to make a function call. The code starting at the address which eax
holds will be executed. After the function call returns the return value will be in the register eax
mov returned, eax
The return value in eax
is transferred into a variable returned
This is what basically the code does. You shold have a look at the call
instuction to know how exactly it works.
精彩评论