i dont know how to subtract properly in ptx when I have long number
For example
abcdefghil-
mnopqrst
I divide in 2
fghil-
pqrst
and save borrow in “borrow” (it’s int, while all the other are unsigned int)
then i apply carry
and do the rest, that is
abcde-
mno
Sometimes the result is correct, sometimes not (but it has a very little difference from the correct one)
asm("{\n" \
"sub.cc.u32 %5, %5, %10;\n\t"
"subc.cc.u32 %4, %4, %9;\n\t" \
"subc.cc.u32 %3, %3, %8;\n\t" \
"subc.cc.u32 %2, %2, %7;\n\t" \
"subc.cc.u32 %1, %1, %6;\n\t"
"subc.u32 %0, 0, 0;\n\t" \
"}" : "=r"(borrow),"+r"(f),"+r"(g),"+r"(h),"+r"(i),"+r"(l) : "r"(p),"r"(q),"r"(r),"r"(s),"r"(t) : );
// save carry in u and apply
asm("{\n" \
"sub.cc.u32 %4, %4, %5;\n\t"
"subc.cc.u32 %3, %3, 0;\n\t" \
"subc.cc.u32 %2, %2, 0;\n\t" \
"subc.cc.u32 %1, %1, 0;\n\t"
"subc.u32 %0, %0, 0;\n\t" \
"}" : "+r"(a),"+r"(b),"+r"(c),"+r"(d),"+r"(e) : "r"(borrow) : );
// second trance
asm("{\n" \
"sub.cc.u32 %4, %4, %7;\n\t"
"subc.cc.u32 %3, %3, %6;\n\t" \
"subc.cc.u32 %2, %2, %5;\n\t" \
"subc.cc.u32 %1, %1, 0;\n\t"
"subc.u32 %0, %0, 0;\n\t" \
"}" : "+r"(a),"+r"(b),"+r"(c),"+r"(d),"+r"(e) : "r"(m),"r"(n),"r"(o) : );