I think using Jcc's would be longer and not as clear using inline assembly.
Here is what I currently have, using CMOVcc's:
void dump_regs()
{
int eax = 0;
int ebx = 0;
int ecx = 0;
int edx = 0;
int esi = 0;
int edi = 0;
int ebp = 0;
int esp = 0;
int cf = 0;
int sf = 0;
int zf = 0;
int of = 0;
int set = 1; // -52(%ebp)
asm(
"movl %eax, -4(%ebp)\n\t"
"movl %ebx, -8(%ebp)\n\t"
"movl %ecx, -12(%ebp)\n\t"
"movl %edx, -16(%ebp)\n\t"
"movl %esi, -20(%ebp)\n\t"
"movl %edi, -24(%ebp)\n\t"
"movl %ebp, -28(%ebp)\n\t"
"movl %esp, -32(%ebp)\n\t"
"movl $0, %eax\n\t"
"cmovb -52(%ebp),%eax\n\t" // mov if CF = 1
"movl %eax, -36(%ebp) \n\t" // cf
"movl $0, %eax\n\t"
"cmovs -52(%ebp),%eax\n\t" // mov if SF = 1
"movl %eax, -40(%ebp)\n\t" // sf
"movl $0, %eax\n\t"
"cmove -52(%ebp),%eax\n\t" // mov if ZF = 1
"movl %eax, -44(%ebp)\n\t" // zf
"movl $0, %eax\n\t"
"cmovo -52(%ebp),%eax\n\t" // mov if OF = 1
"movl %eax, -48(%ebp)\n\t" // of
"movl -4(%ebp), %eax\n\t" // restore EAX
);
printf("EAX = %#08x\tEBX = %#08x\tECX = %#08x\tEDX = %#08x\n",eax,ebx,ecx,edx);
printf("ESI = %#08x\tEDI = %#08x\tEBP = %#08x\tESP = %#08x\n",esi,edi,ebp,esp);
printf("CF = %d\tSF = %d\tZF = %d\tOF = %d\n",cf,sf,zf,of);
}
One important thing I haven't worked out yet are side-effects, I want to be able to call this without disturbing the state, any tips in that direction are welcome.