65,206
社区成员
发帖
与我相关
我的任务
分享
struct count
{
int x1;
int x2;
int x3;
int x4;
int x5;
int x6;
}
#include <stdio.h>
#include <memory.h>
struct count {
int x1;
int x2;
int x3;
int x4;
int x5;
int x6;
} c,*p;
int main() {
p=&c;
__asm {
push ecx
push edi
mov eax,3
mov ecx,6
mov edi,p
rep stosd
pop edi
pop ecx
}
printf("%d,%d,%d,%d,%d,%d\n",c.x1,c.x2,c.x3,c.x4,c.x5,c.x6);
__asm {
push ecx
push edi
push esi
mov esi,p
mov edi,esi
mov ecx,6
next:
lodsd
neg eax
stosd
loop next
pop esi
pop edi
pop ecx
}
printf("%d,%d,%d,%d,%d,%d\n",c.x1,c.x2,c.x3,c.x4,c.x5,c.x6);
return 0;
}
//3,3,3,3,3,3
//-3,-3,-3,-3,-3,-3
用意念
count c;
int* p = (int*)&c
for (int i = 0; i < 6; ++i, ++p)
{
*p = -*p;
}