#include "os.h" #include #include "dat.h" #define LO(x) ((x) & ((1<<(Dbits/2))-1)) #define HI(x) ((x) >> (Dbits/2)) static void mpdigmul(mpdigit a, mpdigit b, mpdigit *p) { mpdigit x, ah, al, bh, bl, p1, p2, p3, p4; int carry; // half digits ah = HI(a); al = LO(a); bh = HI(b); bl = LO(b); // partial products p1 = ah*bl; p2 = bh*al; p3 = bl*al; p4 = ah*bh; // p = ((p1+p2)<<(Dbits/2)) + (p4< x) borrow = 1; else borrow = 0; x = part[1]; mpdigmul(*b++, m, part); x += part[0]; if(x < part[0]) borrow++; x = y - x; if(x > y) borrow++; *p++ = x; } x = *p; y = x - borrow - part[1]; *p = y; if(y > x) return -1; else return 1; }