diff --git a/mach/proto/fp/cmf8.c b/mach/proto/fp/cmf8.c index 743ea5d46..c63145bec 100644 --- a/mach/proto/fp/cmf8.c +++ b/mach/proto/fp/cmf8.c @@ -23,8 +23,13 @@ _double d1,d2; int sign1,sign2; int rv; +#if FL_MSL_AT_LOW_ADDRESS l1 = get4((char *)&d1); l2 = get4((char *)&d2); +#else + l1 = get4(((char *)&d1+4)); + l2 = get4(((char *)&d2+4)); +#endif sign1 = SIGN(l1); sign2 = SIGN(l2); if (sign1 != sign2) { @@ -39,8 +44,13 @@ _double d1,d2; } else { /* decide in 2nd half */ unsigned long u1, u2; +#if FL_MSL_AT_LOW_ADDRESS u1 = get4(((char *)&d1 + 4)); u2 = get4(((char *)&d2 + 4)); +#else + u1 = get4((char *)&d1); + u2 = get4((char *)&d2); +#endif if (u1 == u2) return(0); if (u1 < u2) rv = 1; diff --git a/mach/proto/fp/compact.c b/mach/proto/fp/compact.c index c19576b92..55c3c22eb 100644 --- a/mach/proto/fp/compact.c +++ b/mach/proto/fp/compact.c @@ -108,8 +108,16 @@ dbl_over: trap(EFOVFL); * STORE MANTISSA */ +#if FL_MSL_AT_LOW_ADDRESS put4(DBL->_s.p1.fract, (char *) &DBL->_s.p1.fract); put4(DBL->_s.p2, (char *) &DBL->_s.p2); +#else + { unsigned long l; + put4(DBL->_s.p2, (char *) &l); + put4(DBL->_s.p1.fract, (char *) &DBL->_s.p2); + DBL->_s.p1.fract = l; + } +#endif } else { /* diff --git a/mach/proto/fp/extend.c b/mach/proto/fp/extend.c index 402b9eab7..2acf307a6 100644 --- a/mach/proto/fp/extend.c +++ b/mach/proto/fp/extend.c @@ -52,9 +52,20 @@ zero: zrf_ext(to); goto zero; } /* there is a number to convert so lets get started */ -/* first extract the exponent; its always in the first two bytes */ +#if FL_MSL_AT_LOW_ADDRESS +#if FL_MSW_AT_LOW_ADDRESS to->exp = uget2(cpt1); +#else + to->exp = uget2(cpt1+2); +#endif +#else +#if FL_MSW_AT_LOW_ADDRESS + to->exp = uget2(cpt1+4); +#else + to->exp = uget2(cpt1+6); +#endif +#endif to->sign = (to->exp & 0x8000); /* set sign bit */ to->exp ^= to->sign; if (size == sizeof(DOUBLE)) @@ -65,17 +76,23 @@ zero: zrf_ext(to); leadbit++; /* will set Lead bit later */ else to->exp++; - to->m1 = get4(cpt1); - if (size == sizeof(DOUBLE)) { - to->m1 <<= DBL_M1LEFT; /* shift */ - to->exp -= DBL_BIAS; /* remove bias */ +#if FL_MSL_AT_LOW_ADDRESS + to->m1 = get4(cpt1); cpt1 += 4; tmp = get4(cpt1); +#else + tmp = get4(cpt1); + cpt1 += 4; + to->m1 = get4(cpt1); +#endif + to->m1 <<= DBL_M1LEFT; /* shift */ + to->exp -= DBL_BIAS; /* remove bias */ to->m1 |= (tmp>>DBL_RPACK); /* plus 10 == 32 */ to->m2 = (tmp<m1 = get4(cpt1); to->m1 <<= SGL_M1LEFT; /* shift */ to->exp -= SGL_BIAS; /* remove bias */ to->m2 = 0L; diff --git a/mach/proto/fp/get_put.h b/mach/proto/fp/get_put.h index 48b1b8bf2..9fd7f606f 100644 --- a/mach/proto/fp/get_put.h +++ b/mach/proto/fp/get_put.h @@ -13,7 +13,11 @@ #define Xchar(ch) ((ch) & 0377) #endif -#if ! BYTES_REVERSED +#define BYTES_REVERSED (MSB_AT_LOW_ADDRESS != FL_MSB_AT_LOW_ADDRESS) +#define WORDS_REVERSED (MSW_AT_LOW_ADDRESS != FL_MSW_AT_LOW_ADDRESS) +#define LONGS_REVERSED (FL_MSL_AT_LOW_ADDRESS) + +#if BYTES_REVERSED #define uget2(c) (Xchar((c)[1]) | ((unsigned) Xchar((c)[0]) << 8)) #define Xput2(i, c) (((c)[1] = (i)), ((c)[0] = (i) >> 8)) #define put2(i, c) { register int j = (i); Xput2(j, c); } @@ -25,7 +29,7 @@ #define get2(c) ((short) uget2(c)) -#if WORDS_REVERSED || ! BYTES_REVERSED +#if WORDS_REVERSED || BYTES_REVERSED #define get4(c) (uget2((c)+2) | ((long) uget2(c) << 16)) #define put4(l, c) { register long x=(l); \ Xput2((int)x,(c)+2); \ diff --git a/mach/proto/fp/ngf4.c b/mach/proto/fp/ngf4.c index f8633eb83..328ebd981 100644 --- a/mach/proto/fp/ngf4.c +++ b/mach/proto/fp/ngf4.c @@ -9,13 +9,11 @@ NEGATE A FLOATING POINT (NGF 4) */ /********************************************************/ -/* - Assumes exponent is located in bytes 0 & 1 -*/ -/********************************************************/ #include "FP_types.h" +#include "get_put.h" +#define OFF ((FL_MSW_AT_LOW_ADDRESS ? 0 : 2) + (FL_MSB_AT_LOW_ADDRESS ? 0 : 1)) _float ngf4(f) _float f; @@ -23,7 +21,7 @@ _float f; unsigned char *p; if (f != (_float) 0) { - p = (unsigned char *) &f; + p = (unsigned char *) &f + OFF; *p ^= 0x80; } return f; diff --git a/mach/proto/fp/ngf8.c b/mach/proto/fp/ngf8.c index 91aa46f4c..891b2f856 100644 --- a/mach/proto/fp/ngf8.c +++ b/mach/proto/fp/ngf8.c @@ -9,12 +9,11 @@ NEGATE A FLOATING POINT (NGF 8) */ /********************************************************/ -/* - Assumes exponent is located in bytes 0 & 1 -*/ -/********************************************************/ #include "FP_types.h" +#include "get_put.h" + +#define OFF ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) + (FL_MSB_AT_LOW_ADDRESS ? 0 : 1)) _double ngf8(f) @@ -23,7 +22,7 @@ _double f; unsigned char *p; if (f.__double[0] != 0 || f.__double[1] != 0) { - p = (unsigned char *) &f; + p = (unsigned char *) &f + OFF; *p ^= 0x80; } return f; diff --git a/mach/proto/fp/sbf4.c b/mach/proto/fp/sbf4.c index e6a3aa484..80e1dec59 100644 --- a/mach/proto/fp/sbf4.c +++ b/mach/proto/fp/sbf4.c @@ -11,20 +11,18 @@ #include "FP_types.h" -extern _float adf4(); +extern _float adf4(), ngf4(); _float sbf4(s2,s1) _float s1,s2; { - unsigned char *p; _float *result = &s1; /* s1 may not be in a register! */ if (s2 == (_float) 0) { return s1; } - p = (unsigned char *) &s2; - *p ^= 0x80; /* change sign of s2 */ + s2 = ngf4(s2); *result = adf4(s2,s1); return(s1); /* add and return result */ } diff --git a/mach/proto/fp/sbf8.c b/mach/proto/fp/sbf8.c index f2b711230..444321e7d 100644 --- a/mach/proto/fp/sbf8.c +++ b/mach/proto/fp/sbf8.c @@ -11,20 +11,18 @@ #include "FP_types.h" -extern _double adf8(); +extern _double adf8(), ngf8(); _double sbf8(s2,s1) _double s1,s2; { - unsigned char *p; /* sufficient to access sign bit */ _double *result = &s1; /* s1 may not be in a register! */ if (s2.__double[0] == 0 && s2.__double[1] == 0) { return s1; } - p = (unsigned char *) &s2; - *p ^= 0x80; /* change sign of s2 */ + s2 = ngf8(s2); *result = adf8(s2,s1); /* add and return result */ return(s1); }