Consider inline assembly like this:
uint64_t flags;
asm ("pushf\n\tpop %0" : "=rm"(flags) : : /* ??? */);
Nonwithstanding the fact that there is probably some kind of intrinsic to get the contents of RFLAGS, how do I indicate to the compiler that my inline assembly clobbers one quadword of memory at the top of stack?
add -128/sub -128so they can use an imm8 encoding). And then of course the output constraint has to be"=r", because a memory operand could use an rsp-relative addressing mode. Avoiding the red-zone is the best anyone's been able to come up with in discussions of the same issue on previous SO questions. - Peter Cordes[rsp-8]into a register, but that seems worse than modifying rsp, even if it makes the stack engine insert an extra uop. - Peter Cordespushfis the only way to get the entire RFLAGS register. - fuz-mno-red-zone). So to make a function call in inline-asm, you have to jump through hoops: See stackoverflow.com/questions/37502841/… and stackoverflow.com/questions/37639993/…. (Calling functions from inline asm is just a bad idea, but people trying to learn asm using inline-asm keep wanting to do it.) - Peter Cordes