typedef struct tagstru
{
int a;
int b;
int c;
}stru;
stru sa;
sa.a = 0x123;
sa.b = 0x456;
sa.c = 0x789;
printf("stru: a=%d b=%d c=%d\n", sa.a, sa.b, sa.c);
__asm__ __volatile__ (
"xorl %%ecx, %%ecx\n\t"
"xorl %%eax, %%eax\n\t"
"movl %%ecx, (%%ebx)\n\t"
"xorl %%edx, %%edx\n\t"
"movl %%eax, 4(%%ebx)\n\t"
"xorl %%ecx, %%ecx\n\t"
"movl %%edx, 8(%%ebx)"
: "=m"(sa)
: "b"(&sa)
: "eax", "ecx", "edx");
printf("clear stru: a=%d b=%d c=%d\n", sa.a, sa.b, sa.c);
反汇编代码
:00401558 C74588DEBC3A12 mov [ebp-78], 00000123
:0040155F BBDEBC9A78 mov ebx, 00000789
:00401564 B9DEBC6A45 mov ecx, 00000456
:00401569 C7458CDEBC6A45 mov [ebp-74], 00000456
:00401570 BADEBC3A12 mov edx, 0000012