This is mp_divul3_word.c in view mode; [Download] [Up]
typedef unsigned long ulong; ulong divul3(x,y,hi) ulong x,y,*hi; { #define HIBIT 0x80000000 #define HIMASK 0xffff0000 #define LOMASK 0xffff #define HIWORD(a) (a >> 16) /* si le compilateur est bugge, il faut mettre (a >> 16) & LOMASK) */ #define LOWORD(a) (a & LOMASK) #define GLUE(hi, lo) ((hi << 16) + lo) #define SPLIT(a, b, c) b = HIWORD(a); c = LOWORD(a) ulong v1, v2, u3, u4, q1, q2, aux, aux1, aux2,hiremainder=*hi; int k; for(k = 0; !(y & HIBIT); k++) { hiremainder <<= 1; if (x & HIBIT) hiremainder++; x <<= 1; y <<= 1; } SPLIT(y, v1, v2); SPLIT(x, u3, u4); q1 = hiremainder / v1; if (q1 & HIMASK) q1 = LOMASK; hiremainder -= q1 * v1; aux = v2 * q1; again: SPLIT(aux, aux1, aux2); if (aux2 > u3) aux1++; if (aux1 > hiremainder) {q1--; hiremainder += v1; aux -= v2; goto again;} u3 -= aux2; hiremainder -= aux1; hiremainder <<= 16; hiremainder += u3 & LOMASK; q2 = hiremainder / v1; if (q2 & HIMASK) q2 = LOMASK; hiremainder -= q2 * v1; aux = v2 * q2; again2: SPLIT(aux, aux1, aux2); if (aux2 > u4) aux1++; if (aux1 > hiremainder) {q2--; hiremainder += v1; aux -= v2; goto again2;} u4 -= aux2; hiremainder -= aux1; hiremainder <<= 16; hiremainder += u4 & LOMASK; hiremainder >>= k; *hi = hiremainder; return GLUE(q1, q2); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.