使用c语言打印x86寄存器

使用c语言打印x86寄存器

void main()
{

    int out = 0;
    asm ("movl %%ecx, %0\n" : "=r"(out));
    printf("ecx is %x\n",out);
    int seg;
    asm volatile("movw %%fs,%0" : "=rm" (seg));
    printf("fs is %x\n",seg);

    asm ("movw %%cs, %0\n" : "=rm"(out));
    printf("cs is %x\n",out);

    asm ("movw %%ds, %0\n" : "=rm"(out));
    printf("ds is %x\n",out);

     asm ("movw %%es, %0\n" : "=rm"(out));
    printf("es is %x\n",out);


     asm ("movw %%ss, %0\n" : "=rm"(out));
    printf("ss is %x\n",out);

}
~
x64的寄存器

define get_bp(bp) asm(“movq %%rbp, %0” : “=r” (bp) :)

猜你喜欢

转载自blog.csdn.net/wdjjwb/article/details/77367503
今日推荐