merged with Michael Felts latest version
This commit is contained in:
parent
b09805786d
commit
bcec2e84b5
40 changed files with 124 additions and 417 deletions
|
@ -36,8 +36,6 @@ mul_ext.c
|
||||||
ngf4.c
|
ngf4.c
|
||||||
ngf8.c
|
ngf8.c
|
||||||
nrm_ext.c
|
nrm_ext.c
|
||||||
prt_dbl.c
|
|
||||||
prt_ext.c
|
|
||||||
sbf4.c
|
sbf4.c
|
||||||
sbf8.c
|
sbf8.c
|
||||||
sft_ext.c
|
sft_ext.c
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/*
|
/*
|
||||||
|
Type definitions for C Floating Point Package
|
||||||
include file for floating point package
|
include file for floating point package
|
||||||
*/
|
*/
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
@ -20,6 +21,16 @@
|
||||||
EXTEND: double precision extended format
|
EXTEND: double precision extended format
|
||||||
*/
|
*/
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
|
#ifdef EXT_DEBUG
|
||||||
|
#ifndef __FPSTDIO
|
||||||
|
#define __FPSTDIO
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FPTYPES
|
||||||
|
#define __FPTYPES
|
||||||
typedef unsigned long _float;
|
typedef unsigned long _float;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
|
@ -55,6 +66,4 @@ typedef struct { /* expanded float format */
|
||||||
unsigned long m1;
|
unsigned long m1;
|
||||||
unsigned long m2; /* includes guard byte */
|
unsigned long m2; /* includes guard byte */
|
||||||
} EXTEND;
|
} EXTEND;
|
||||||
#ifdef PRT_EXT
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,9 +41,7 @@ LIST = cff4.$(SUF) cff8.$(SUF) cfu.$(SUF) cmf4.$(SUF) cmf8.$(SUF)\
|
||||||
extend.$(SUF) compact.$(SUF)\
|
extend.$(SUF) compact.$(SUF)\
|
||||||
add_ext.$(SUF) div_ext.$(SUF) mul_ext.$(SUF) nrm_ext.$(SUF)\
|
add_ext.$(SUF) div_ext.$(SUF) mul_ext.$(SUF) nrm_ext.$(SUF)\
|
||||||
sft_ext.$(SUF) sub_ext.$(SUF) zrf_ext.$(SUF)\
|
sft_ext.$(SUF) sub_ext.$(SUF) zrf_ext.$(SUF)\
|
||||||
adder.$(SUF) shifter.$(SUF)\
|
adder.$(SUF) shifter.$(SUF) fptrp.$(SUF)
|
||||||
prt_dbl.$(SUF)\
|
|
||||||
fptrp.$(SUF) prt_ext.$(SUF) # debugging
|
|
||||||
SLIST = cff4.s cff8.s cfu.s cmf4.s cmf8.s\
|
SLIST = cff4.s cff8.s cfu.s cmf4.s cmf8.s\
|
||||||
cuf4.s cuf8.s\
|
cuf4.s cuf8.s\
|
||||||
dvf4.s dvf8.s fef4.s fef8.s\
|
dvf4.s dvf8.s fef4.s fef8.s\
|
||||||
|
@ -55,9 +53,7 @@ SLIST = cff4.s cff8.s cfu.s cmf4.s cmf8.s\
|
||||||
extend.s compact.s\
|
extend.s compact.s\
|
||||||
add_ext.s div_ext.s mul_ext.s nrm_ext.s\
|
add_ext.s div_ext.s mul_ext.s nrm_ext.s\
|
||||||
sft_ext.s sub_ext.s zrf_ext.s\
|
sft_ext.s sub_ext.s zrf_ext.s\
|
||||||
adder.s shifter.s\
|
adder.s shifter.s fptrp.s
|
||||||
prt_dbl.s\
|
|
||||||
fptrp.s prt_ext.s # debugging
|
|
||||||
|
|
||||||
SRC = FP_bias.h FP_shift.h FP_trap.h FP_types.h adder.h get_put.h\
|
SRC = FP_bias.h FP_shift.h FP_trap.h FP_types.h adder.h get_put.h\
|
||||||
cff4.c cff8.c cfu.c cmf4.c cmf8.c\
|
cff4.c cff8.c cfu.c cmf4.c cmf8.c\
|
||||||
|
@ -71,9 +67,7 @@ SRC = FP_bias.h FP_shift.h FP_trap.h FP_types.h adder.h get_put.h\
|
||||||
extend.c compact.c\
|
extend.c compact.c\
|
||||||
add_ext.c div_ext.c mul_ext.c nrm_ext.c\
|
add_ext.c div_ext.c mul_ext.c nrm_ext.c\
|
||||||
sft_ext.c sub_ext.c zrf_ext.c\
|
sft_ext.c sub_ext.c zrf_ext.c\
|
||||||
adder.c shifter.c\
|
adder.c shifter.c fptrp.e
|
||||||
prt_dbl.c\
|
|
||||||
fptrp.e prt_ext.c
|
|
||||||
|
|
||||||
all: FP_$(MACH).a
|
all: FP_$(MACH).a
|
||||||
|
|
||||||
|
@ -284,13 +278,3 @@ shifter.$(SUF): $(CDIR)/shifter.c
|
||||||
ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/shifter.c
|
ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/shifter.c
|
||||||
ed - shifter.s <$(CDIR)/FP.script
|
ed - shifter.s <$(CDIR)/FP.script
|
||||||
ack -c -m$(MACH) $(EMFLAGS) shifter.s
|
ack -c -m$(MACH) $(EMFLAGS) shifter.s
|
||||||
|
|
||||||
prt_dbl.$(SUF): $(CDIR)/prt_dbl.c
|
|
||||||
ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/prt_dbl.c
|
|
||||||
ed - prt_dbl.s <$(CDIR)/FP.script
|
|
||||||
ack -c -m$(MACH) $(EMFLAGS) prt_dbl.s
|
|
||||||
|
|
||||||
prt_ext.$(SUF): $(CDIR)/prt_ext.c
|
|
||||||
ack -c.s -m$(MACH) $(EMFLAGS) $(CDIR)/prt_ext.c
|
|
||||||
ed - prt_ext.s <$(CDIR)/FP.script
|
|
||||||
ack -c -m$(MACH) $(EMFLAGS) prt_ext.s
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PRT_EXT
|
|
||||||
ADD TWO EXTENDED FORMAT NUMBERS
|
ADD TWO EXTENDED FORMAT NUMBERS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -15,20 +14,10 @@
|
||||||
add_ext(e1,e2)
|
add_ext(e1,e2)
|
||||||
register EXTEND *e1,*e2;
|
register EXTEND *e1,*e2;
|
||||||
{
|
{
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("before ADD #1:",e1);
|
|
||||||
prt_ext("before ADD #2:",e2);
|
|
||||||
#endif PRT_EXT
|
|
||||||
if (b64_add(&e1->m1,&e2->m1)) { /* addition carry */
|
if (b64_add(&e1->m1,&e2->m1)) { /* addition carry */
|
||||||
b64_sft(&e1->m1,1); /* shift mantissa one bit RIGHT */
|
b64_sft(&e1->m1,1); /* shift mantissa one bit RIGHT */
|
||||||
e1->m1 |= 0x80000000L; /* set max bit */
|
e1->m1 |= 0x80000000L; /* set max bit */
|
||||||
e1->exp++; /* increase the exponent */
|
e1->exp++; /* increase the exponent */
|
||||||
}
|
}
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("AFTER ADD :",e1);
|
|
||||||
#endif
|
|
||||||
nrm_ext(e1);
|
nrm_ext(e1);
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("AFTER NRM :",e1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* these are the routines the routines to do 32 and 64-bit addition
|
* these are the routines the routines to do 32 and 64-bit addition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# ifdef DEBUG
|
# ifdef EXT_DEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -28,15 +28,15 @@ b64_add(e1,e2)
|
||||||
*/
|
*/
|
||||||
register B64 *e1,*e2;
|
register B64 *e1,*e2;
|
||||||
{
|
{
|
||||||
register short overflow;
|
register int overflow;
|
||||||
short carry;
|
int carry;
|
||||||
|
|
||||||
/* add higher pair of 32 bits */
|
/* add higher pair of 32 bits */
|
||||||
overflow = b32_add(&e1->h_32,&e2->h_32);
|
overflow = b32_add(&e1->h_32,&e2->h_32);
|
||||||
|
|
||||||
/* add lower pair of 32 bits */
|
/* add lower pair of 32 bits */
|
||||||
carry = b32_add(&e1->l_32,&e2->l_32);
|
carry = b32_add(&e1->l_32,&e2->l_32);
|
||||||
# ifdef DEBUG
|
# ifdef EXT_DEBUG
|
||||||
printf("\t\t\t\t\tb64_add: overflow (%d); internal carry(%d)\n",
|
printf("\t\t\t\t\tb64_add: overflow (%d); internal carry(%d)\n",
|
||||||
overflow,carry);
|
overflow,carry);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -55,7 +55,7 @@ register B64 *e1,*e2;
|
||||||
b32_add(e1,e2)
|
b32_add(e1,e2)
|
||||||
register unsigned long *e1,*e2;
|
register unsigned long *e1,*e2;
|
||||||
{
|
{
|
||||||
register short carry;
|
register int carry;
|
||||||
|
|
||||||
if (*e1 & *e2 & MAXBIT) /* both max_bits are set */
|
if (*e1 & *e2 & MAXBIT) /* both max_bits are set */
|
||||||
carry = TRUE; /* so there is a carry */
|
carry = TRUE; /* so there is a carry */
|
||||||
|
@ -65,7 +65,7 @@ register unsigned long *e1,*e2;
|
||||||
? UNKNOWN
|
? UNKNOWN
|
||||||
/* both are clear - no carry */
|
/* both are clear - no carry */
|
||||||
: FALSE;
|
: FALSE;
|
||||||
# ifdef DEBUG
|
# ifdef EXT_DEBUG
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
printf("\t\t\t\t\tb32_add: overflow before add(%d) test(%d)\n",
|
printf("\t\t\t\t\tb32_add: overflow before add(%d) test(%d)\n",
|
||||||
carry,(*e1&MAXBIT)?FALSE:TRUE);
|
carry,(*e1&MAXBIT)?FALSE:TRUE);
|
||||||
|
@ -73,7 +73,7 @@ register unsigned long *e1,*e2;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
*e1 += *e2;
|
*e1 += *e2;
|
||||||
# ifdef DEBUG
|
# ifdef EXT_DEBUG
|
||||||
printf("%08X\n",*e1);
|
printf("%08X\n",*e1);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ADD TWO FLOATS - SINGLE
|
ADD TWO FLOATS - SINGLE (ADF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
@ -30,9 +30,6 @@ _float s1,s2;
|
||||||
/* if signs differ do subtraction */
|
/* if signs differ do subtraction */
|
||||||
/* result in e1 */
|
/* result in e1 */
|
||||||
if (e1.sign ^ e2.sign) {
|
if (e1.sign ^ e2.sign) {
|
||||||
#ifdef DEBUG
|
|
||||||
printf("\t\t\tADF calls SUBTRACT\n");
|
|
||||||
#endif DEBUG
|
|
||||||
/* set sign of e1 to sign of largest */
|
/* set sign of e1 to sign of largest */
|
||||||
swap = (e2.exp > e1.exp) ? 1 : (e2.exp < e1.exp) ? 0 :
|
swap = (e2.exp > e1.exp) ? 1 : (e2.exp < e1.exp) ? 0 :
|
||||||
(e2.m1 > e1.m1 ) ? 1 : 0;
|
(e2.m1 > e1.m1 ) ? 1 : 0;
|
||||||
|
@ -40,9 +37,6 @@ _float s1,s2;
|
||||||
sft_ext(&e1,&e2);
|
sft_ext(&e1,&e2);
|
||||||
/* subtract the extended formats */
|
/* subtract the extended formats */
|
||||||
if (swap) {
|
if (swap) {
|
||||||
#ifdef DEBUG
|
|
||||||
printf("\t\t\t\tSWAP\n");
|
|
||||||
#endif DEBUG
|
|
||||||
sub_ext(&e2,&e1);
|
sub_ext(&e2,&e1);
|
||||||
e1 = e2;
|
e1 = e2;
|
||||||
}
|
}
|
||||||
|
@ -50,9 +44,6 @@ _float s1,s2;
|
||||||
sub_ext(&e1,&e2);
|
sub_ext(&e1,&e2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef DEBUG
|
|
||||||
printf("\t\t\tADF calls ADDITION\n");
|
|
||||||
#endif DEBUG
|
|
||||||
/* adjust mantissas to equal powers */
|
/* adjust mantissas to equal powers */
|
||||||
sft_ext(&e1,&e2);
|
sft_ext(&e1,&e2);
|
||||||
add_ext(&e1,&e2);
|
add_ext(&e1,&e2);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ADD TWO FLOATS - DOUBLE
|
ADD TWO FLOATS - DOUBLE (ADF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
@ -16,7 +16,7 @@ adf8(s2,s1)
|
||||||
_double s1,s2;
|
_double s1,s2;
|
||||||
{
|
{
|
||||||
EXTEND e1,e2;
|
EXTEND e1,e2;
|
||||||
short swap;
|
int swap;
|
||||||
|
|
||||||
if (s1.__double[0] == 0 && s1.__double[1] == 0) {
|
if (s1.__double[0] == 0 && s1.__double[1] == 0) {
|
||||||
s1 = s2;
|
s1 = s2;
|
||||||
|
@ -28,10 +28,6 @@ _double s1,s2;
|
||||||
|
|
||||||
extend(&s1,&e1,sizeof(_double));
|
extend(&s1,&e1,sizeof(_double));
|
||||||
extend(&s2,&e2,sizeof(_double));
|
extend(&s2,&e2,sizeof(_double));
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("ADF8: e1",&e1);
|
|
||||||
prt_ext("ADF8: e2",&e2);
|
|
||||||
#endif
|
|
||||||
/* adjust mantissas to equal powers */
|
/* adjust mantissas to equal powers */
|
||||||
if (e1.sign ^ e2.sign) { /* signs are different */
|
if (e1.sign ^ e2.sign) { /* signs are different */
|
||||||
/* determine which is largest number */
|
/* determine which is largest number */
|
||||||
|
@ -42,9 +38,6 @@ _double s1,s2;
|
||||||
sft_ext(&e1,&e2);
|
sft_ext(&e1,&e2);
|
||||||
/* subtract the extended formats */
|
/* subtract the extended formats */
|
||||||
if (swap) { /* &e2 is the largest number */
|
if (swap) { /* &e2 is the largest number */
|
||||||
#ifdef PRT_EXT
|
|
||||||
fprintf(stderr,"ADF8: swaps and subtracts extended\n");
|
|
||||||
#endif
|
|
||||||
sub_ext(&e2,&e1);
|
sub_ext(&e2,&e1);
|
||||||
e1 = e2;
|
e1 = e2;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +50,6 @@ _double s1,s2;
|
||||||
sft_ext(&e1,&e2);
|
sft_ext(&e1,&e2);
|
||||||
add_ext(&e1,&e2);
|
add_ext(&e1,&e2);
|
||||||
}
|
}
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("ADF8: e1 result",&e1);
|
|
||||||
#endif
|
|
||||||
compact(&e1,&s1,sizeof(_double));
|
compact(&e1,&s1,sizeof(_double));
|
||||||
return(s1);
|
return(s1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT DOUBLE TO FLOAT
|
CONVERT DOUBLE TO FLOAT (CFF 8 4)
|
||||||
|
|
||||||
This routine works quite simply. A floating point
|
This routine works quite simply. A floating point
|
||||||
of size 08 is converted to extended format.
|
of size 08 is converted to extended format.
|
||||||
|
@ -23,13 +23,5 @@ _double src; /* the source itself - THIS TIME it's DOUBLE */
|
||||||
EXTEND buf;
|
EXTEND buf;
|
||||||
|
|
||||||
extend(&src,&buf,8); /* no matter what */
|
extend(&src,&buf,8); /* no matter what */
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("CFF4() entry:",&buf);
|
|
||||||
fprintf(stderr,"ds(%d),ss(%d),src(%08X%08X)\n",8,4,src.__double[0],
|
|
||||||
src.__double[1]);
|
|
||||||
#endif PRT_EXT
|
|
||||||
compact(&buf,(_double *) &(src.__double[1]),4);
|
compact(&buf,(_double *) &(src.__double[1]),4);
|
||||||
#ifdef PRT_EXT
|
|
||||||
fprintf(stderr,"CFF4() exit : %08X\n",src.__double[1]);
|
|
||||||
#endif PRT_EXT
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT FLOAT TO DOUBLE
|
CONVERT FLOAT TO DOUBLE (CFF 4 8)
|
||||||
|
|
||||||
This routine works quite simply. A floating point
|
This routine works quite simply. A floating point
|
||||||
of size 04 is converted to extended format.
|
of size 04 is converted to extended format.
|
||||||
|
@ -23,13 +23,5 @@ _float src; /* the space on the stack is for a double - see cg/table */
|
||||||
EXTEND buf;
|
EXTEND buf;
|
||||||
|
|
||||||
extend((_double *) &src,&buf,4); /* no matter what */
|
extend((_double *) &src,&buf,4); /* no matter what */
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("CFF8() entry:",&buf);
|
|
||||||
fprintf(stderr,"ds(%d),ss(%d),src(%08X)\n",4,8,src);
|
|
||||||
#endif
|
|
||||||
compact(&buf,&src,8);
|
compact(&buf,&src,8);
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"CFF8() exit : %08X",src.__double[0]);
|
|
||||||
fprintf(stderr,"%08X\n",src.__double[1]);
|
|
||||||
#endif DEBUG
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT FLOAT TO UNSIGNED
|
CONVERT FLOAT TO SIGNED (CFI m n)
|
||||||
|
|
||||||
N.B. The caller must know what it is getting.
|
N.B. The caller must know what it is getting.
|
||||||
A LONG is always returned. If it is an
|
A LONG is always returned. If it is an
|
||||||
|
@ -27,9 +27,6 @@ _double src; /* assume worst case */
|
||||||
short newint, max_exp;
|
short newint, max_exp;
|
||||||
|
|
||||||
extend(&src,&buf,ss); /* get extended format */
|
extend(&src,&buf,ss); /* get extended format */
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("CFI() entry:",&buf);
|
|
||||||
#endif PRT_EXT
|
|
||||||
buf.exp--; /* additional bias correction */
|
buf.exp--; /* additional bias correction */
|
||||||
if (buf.exp < 1) { /* no conversion needed */
|
if (buf.exp < 1) { /* no conversion needed */
|
||||||
src.__double[ss == 8] = 0L;
|
src.__double[ss == 8] = 0L;
|
||||||
|
@ -38,9 +35,6 @@ _double src; /* assume worst case */
|
||||||
max_exp = (ds << 3) - 1; /* signed numbers */
|
max_exp = (ds << 3) - 1; /* signed numbers */
|
||||||
/* have more limited max_exp */
|
/* have more limited max_exp */
|
||||||
if (buf.exp > max_exp) {
|
if (buf.exp > max_exp) {
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("CFI() INT OVERFLOW", &buf);
|
|
||||||
#endif PRT_EXT
|
|
||||||
trap(EIOVFL); /* integer overflow */
|
trap(EIOVFL); /* integer overflow */
|
||||||
buf.exp %= max_exp; /* truncate */
|
buf.exp %= max_exp; /* truncate */
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT FLOAT TO UNSIGNED
|
CONVERT FLOAT TO UNSIGNED (CFU m n)
|
||||||
|
|
||||||
N.B. The caller must know what it is getting.
|
N.B. The caller must know what it is getting.
|
||||||
A LONG is always returned. If it is an
|
A LONG is always returned. If it is an
|
||||||
|
@ -27,9 +27,6 @@ _double src; /* assume worst case */
|
||||||
short newint, max_exp;
|
short newint, max_exp;
|
||||||
|
|
||||||
extend(&src,&buf,ss); /* get extended format */
|
extend(&src,&buf,ss); /* get extended format */
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("CFU() entry:",&buf);
|
|
||||||
#endif PRT_EXT
|
|
||||||
buf.exp--; /* additional bias correction */
|
buf.exp--; /* additional bias correction */
|
||||||
if (buf.exp < 1) { /* no conversion needed */
|
if (buf.exp < 1) { /* no conversion needed */
|
||||||
src.__double[ss == 8] = 0L;
|
src.__double[ss == 8] = 0L;
|
||||||
|
@ -37,9 +34,6 @@ _double src; /* assume worst case */
|
||||||
}
|
}
|
||||||
max_exp = (ds << 3);
|
max_exp = (ds << 3);
|
||||||
if (buf.exp > max_exp) {
|
if (buf.exp > max_exp) {
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("CFU() INT OVERFLOW",&buf);
|
|
||||||
#endif PRT_EXT
|
|
||||||
trap(EIOVFL); /* integer overflow */
|
trap(EIOVFL); /* integer overflow */
|
||||||
buf.exp %= max_exp;
|
buf.exp %= max_exp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT INTEGER TO FLOAT
|
CONVERT INTEGER TO FLOAT (CIF n 4)
|
||||||
|
|
||||||
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
||||||
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
||||||
|
@ -38,9 +38,6 @@ long src; /* largest possible integer to convert */
|
||||||
buf.exp = 17;
|
buf.exp = 17;
|
||||||
result = (_float *) &ss;
|
result = (_float *) &ss;
|
||||||
}
|
}
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CIF4(ds(%d),ss(%d),src(%D))\n\n",4,ss,i_src);
|
|
||||||
#endif
|
|
||||||
if (i_src == 0) {
|
if (i_src == 0) {
|
||||||
*result = (_float) 0L;
|
*result = (_float) 0L;
|
||||||
return(0L);
|
return(0L);
|
||||||
|
@ -55,9 +52,6 @@ long src; /* largest possible integer to convert */
|
||||||
if (ss != sizeof(long))
|
if (ss != sizeof(long))
|
||||||
buf.m1 <<= 16;
|
buf.m1 <<= 16;
|
||||||
nrm_ext(&buf); /* adjust mantissa field */
|
nrm_ext(&buf); /* adjust mantissa field */
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CIF() buf.exp after nrm_ext() == %d\n\n",buf.exp);
|
|
||||||
#endif
|
|
||||||
compact(&buf,(_double *) result,4); /* put on stack */
|
compact(&buf,(_double *) result,4); /* put on stack */
|
||||||
return(*result);
|
return(*result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT INTEGER TO FLOAT
|
CONVERT INTEGER TO FLOAT (CIF n 8)
|
||||||
|
|
||||||
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
||||||
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
||||||
|
@ -37,9 +37,6 @@ long src; /* largest possible integer to convert */
|
||||||
i_src = (long) *ipt;
|
i_src = (long) *ipt;
|
||||||
buf.exp = 17;
|
buf.exp = 17;
|
||||||
}
|
}
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CIF8(ds(%d),ss(%d),src(%D))\n\n",8,ss,i_src);
|
|
||||||
#endif
|
|
||||||
if (i_src == 0) {
|
if (i_src == 0) {
|
||||||
zrf8(result);
|
zrf8(result);
|
||||||
return(*result);
|
return(*result);
|
||||||
|
@ -54,9 +51,6 @@ long src; /* largest possible integer to convert */
|
||||||
if (ss != sizeof(long))
|
if (ss != sizeof(long))
|
||||||
buf.m1 <<= 16;
|
buf.m1 <<= 16;
|
||||||
nrm_ext(&buf);
|
nrm_ext(&buf);
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CIF() buf.exp after nrm_ext() == %d\n\n",buf.exp);
|
|
||||||
#endif
|
|
||||||
compact(&buf,result,8);
|
compact(&buf,result,8);
|
||||||
return(*result);
|
return(*result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,12 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
COMPARE DOUBLES
|
COMPARE SINGLES (CMF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
#include "get_put.h"
|
#include "get_put.h"
|
||||||
|
|
||||||
short
|
|
||||||
cmf4(f1,f2)
|
cmf4(f1,f2)
|
||||||
_float f1,f2;
|
_float f1,f2;
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,12 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
COMPARE DOUBLES
|
COMPARE DOUBLES (CMF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
#include "get_put.h"
|
#include "get_put.h"
|
||||||
|
|
||||||
short
|
|
||||||
cmf8(d1,d2)
|
cmf8(d1,d2)
|
||||||
_double d1,d2;
|
_double d1,d2;
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PRT_EXIT
|
|
||||||
#define PRT_TRAP
|
|
||||||
#define PRT_ENTRY
|
|
||||||
COMPACT EXTEND FORMAT INTO FLOAT OF PROPER SIZE
|
COMPACT EXTEND FORMAT INTO FLOAT OF PROPER SIZE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -28,35 +25,23 @@ int size;
|
||||||
SINGLE *SGL;
|
SINGLE *SGL;
|
||||||
int exact;
|
int exact;
|
||||||
|
|
||||||
#ifdef PRT_ENTRY
|
if (size == sizeof(_double)) {
|
||||||
prt_ext("enter compact:",f);
|
/*
|
||||||
#endif PRT_ENTRY
|
* COMPACT EXTENDED INTO DOUBLE
|
||||||
if (size == sizeof(_double))
|
*/
|
||||||
/********************************************************/
|
|
||||||
/*
|
|
||||||
COMPACT EXTENDED INTO DOUBLE
|
|
||||||
*/
|
|
||||||
/********************************************************/
|
|
||||||
{
|
|
||||||
if ((f->m1|(f->m2 & DBL_ZERO)) == 0L) {
|
if ((f->m1|(f->m2 & DBL_ZERO)) == 0L) {
|
||||||
zrf8(to);
|
zrf8(to);
|
||||||
goto leave;
|
return;
|
||||||
}
|
}
|
||||||
f->exp += DBL_BIAS; /* restore proper bias */
|
f->exp += DBL_BIAS; /* restore proper bias */
|
||||||
if (f->exp > DBL_MAX) {
|
if (f->exp > DBL_MAX) {
|
||||||
dbl_over: trap(EFOVFL);
|
dbl_over: trap(EFOVFL);
|
||||||
#ifdef PRT_TRAP
|
|
||||||
prt_ext("FCOMPACT DBL OVERFLOW",f);
|
|
||||||
#endif PRT_TRAP
|
|
||||||
f->exp = DBL_MAX;
|
f->exp = DBL_MAX;
|
||||||
f->m1 = f->m2 = 0L;
|
f->m1 = f->m2 = 0L;
|
||||||
if (error++)
|
if (error++)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (f->exp < DBL_MIN) {
|
else if (f->exp < DBL_MIN) {
|
||||||
#ifdef PRT_TRAP
|
|
||||||
prt_ext("FCOMPACT DBL UNDERFLOW",f);
|
|
||||||
#endif PRT_TRAP
|
|
||||||
trap(EFUNFL);
|
trap(EFUNFL);
|
||||||
f->exp = DBL_MIN;
|
f->exp = DBL_MIN;
|
||||||
f->m1 = f->m2 = 0L;
|
f->m1 = f->m2 = 0L;
|
||||||
|
@ -87,14 +72,8 @@ dbl_over: trap(EFOVFL);
|
||||||
if (f->m2 & DBL_ROUNDUP) {
|
if (f->m2 & DBL_ROUNDUP) {
|
||||||
DBL->_s.p2++; /* rounding up */
|
DBL->_s.p2++; /* rounding up */
|
||||||
if (DBL->_s.p2 == 0L) { /* carry out */
|
if (DBL->_s.p2 == 0L) { /* carry out */
|
||||||
#ifdef PRT_RNDMSG
|
|
||||||
write(2,"rounding up lsb\n",16);
|
|
||||||
#endif PRT_RNDMSG
|
|
||||||
DBL->_s.p1.fract++;
|
DBL->_s.p1.fract++;
|
||||||
if (DBL->_s.p1.fract & DBL_CARRYOUT) { /* carry out */
|
if (DBL->_s.p1.fract & DBL_CARRYOUT) { /* carry out */
|
||||||
#ifdef PRT_RNDMSG
|
|
||||||
write(2,"shift due to rounding\n",22);
|
|
||||||
#endif PRT_RNDMSG
|
|
||||||
if (DBL->_s.p1.fract & 01)
|
if (DBL->_s.p1.fract & 01)
|
||||||
DBL->_s.p2 = CARRYBIT;
|
DBL->_s.p2 = CARRYBIT;
|
||||||
DBL->_s.p1.fract >>= 1;
|
DBL->_s.p1.fract >>= 1;
|
||||||
|
@ -107,43 +86,36 @@ dbl_over: trap(EFOVFL);
|
||||||
if (f->exp > DBL_MAX)
|
if (f->exp > DBL_MAX)
|
||||||
goto dbl_over;
|
goto dbl_over;
|
||||||
|
|
||||||
/* STORE EXPONENT: */
|
/*
|
||||||
|
* STORE EXPONENT:
|
||||||
|
*
|
||||||
|
* 1) clear leading bits (B4-B15)
|
||||||
|
* 2) shift and store exponent
|
||||||
|
*/
|
||||||
|
|
||||||
/* 1) clear leading bits (B4-B15) */
|
|
||||||
DBL->_s.p1.fract &= DBL_MASK;
|
DBL->_s.p1.fract &= DBL_MASK;
|
||||||
|
|
||||||
/* 2) shift and store exponent */
|
|
||||||
f->exp <<= DBL_EXPSHIFT;
|
f->exp <<= DBL_EXPSHIFT;
|
||||||
DBL->_s.p1.fract |= ((long) f->exp << EXP_STORE);
|
DBL->_s.p1.fract |= ((long) f->exp << EXP_STORE);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
/********************************************************/
|
/*
|
||||||
/*
|
* COMPACT EXTENDED INTO FLOAT
|
||||||
COMPACT EXTENDED INTO FLOAT
|
*/
|
||||||
*/
|
|
||||||
/********************************************************/
|
|
||||||
{
|
|
||||||
/* local CAST conversion */
|
/* local CAST conversion */
|
||||||
SGL = (SINGLE *) to;
|
SGL = (SINGLE *) to;
|
||||||
if ((f->m1 & SGL_ZERO) == 0L) {
|
if ((f->m1 & SGL_ZERO) == 0L) {
|
||||||
SGL->fract = 0L;
|
SGL->fract = 0L;
|
||||||
goto leave;
|
return;
|
||||||
}
|
}
|
||||||
f->exp += SGL_BIAS; /* restore bias */
|
f->exp += SGL_BIAS; /* restore bias */
|
||||||
if (f->exp > SGL_MAX) {
|
if (f->exp > SGL_MAX) {
|
||||||
sgl_over: trap(EFOVFL);
|
sgl_over: trap(EFOVFL);
|
||||||
#ifdef PRT_TRAP
|
|
||||||
prt_ext("FCOMPACT FLOAT OVERFLOW",f);
|
|
||||||
#endif PRT_TRAP
|
|
||||||
f->exp = SGL_MAX;
|
f->exp = SGL_MAX;
|
||||||
f->m1 = f->m2 = 0L;
|
f->m1 = f->m2 = 0L;
|
||||||
if (error++)
|
if (error++)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (f->exp < SGL_MIN) {
|
else if (f->exp < SGL_MIN) {
|
||||||
#ifdef PRT_TRAP
|
|
||||||
prt_ext("FCOMPACT FLOAT UNDERFLOW",f);
|
|
||||||
#endif PRT_TRAP
|
|
||||||
trap(EFUNFL);
|
trap(EFUNFL);
|
||||||
f->exp = SGL_MIN;
|
f->exp = SGL_MIN;
|
||||||
f->m1 = f->m2 = 0L;
|
f->m1 = f->m2 = 0L;
|
||||||
|
@ -167,9 +139,6 @@ sgl_over: trap(EFOVFL);
|
||||||
/* INEXACT(); */
|
/* INEXACT(); */
|
||||||
if (f->m1 & SGL_ROUNDUP) {
|
if (f->m1 & SGL_ROUNDUP) {
|
||||||
SGL->fract++;
|
SGL->fract++;
|
||||||
#ifdef PRT_RNDMSG
|
|
||||||
write(2,"rounding up lsb\n",16);
|
|
||||||
#endif PRT_RNDMSG
|
|
||||||
/* check normal */
|
/* check normal */
|
||||||
if (SGL->fract & SGL_CARRYOUT) {
|
if (SGL->fract & SGL_CARRYOUT) {
|
||||||
SGL->fract >>= 1;
|
SGL->fract >>= 1;
|
||||||
|
@ -180,41 +149,34 @@ sgl_over: trap(EFOVFL);
|
||||||
if (f->exp > SGL_MAX)
|
if (f->exp > SGL_MAX)
|
||||||
goto sgl_over;
|
goto sgl_over;
|
||||||
|
|
||||||
/* STORE EXPONENT */
|
/*
|
||||||
/* 1) clear leading bit of fraction */
|
* STORE EXPONENT:
|
||||||
SGL->fract &= SGL_MASK; /* B23-B31 are 0 */
|
*
|
||||||
|
* 1) clear leading bit of fraction
|
||||||
|
* 2) shift and store exponent
|
||||||
|
*/
|
||||||
|
|
||||||
/* 2) shift and store exponent */
|
SGL->fract &= SGL_MASK; /* B23-B31 are 0 */
|
||||||
f->exp <<= SGL_EXPSHIFT;
|
f->exp <<= SGL_EXPSHIFT;
|
||||||
SGL->fract |= ((long) f->exp << EXP_STORE);
|
SGL->fract |= ((long) f->exp << EXP_STORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************/
|
/*
|
||||||
/*
|
* STORE SIGN BIT
|
||||||
STORE SIGN BIT
|
*/
|
||||||
*/
|
|
||||||
/********************************************************/
|
|
||||||
if (f->sign) {
|
if (f->sign) {
|
||||||
SGL = (SINGLE *) to; /* make sure */
|
SGL = (SINGLE *) to; /* make sure */
|
||||||
SGL->fract |= CARRYBIT;
|
SGL->fract |= CARRYBIT;
|
||||||
}
|
}
|
||||||
/********************************************************/
|
|
||||||
/*
|
/*
|
||||||
STORE MANTISSA
|
* STORE MANTISSA
|
||||||
/*
|
*/
|
||||||
/********************************************************/
|
|
||||||
|
|
||||||
if (size == sizeof(_double)) {
|
if (size == sizeof(_double)) {
|
||||||
put4(DBL->_s.p1.fract, (char *) &DBL->_s.p1.fract);
|
put4(DBL->_s.p1.fract, (char *) &DBL->_s.p1.fract);
|
||||||
put4(DBL->_s.p2, (char *) &DBL->_s.p2);
|
put4(DBL->_s.p2, (char *) &DBL->_s.p2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
put4(SGL->fract, (char *) &SGL->fract);
|
put4(SGL->fract, (char *) &SGL->fract);
|
||||||
|
|
||||||
leave:
|
|
||||||
#ifdef PRT_EXIT
|
|
||||||
prt_ext("exit compact:",f);
|
|
||||||
prt_dbl((DOUBLE *) to,size); getchar();
|
|
||||||
#endif PRT_EXIT
|
|
||||||
; /* end of print statement or null statement */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT INTEGER TO FLOAT
|
CONVERT INTEGER TO FLOAT (CUF n 4)
|
||||||
|
|
||||||
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
||||||
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
||||||
|
@ -38,9 +38,6 @@ long src; /* largest possible integer to convert */
|
||||||
buf.exp = 17;
|
buf.exp = 17;
|
||||||
result = (_float *) &ss;
|
result = (_float *) &ss;
|
||||||
}
|
}
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CUF4(ds(%d),ss(%d),src(%D))\n\n",4,ss,i_src);
|
|
||||||
#endif
|
|
||||||
if (i_src == 0) {
|
if (i_src == 0) {
|
||||||
*result = (_float) 0L;
|
*result = (_float) 0L;
|
||||||
return (_float) 0L;
|
return (_float) 0L;
|
||||||
|
@ -56,9 +53,6 @@ long src; /* largest possible integer to convert */
|
||||||
|
|
||||||
/* adjust mantissa field */
|
/* adjust mantissa field */
|
||||||
nrm_ext(&buf);
|
nrm_ext(&buf);
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CUF() buf.exp after nrm_ext() == %d\n\n",buf.exp);
|
|
||||||
#endif
|
|
||||||
compact(&buf,(_double *) result,4);
|
compact(&buf,(_double *) result,4);
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONVERT INTEGER TO FLOAT
|
CONVERT INTEGER TO FLOAT (CUF n 8)
|
||||||
|
|
||||||
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
THIS ROUTINE WORKS BY FILLING AN EXTENDED
|
||||||
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
WITH THE INTEGER VALUE IN EXTENDED FORMAT
|
||||||
|
@ -34,9 +34,6 @@ long src; /* largest possible integer to convert */
|
||||||
i_src = (long) *ipt;
|
i_src = (long) *ipt;
|
||||||
buf.exp = 17;
|
buf.exp = 17;
|
||||||
}
|
}
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CUF8(ds(%d),ss(%d),src(%D))\n\n",8,ss,i_src);
|
|
||||||
#endif
|
|
||||||
if (i_src == 0) {
|
if (i_src == 0) {
|
||||||
zrf8(&ss);
|
zrf8(&ss);
|
||||||
return;
|
return;
|
||||||
|
@ -52,8 +49,5 @@ long src; /* largest possible integer to convert */
|
||||||
|
|
||||||
/* adjust mantissa field */
|
/* adjust mantissa field */
|
||||||
nrm_ext(&buf);
|
nrm_ext(&buf);
|
||||||
#ifdef PRT_STDERR
|
|
||||||
fprintf(stderr,"CUF() buf.exp after nrm_ext() == %d\n\n",buf.exp);
|
|
||||||
#endif
|
|
||||||
compact(&buf,(_double *) &ss,8);
|
compact(&buf,(_double *) &ss,8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PRT_EXT
|
|
||||||
#define PRT_ALL
|
|
||||||
DIVIDE EXTENDED FORMAT
|
DIVIDE EXTENDED FORMAT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -21,10 +19,7 @@
|
||||||
This is a routine to do the work.
|
This is a routine to do the work.
|
||||||
It is based on the partial products method
|
It is based on the partial products method
|
||||||
and makes no use possible machine instructions
|
and makes no use possible machine instructions
|
||||||
to divide (hardware dividers). It is intended
|
to divide (hardware dividers).
|
||||||
that it be rewritten to do so, but expedieancy
|
|
||||||
requires that something be written NOW - and
|
|
||||||
this is it.
|
|
||||||
*/
|
*/
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
|
@ -36,11 +31,6 @@ EXTEND *e1,*e2;
|
||||||
unsigned long result[2];
|
unsigned long result[2];
|
||||||
register unsigned long *lp;
|
register unsigned long *lp;
|
||||||
|
|
||||||
#ifdef PRT_EXT
|
|
||||||
fprintf("stderr:start div_ext:\n");
|
|
||||||
prt_ext("dividend:",e1);
|
|
||||||
prt_ext("divisor :",e2);
|
|
||||||
#endif
|
|
||||||
if ((e1->m1 | e1->m2) == 0) { /* 0 / anything == 0 */
|
if ((e1->m1 | e1->m2) == 0) { /* 0 / anything == 0 */
|
||||||
e1->exp = 0; /* make sure */
|
e1->exp = 0; /* make sure */
|
||||||
return;
|
return;
|
||||||
|
@ -59,25 +49,32 @@ EXTEND *e1,*e2;
|
||||||
e1->exp -= e2->exp;
|
e1->exp -= e2->exp;
|
||||||
e1->exp += 2; /* bias correction */
|
e1->exp += 2; /* bias correction */
|
||||||
if (e1->exp < EXT_MIN) {
|
if (e1->exp < EXT_MIN) {
|
||||||
error++;
|
/*
|
||||||
#ifdef PRT_EXT
|
* Exception 8.4 - Underflow
|
||||||
prt_ext("DIV_EXT UNDERFLOW",e1);
|
*/
|
||||||
#endif PRT_EXT
|
|
||||||
trap(EFUNFL); /* underflow */
|
trap(EFUNFL); /* underflow */
|
||||||
e1->exp = EXT_MIN;
|
e1->exp = EXT_MIN;
|
||||||
e1->m1 = e1->m2 = 0L;
|
e1->m1 = e1->m2 = 0L;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ((e2->m1 | e2->m2) == 0) {
|
if ((e2->m1 | e2->m2) == 0) {
|
||||||
error++;
|
/*
|
||||||
#ifdef PRT_EXT
|
* Exception 8.2 - Divide by zero
|
||||||
prt_ext("DIV_EXT DIV 0.0",e2);
|
*/
|
||||||
#endif PRT_EXT
|
|
||||||
trap(EFDIVZ);
|
trap(EFDIVZ);
|
||||||
e1->m1 = e1->m2 = 0L;
|
e1->m1 = e1->m2 = 0L;
|
||||||
e1->exp = EXT_MAX;
|
e1->exp = EXT_MAX;
|
||||||
}
|
|
||||||
if (error)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (e1->exp >= EXT_MAX) {
|
||||||
|
/*
|
||||||
|
* Exception 8.3 - Overflow
|
||||||
|
*/
|
||||||
|
trap(EFOVFL); /* overflow */
|
||||||
|
e1->exp = EXT_MAX;
|
||||||
|
e1->m1 = e1->m2 = 0L;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* do division of mantissas */
|
/* do division of mantissas */
|
||||||
/* uses partial product method */
|
/* uses partial product method */
|
||||||
|
@ -100,10 +97,6 @@ EXTEND *e1,*e2;
|
||||||
/* compare dividend and divisor */
|
/* compare dividend and divisor */
|
||||||
/* if dividend >= divisor add a bit */
|
/* if dividend >= divisor add a bit */
|
||||||
/* and subtract divisior from dividend */
|
/* and subtract divisior from dividend */
|
||||||
#ifdef PRT_ALL
|
|
||||||
prt_ext("dividend:",e1);
|
|
||||||
prt_ext("divisor :",e2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( (e1->m1 < e2->m1) ||
|
if ( (e1->m1 < e2->m1) ||
|
||||||
((e1->m1 == e2->m1) && (e1->m2 < e2->m2) ))
|
((e1->m1 == e2->m1) && (e1->m2 < e2->m2) ))
|
||||||
|
@ -115,15 +108,7 @@ EXTEND *e1,*e2;
|
||||||
e1->m1 -= 1; /* carry in */
|
e1->m1 -= 1; /* carry in */
|
||||||
e1->m1 -= e2->m1; /* do SUBTRACTION */
|
e1->m1 -= e2->m1; /* do SUBTRACTION */
|
||||||
e1->m2 -= e2->m2; /* SUBTRACTION */
|
e1->m2 -= e2->m2; /* SUBTRACTION */
|
||||||
#ifdef PRT_ALL
|
|
||||||
prt_ext("result :",e1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef PRT_ALL
|
|
||||||
fprintf(stderr,"div_ext %d %08X%08X\n\n",64-count,
|
|
||||||
result[0],result[1]);
|
|
||||||
fflush(stderr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* shift dividend left one bit OR */
|
/* shift dividend left one bit OR */
|
||||||
/* IF it equals ZERO we can break out */
|
/* IF it equals ZERO we can break out */
|
||||||
|
@ -146,14 +131,6 @@ EXTEND *e1,*e2;
|
||||||
break; /* leave loop */
|
break; /* leave loop */
|
||||||
} /* end of divide by subtraction loop */
|
} /* end of divide by subtraction loop */
|
||||||
|
|
||||||
/* DISPLAY RESULTS FOR DEBUGGING */
|
|
||||||
#ifdef PRT_ALL
|
|
||||||
prt_ext("dividend:",e1);
|
|
||||||
prt_ext("divisor :",e2);
|
|
||||||
fprintf(stderr,"div_ext %d %08X%08X\n",64-count,
|
|
||||||
result[0],result[1]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
lp = result;
|
lp = result;
|
||||||
if (count > 31) { /* move to higher word */
|
if (count > 31) { /* move to higher word */
|
||||||
|
@ -169,18 +146,20 @@ EXTEND *e1,*e2;
|
||||||
*lp <<= count;
|
*lp <<= count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
#ifdef EXCEPTION_INEXACT
|
||||||
if (error)
|
if (error) {
|
||||||
INEXACT();
|
/*
|
||||||
*/
|
* report here exception 8.5 - Inexact
|
||||||
|
* from Draft 8.0 of IEEE P754:
|
||||||
|
* In the absence of an invalid operation exception,
|
||||||
|
* if the rounded result of an operation is not exact or if
|
||||||
|
* it overflows without a trap, then the inexact exception
|
||||||
|
* shall be assigned. The rounded or overflowed result
|
||||||
|
* shall be delivered to the destination.
|
||||||
|
*/
|
||||||
|
INEXACT();
|
||||||
|
#endif
|
||||||
e1->m1 = result[0];
|
e1->m1 = result[0];
|
||||||
e1->m2 = result[1];
|
e1->m2 = result[1];
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("result :",e1);
|
|
||||||
#endif
|
|
||||||
nrm_ext(e1);
|
nrm_ext(e1);
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after nrm:",e1);
|
|
||||||
/*sleep(4);*/
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DIVIDE TWO FLOATS - SINGLE Precision
|
DIVIDE TWO FLOATS - SINGLE Precision (dvf 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DIVIDE TWO FLOATS - DOUBLE Precision
|
DIVIDE TWO FLOATS - DOUBLE Precision (DVF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PRT_EXIT
|
|
||||||
#define PRT_ENTRY
|
|
||||||
#define PRT_DBL
|
|
||||||
CONVERTS FLOATING POINT TO EXTENDED FORMAT
|
CONVERTS FLOATING POINT TO EXTENDED FORMAT
|
||||||
|
|
||||||
Two sizes of FLOATING Point are known:
|
Two sizes of FLOATING Point are known:
|
||||||
|
@ -45,19 +42,11 @@ int size;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
int leadbit = 0;
|
int leadbit = 0;
|
||||||
|
|
||||||
#ifdef PRT_ENTRY
|
|
||||||
write(2,"entry extend: ",14);
|
|
||||||
#ifdef PRT_DBL
|
|
||||||
prt_dbl(from,size);
|
|
||||||
#else
|
|
||||||
write(2,"\n",1);
|
|
||||||
#endif PRT_DBL
|
|
||||||
#endif PRT_ENTRY
|
|
||||||
f = (DOUBLE *) from; /* local cast conversion */
|
f = (DOUBLE *) from; /* local cast conversion */
|
||||||
if (f->_s.p1.fract == 0L) {
|
if (f->_s.p1.fract == 0L) {
|
||||||
if (size == sizeof(SINGLE)) {
|
if (size == sizeof(SINGLE)) {
|
||||||
zero: zrf_ext(to);
|
zero: zrf_ext(to);
|
||||||
goto ready;
|
return;
|
||||||
}
|
}
|
||||||
else if (f->_s.p2 == 0L)
|
else if (f->_s.p2 == 0L)
|
||||||
goto zero;
|
goto zero;
|
||||||
|
@ -95,9 +84,4 @@ zero: zrf_ext(to);
|
||||||
to->m1 |= NORMBIT; /* set bit L */
|
to->m1 |= NORMBIT; /* set bit L */
|
||||||
if (leadbit == 0) /* set or clear Leading Bit */
|
if (leadbit == 0) /* set or clear Leading Bit */
|
||||||
to->m1 &= ~NORMBIT; /* clear bit L */
|
to->m1 &= ~NORMBIT; /* clear bit L */
|
||||||
ready:
|
|
||||||
#ifdef PRT_EXIT
|
|
||||||
prt_ext("exit extend:",to)
|
|
||||||
#endif PRT_EXIT
|
|
||||||
; /* end of print statement or null statement */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SEPERATE INTO EXPONENT AND FRACTION
|
SEPERATE INTO EXPONENT AND FRACTION (FEF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SEPERATE DOUBLE INTO EXPONENT AND FRACTION
|
SEPERATE DOUBLE INTO EXPONENT AND FRACTION (FEF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
@ -22,16 +22,8 @@ _double s1;
|
||||||
EXTEND buf;
|
EXTEND buf;
|
||||||
struct fef8_returns *r = (struct fef8_returns *) &s1;
|
struct fef8_returns *r = (struct fef8_returns *) &s1;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
printf("FEF8(): ");
|
|
||||||
#endif DEBUG
|
|
||||||
extend(&s1,&buf,sizeof(_double));
|
extend(&s1,&buf,sizeof(_double));
|
||||||
r->e = buf.exp - 1;
|
r->e = buf.exp - 1;
|
||||||
buf.exp = 1;
|
buf.exp = 1;
|
||||||
compact(&buf,&r->f,sizeof(_double));
|
compact(&buf,&r->f,sizeof(_double));
|
||||||
#ifdef DEBUG
|
|
||||||
printf("exponent = %3d fraction = 0x%08X%08X: ",
|
|
||||||
r->f.__double[0],r->f.__double[1]);
|
|
||||||
printf("FEF8()\n");
|
|
||||||
#endif DEBUG
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MULTIPLY AND DISMEMBER PARTS
|
MULTIPLY AND DISMEMBER PARTS (FIF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MULTIPLY AND DISMEMBER PARTS
|
MULTIPLY AND DISMEMBER PARTS (FIF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Multiply Single Precesion Float
|
* Multiply Single Precesion Float (MLF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Multiply Single Precesion Float
|
* Multiply Single Precision Float (MLF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -17,17 +17,13 @@
|
||||||
mul_ext(e1,e2)
|
mul_ext(e1,e2)
|
||||||
EXTEND *e1,*e2;
|
EXTEND *e1,*e2;
|
||||||
{
|
{
|
||||||
register short k,i,j; /* loop control */
|
register int k,i,j; /* loop control */
|
||||||
long unsigned *reg[7];
|
long unsigned *reg[7];
|
||||||
long unsigned tmp[4];
|
long unsigned tmp[4];
|
||||||
short unsigned mp[4]; /* multiplier */
|
short unsigned mp[4]; /* multiplier */
|
||||||
short unsigned mc[4]; /* multipcand */
|
short unsigned mc[4]; /* multipcand */
|
||||||
B64 low64,tmp64; /* 64 bit storage */
|
B64 low64,tmp64; /* 64 bit storage */
|
||||||
|
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("before MUL_EXT() e1:",e1);
|
|
||||||
prt_ext("before MUL_EXT() e2:",e2);
|
|
||||||
#endif
|
|
||||||
/* first save the sign (XOR) */
|
/* first save the sign (XOR) */
|
||||||
|
|
||||||
e1->sign ^= e2->sign;
|
e1->sign ^= e2->sign;
|
||||||
|
@ -66,24 +62,15 @@ EXTEND *e1,*e2;
|
||||||
|
|
||||||
/* check for overflow */
|
/* check for overflow */
|
||||||
if (e1->exp >= EXT_MAX) {
|
if (e1->exp >= EXT_MAX) {
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("EXT_MUL OVERFLOW",e1);
|
|
||||||
#endif
|
|
||||||
trap(EFOVFL);
|
trap(EFOVFL);
|
||||||
/* if caught */
|
/* if caught */
|
||||||
/* return signed infinity */
|
/* return signed infinity */
|
||||||
e1->exp = EXT_MAX;
|
e1->exp = EXT_MAX;
|
||||||
infinity: e1->m1 = e1->m2 =0L;
|
infinity: e1->m1 = e1->m2 =0L;
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after MUL_EXT() e1:",e1);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* check for underflow */
|
/* check for underflow */
|
||||||
if (e1->exp < EXT_MIN) {
|
if (e1->exp < EXT_MIN) {
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("EXT_MUL UNDERFLOW",e1);
|
|
||||||
#endif
|
|
||||||
trap(EFUNFL);
|
trap(EFUNFL);
|
||||||
e1->exp = EXT_MIN;
|
e1->exp = EXT_MIN;
|
||||||
goto infinity;
|
goto infinity;
|
||||||
|
@ -101,16 +88,6 @@ infinity: e1->m1 = e1->m2 =0L;
|
||||||
mc[1] = (unsigned short) e2->m1;
|
mc[1] = (unsigned short) e2->m1;
|
||||||
mc[2] = e2->m2 >> 16;
|
mc[2] = e2->m2 >> 16;
|
||||||
mc[3] = (unsigned short) e2->m2;
|
mc[3] = (unsigned short) e2->m2;
|
||||||
# ifdef DEBUG
|
|
||||||
for(i=0;i<4;i++)
|
|
||||||
printf("%04x",mp[i]);
|
|
||||||
putchar('\r');
|
|
||||||
putchar('\n');
|
|
||||||
for(i=0;i<4;i++)
|
|
||||||
printf("%04x",mc[i]);
|
|
||||||
putchar('\r');
|
|
||||||
putchar('\n');
|
|
||||||
# endif
|
|
||||||
/*
|
/*
|
||||||
* assign pointers
|
* assign pointers
|
||||||
*/
|
*/
|
||||||
|
@ -135,72 +112,24 @@ infinity: e1->m1 = e1->m2 =0L;
|
||||||
for(j=4;j--;) if (mc[j]) {
|
for(j=4;j--;) if (mc[j]) {
|
||||||
k = i+j;
|
k = i+j;
|
||||||
tmp[0] = (long)mp[i] * (long)mc[j];
|
tmp[0] = (long)mp[i] * (long)mc[j];
|
||||||
# ifdef PRT_EXT2
|
|
||||||
printf("%04x * %04x == %08X ",mp[i],mc[j],tmp[0]);
|
|
||||||
printf("index == %d ",k);
|
|
||||||
printf("register before add == %08X\n",*reg[k]);
|
|
||||||
fflush(stdout);
|
|
||||||
# endif
|
|
||||||
#ifdef PRT_ADD
|
|
||||||
printf("REGISTERS-----\n");
|
|
||||||
printf("%08X %08X %08X %08X\n0000%04x %04x%04x %04x%04x %04x0000\n",
|
|
||||||
*reg[0],*reg[2],*reg[4],*reg[6],
|
|
||||||
(short)(*reg[1]>>16),(short)(*reg[1]),(short)(*reg[3]>>16),
|
|
||||||
(short)(*reg[3]),(short)(*reg[5]>>16),(short)(*reg[5]));
|
|
||||||
# endif
|
|
||||||
if (b32_add(reg[k],tmp)) {
|
if (b32_add(reg[k],tmp)) {
|
||||||
for(tmp[0] = 0x10000L;k>0;)
|
for(tmp[0] = 0x10000L;k>0;)
|
||||||
if (b32_add(reg[--k],tmp) == 0)
|
if (b32_add(reg[--k],tmp) == 0)
|
||||||
break;
|
break;
|
||||||
#ifdef PRT_ADD
|
|
||||||
printf("CARRY---------\n");
|
|
||||||
printf("%08X %08X %08X %08X\n0000%04x %04x%04x %04x%04x %04x0000\n",
|
|
||||||
*reg[0],*reg[2],*reg[4],*reg[6],
|
|
||||||
(short)(*reg[1]>>16),(short)(*reg[1]),(short)(*reg[3]>>16),
|
|
||||||
(short)(*reg[3]),(short)(*reg[5]>>16),(short)(*reg[5]));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* combine the registers to a total
|
* combine the registers to a total
|
||||||
*/
|
*/
|
||||||
#ifdef PRT_ADD
|
|
||||||
printf("%08X %08X %08X %08X\n0000%04x %04x%04x %04x%04x %04x0000\n",
|
|
||||||
*reg[0],*reg[2],*reg[4],*reg[6],
|
|
||||||
(short)(*reg[1]>>16),(short)(*reg[1]),(short)(*reg[3]>>16),
|
|
||||||
(short)(*reg[3]),(short)(*reg[5]>>16),(short)(*reg[5]));
|
|
||||||
# endif
|
|
||||||
tmp64.h_32 = (*reg[1]>>16);
|
tmp64.h_32 = (*reg[1]>>16);
|
||||||
tmp64.l_32 = (*reg[1]<<16) + (*reg[3]>>16);
|
tmp64.l_32 = (*reg[1]<<16) + (*reg[3]>>16);
|
||||||
# ifdef PRT_ALL
|
|
||||||
printf("%08X%08X tmp64\n",tmp64.h_32,tmp64.l_32);
|
|
||||||
fflush(stdout);
|
|
||||||
printf("%08X%08X e1->m1\n",e1->m1,e1->m2);
|
|
||||||
fflush(stdout);
|
|
||||||
# endif
|
|
||||||
b64_add((B64 *)&e1->m1,&tmp64);
|
b64_add((B64 *)&e1->m1,&tmp64);
|
||||||
# ifdef PRT_ALL
|
|
||||||
printf("b64_add:\n");
|
|
||||||
printf("%08X%08X e1->m1\n",e1->m1,e1->m2);
|
|
||||||
fflush(stdout);
|
|
||||||
# endif
|
|
||||||
tmp64.l_32 = *reg[5]<<16;
|
tmp64.l_32 = *reg[5]<<16;
|
||||||
tmp64.h_32 = (*reg[5]>>16) + (*reg[3]<<16);
|
tmp64.h_32 = (*reg[5]>>16) + (*reg[3]<<16);
|
||||||
if (b64_add(&low64,&tmp64))
|
if (b64_add(&low64,&tmp64))
|
||||||
if (++e1->m2 == 0)
|
if (++e1->m2 == 0)
|
||||||
e1->m1++;
|
e1->m1++;
|
||||||
|
|
||||||
# ifdef PRT_ADD
|
|
||||||
printf("%08X %08X %08X %08X\n",e1->m1,e1->m2,low64.h_32,low64.l_32);
|
|
||||||
fflush(stdout);
|
|
||||||
#endif
|
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after MUL_EXT() e1:",e1);
|
|
||||||
#endif PRT_EXT
|
|
||||||
nrm_ext(e1);
|
nrm_ext(e1);
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after NRM_EXT() e1:",e1);
|
|
||||||
sleep(4);
|
|
||||||
#endif PRT_EXT
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NEGATE A FLOATING POINT
|
NEGATE A FLOATING POINT (NGF 4)
|
||||||
*/
|
*/
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/*
|
/*
|
||||||
|
@ -26,4 +26,3 @@ _float f;
|
||||||
*p ^= 0x80;
|
*p ^= 0x80;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NEGATE A FLOATING POINT
|
NEGATE A FLOATING POINT (NGF 8)
|
||||||
*/
|
*/
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,17 +21,8 @@ EXTEND *e1;
|
||||||
register unsigned long *mant_2;
|
register unsigned long *mant_2;
|
||||||
|
|
||||||
/* local CAST conversion */
|
/* local CAST conversion */
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("before NRM_EXT() e1:",e1);
|
|
||||||
#endif PRT_EXT
|
|
||||||
mant_1 = (unsigned long *) &e1->m1;
|
mant_1 = (unsigned long *) &e1->m1;
|
||||||
/*
|
|
||||||
THIS RESULTS IN A BAD CODE !!!!
|
|
||||||
ANOTHER BUG IN EM CODE MAYBE????
|
|
||||||
mant_2 = (unsigned long *) &e1->m2;
|
mant_2 = (unsigned long *) &e1->m2;
|
||||||
*/
|
|
||||||
/* statement that works */
|
|
||||||
mant_2 = mant_1 + 1;
|
|
||||||
|
|
||||||
/* we assume that the mantissa != 0 */
|
/* we assume that the mantissa != 0 */
|
||||||
/* if it is then just return */
|
/* if it is then just return */
|
||||||
|
@ -51,18 +42,6 @@ EXTEND *e1;
|
||||||
*mant_1-- = 0L;
|
*mant_1-- = 0L;
|
||||||
e1->exp -= 32;
|
e1->exp -= 32;
|
||||||
}
|
}
|
||||||
#ifdef OLD
|
|
||||||
/* check that e1->m1 is not too large */
|
|
||||||
if (*mant_1 & CARRYBIT) { /* carry occured */
|
|
||||||
e1->exp++; /* increase exponent */
|
|
||||||
*mant_2 >>= 1; /* right shift mantissa */
|
|
||||||
if ((short) *mant_1 & 01)
|
|
||||||
*mant_2 |= CARRYBIT;
|
|
||||||
*mant_1 >>= 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
while ((*mant_1 & NORMBIT) == 0) {
|
while ((*mant_1 & NORMBIT) == 0) {
|
||||||
e1->exp--;
|
e1->exp--;
|
||||||
*mant_1 <<= 1;
|
*mant_1 <<= 1;
|
||||||
|
@ -73,7 +52,4 @@ EXTEND *e1;
|
||||||
}
|
}
|
||||||
*mant_2 <<= 1;
|
*mant_2 <<= 1;
|
||||||
}
|
}
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after NRM_EXT() e1:",e1);
|
|
||||||
#endif PRT_EXT
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SUBTRACT TWO FLOATS - SINGLE Precision
|
SUBTRACT TWO FLOATS - SINGLE Precision (SBF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SUBTRACT TWO FLOATS - DOUBLE Precision
|
SUBTRACT TWO FLOATS - DOUBLE Precision (SBF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
@ -22,9 +22,6 @@ _double s1,s2;
|
||||||
/* s2 = -s2; */
|
/* s2 = -s2; */
|
||||||
char unsigned *p; /* sufficient to access sign bit */
|
char unsigned *p; /* sufficient to access sign bit */
|
||||||
|
|
||||||
#ifdef PRT_EXT
|
|
||||||
fprintf(stderr,"SBF8 ():\n");
|
|
||||||
#endif
|
|
||||||
if (s2.__double[0] == 0 && s2.__double[1] == 0) {
|
if (s2.__double[0] == 0 && s2.__double[1] == 0) {
|
||||||
return s1;
|
return s1;
|
||||||
}
|
}
|
||||||
|
@ -33,4 +30,3 @@ _double s1,s2;
|
||||||
s1 = adf8(s2,s1); /* add and return result */
|
s1 = adf8(s2,s1); /* add and return result */
|
||||||
return(s1);
|
return(s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PRT_EXT
|
|
||||||
SHIFT TWO EXTENDED NUMBERS INTO PROPER
|
SHIFT TWO EXTENDED NUMBERS INTO PROPER
|
||||||
ALIGNMENT FOR ADDITION (exponents are equal)
|
ALIGNMENT FOR ADDITION (exponents are equal)
|
||||||
*/
|
*/
|
||||||
|
@ -17,13 +16,9 @@ sft_ext(e1,e2)
|
||||||
EXTEND *e1,*e2;
|
EXTEND *e1,*e2;
|
||||||
{
|
{
|
||||||
register EXTEND *s;
|
register EXTEND *s;
|
||||||
register short diff;
|
register int diff;
|
||||||
long tmp;
|
long tmp;
|
||||||
|
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("enter sft_ext e1:",e1);
|
|
||||||
prt_ext("enter sft_ext e2:",e2);
|
|
||||||
#endif PRT_EXT
|
|
||||||
diff = e1->exp - e2->exp;
|
diff = e1->exp - e2->exp;
|
||||||
|
|
||||||
if (!diff)
|
if (!diff)
|
||||||
|
@ -62,8 +57,4 @@ EXTEND *e1,*e2;
|
||||||
s->m2 >>= diff;
|
s->m2 >>= diff;
|
||||||
s->m2 |= tmp;
|
s->m2 |= tmp;
|
||||||
}
|
}
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("exit sft_ext e1:",e1);
|
|
||||||
prt_ext("exit sft_ext e2:",e2);
|
|
||||||
#endif PRT_EXT
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
b64_sft(e1,n)
|
b64_sft(e1,n)
|
||||||
B64 *e1;
|
B64 *e1;
|
||||||
short n;
|
int n;
|
||||||
{
|
{
|
||||||
if (n>0) do { /* RIGHT shift n bits */
|
if (n>0) do { /* RIGHT shift n bits */
|
||||||
e1->l_32 >>= 1; /* shift 64 bits */
|
e1->l_32 >>= 1; /* shift 64 bits */
|
||||||
|
|
|
@ -6,30 +6,23 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PRT_EXT
|
SUBTRACT 2 EXTENDED FORMAT NUMBERS
|
||||||
SUBTRACT EXTENDED FORMAT
|
|
||||||
*/
|
*/
|
||||||
/* assumes that e1 >= e2 on entry */
|
/*
|
||||||
/* no test is made to check this */
|
* adf (addition routines) use this rather than
|
||||||
/* so make sure yourself */
|
* add_ext when the signs of the numbers are different.
|
||||||
|
* sub_ext requires that e1 >= e2 on entry
|
||||||
|
* otherwise nonsense results. If you use this routine
|
||||||
|
* make certain this requirement is met.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
sub_ext(e1,e2)
|
sub_ext(e1,e2)
|
||||||
EXTEND *e1,*e2;
|
EXTEND *e1,*e2;
|
||||||
{
|
{
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("before SUB_EXT() e1:",e1);
|
|
||||||
prt_ext("before SUB_EXT() e2:",e2);
|
|
||||||
#endif PRT_EXT
|
|
||||||
if (e2->m2 > e1->m2)
|
if (e2->m2 > e1->m2)
|
||||||
e1->m1 -= 1; /* carry in */
|
e1->m1 -= 1; /* carry in */
|
||||||
e1->m1 -= e2->m1;
|
e1->m1 -= e2->m1;
|
||||||
e1->m2 -= e2->m2;
|
e1->m2 -= e2->m2;
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after SUB_EXT() e1:",e1);
|
|
||||||
#endif PRT_EXT
|
|
||||||
nrm_ext(e1);
|
nrm_ext(e1);
|
||||||
#ifdef PRT_EXT
|
|
||||||
prt_ext("after NRM_EXT() e1:",e1);
|
|
||||||
#endif PRT_EXT
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return a zero float
|
return a zero float (ZRF 4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return a zero double
|
return a zero double (ZRF 8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FP_types.h"
|
#include "FP_types.h"
|
||||||
|
|
|
@ -15,13 +15,12 @@ zrf_ext(e)
|
||||||
EXTEND *e;
|
EXTEND *e;
|
||||||
{
|
{
|
||||||
register short *ipt;
|
register short *ipt;
|
||||||
register short i;
|
register int i;
|
||||||
register short zero = 0;
|
|
||||||
|
|
||||||
/* local CAST conversion */
|
/* local CAST conversion */
|
||||||
ipt = (short *) e;
|
ipt = (short *) e;
|
||||||
|
|
||||||
i = sizeof(EXTEND)/sizeof(short);
|
i = sizeof(EXTEND)/sizeof(short);
|
||||||
while (i--)
|
while (i--)
|
||||||
*ipt++ = zero;
|
*ipt++ = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue