Hi.
If I have the folowing two functions for the device:
typedef unsigned int u32;
__device__ u32
__uaddo(u32 a, u32 b) {
u32 res;
asm("add.cc.u32 %0, %1, %2; /* inline */ \n\t"
: "=r" (res) : "r" (a) , "r" (b));
return res;
}
__device__ u32
__uaddc(u32 a, u32 b) {
u32 res;
asm("addc.u32 %0, %1, %2; /* inline */ \n\t"
: "=r" (res) : "r" (a) , "r" (b));
return res;
}
… and I call them in the folowing order:
u32 a = 0xffffffff;
u32 b = 0xf;
u32 s = __uaddo(a,b);
s = __uaddc(0,0); // s will be 0 (zero) although a+b doesn't fit in 32-bit
What is the reason for not having the carry flag set in the second call?
Someone said that “the flags are ephemeral”.
Isn’t the CC.CF flag a hardware one? Shouldn’t it be set until the next carry-out instruction?