C++ 内嵌汇编 实现 加法操作
原创
©著作权归作者所有:来自51CTO博客作者JeaminThk的原创作品,请联系作者获取转载授权,否则将追究法律责任
程序体现了怎么在C++的代码中进行汇编程序开发
#include <stdio.h>
#include <malloc.h>
void asmFunc(int* pAddress);
void main()
{
int *pAddress=(int*)malloc(sizeof(int));
asmFunc(pAddress);
printf("%d\n",*pAddress);
}
// 0x0F + 0X10 = 0X0F(十进制的31)
void asmFunc(int* pAddress)
{
_asm {
push eax
push ebx
push ecx
mov eax, 0x0F
mov ebx, 0x10
add eax, ebx
mov ecx, pAddress
mov [ecx], eax
pop ecx
pop ebx
pop eax
}
}
结果输出:31