I would like to return a flag using inline assembly.
Here is the inline code:
Code: Select all
FIL bool Lock_BTR(QWORD* variable, BYTE Bit)
{
bool r;
QWORD b = Bit;
asm volatile("lock btrq %1, %2; setc %0;"
: "=g" (r) //Output
: "Ir" (b), "m" (*variable) //Input
:"cc");
return r;
}
Code: Select all
31e7ce: f0 4d 0f b3 10 lock btr QWORD PTR [r8],r10
31e7d3: 41 0f 92 c3 setb r11b
31e7d7: 45 84 db test r11b,r11b
31e7da: 75 44 jne 31e820 <_ZN6System4tHub11_ProcessCPUEv+0xb0>
I know I put the setc in the inline, but is there anyway to have it return the value without using setc so the compiler can remove a couple of instructions?
I would like a simple lock btr and then jb or jc...
For complete-ness, here is the c+ call
EDIT: New Code in function.
Code: Select all
FIL bool tCPU::EthernetCardAction()
{
if (APICID < 64)
return Lock_BTR(&ABIT.Ethernet->EthernetCardAction0, APICID);
if (APICID < 128)
return Lock_BTR(&ABIT.Ethernet->EthernetCardAction0, APICID - 64);
if (APICID < 192)
return Lock_BTR(&ABIT.Ethernet->EthernetCardAction0, APICID - 128);
return Lock_BTR(&ABIT.Ethernet->EthernetCardAction0, APICID - 192);
}