c - Read register value to variable, with one asm command -
how can read register value variable 1 inline assembler command? using gcc on old freebsd system (v2.1 i386).
i have such code:
static volatile unsigned long r_eax, r_ebx; asm ("movl %%eax, %0\n" :"=r"(r_eax)); asm ("movl %%ebx, %0\n" :"=r"(r_ebx)); as result this:
mov %eax,%eax mov %eax,0x1944b8 mov 0x1944b8,%eax mov %ebx,%eax mov %eax,0x1944bc mov 0x1944bc,%eax but need just:
mov %eax,0x1944b8 mov %ebx,0x1944bc how can achieve result?
this me (as long r_eax / r_ebx static)
asm ("movl %%eax, %0\n" "movl %%ebx, %1\n" : "=m"(r_eax), "=m"(r_ebx)); beware that, unless specify assembly language statements within same asm() bracket, compiler might decide sorts of "interesting optimizations" in-between, including modifications these regs.
Comments
Post a Comment