use con_float file, and use new interface to fif and fef routines

This commit is contained in:
ceriel 1989-07-31 14:50:19 +00:00
parent 066c005493
commit 6572fa2def
5 changed files with 17 additions and 168 deletions

View file

@ -265,18 +265,20 @@ C_ngf
default ==> arg_error( "ngf", $1).
C_fif
$1 == 4 ==> "jsr (.fif4)".
$1 == 8 ==> "jsr (.fif8)".
$1 == 4 ==> C_lor((arith)1);
"jsr (.fif4)";
"tst.l (sp)+".
$1 == 8 ==> C_lor((arith)1);
"jsr (.fif8)";
"tst.l (sp)+".
default ==> arg_error( "fif", $1).
C_fef
$1 == 4 ==> C_dup( (arith) 4);
$1 == 4 ==> C_lor( (arith) 1);
"sub.l #4, (sp)";
"jsr (.fef4)".
$1 == 8 ==> "move.l (sp)+, d0";
"move.l (sp)+, d1";
"move.l d0, -(sp)";
"move.l d1, -(sp)";
"move.l d0, -(sp)";
$1 == 8 ==> C_lor((arith)1);
"sub.l #4, (sp)";
"jsr (.fef8)".
default ==> arg_error( "fef", $1).

View file

@ -26,145 +26,4 @@ char *filename;
}
*/
con_float(str, argval)
char *str;
int argval;
{
#ifdef NOFLOAT
static int been_here;
if (argval != 4 && argval != 8)
arg_error("fcon", argval);
if (argval == 8)
gen4((FOUR_BYTES) 0);
gen4((FOUR_BYTES) 0);
if ( !been_here++)
{
fprint(STDERR, "Warning : dummy float-constant(s)\n");
}
#else
#define IEEEFLOAT
double f;
double atof();
int i;
int j;
double frexp();
#ifndef OWNFLOAT
int sign = 0;
int fraction[4] ;
#else OWNFLOAT
float fl;
char *p;
#endif OWNFLOAT
if (argval!= 4 && argval!= 8) {
arg_error("fcon", argval);
argval = 8;
}
f = atof(str);
if (f == 0) {
if (argval == 8) gen4((FOUR_BYTES) 0);
gen4((FOUR_BYTES) 0);
return;
}
#ifdef OWNFLOAT
if (argval == 4) {
/* careful: avoid overflow */
double ldexp();
f = frexp(f, &i);
fl = f;
fl = frexp(fl,&j);
if (i+j > 127) {
/* overflow situation */
gen1(f<0?0377:0177);
gen1(0377);
gen1(0377);
gen1(0377);
return;
}
if (i+j < -127) {
/* underflow situation */
gen1(f<0?0200:0);
gen1(0200);
gen1(0);
gen1(0);
return;
}
fl = ldexp(fl, i+j);
p = (char *) &fl;
}
else {
p = (char *) &f;
}
gen1(*p++&0377);
for (i = argval-1; i; i--) {
gen1(*p++&0377);
}
#else OWNFLOAT
f = frexp(f, &i);
if (f < 0) {
f = -f;
sign = 1;
}
while (f < 0.5) {
f += f;
i --;
}
f = 2*f - 1.0; /* hidden bit */
#ifdef IEEEFLOAT
if (argval == 4) {
#endif IEEEFLOAT
i = (i + 128) & 0377;
fraction[0] = (sign << 15) | (i << 7);
for (j = 6; j>= 0; j--) {
f *= 2;
if (f >= 1.0) {
f -= 1.0;
fraction[0] |= (1 << j);
}
}
#ifdef IEEEFLOAT
}
else {
i = (i + 1024) & 03777;
fraction[0] = (sign << 15) | (i << 4);
for (j = 3; j>= 0; j--) {
f *= 2;
if (f >= 1.0) {
fraction[0] |= (1 << j);
f -= 1.0;
}
}
}
#endif IEEEFLOAT
for (i = 1; i < argval / 2; i++) {
fraction[i] = 0;
for (j = 15; j>= 0; j--) {
f *= 2;
if (f >= 1.0) {
fraction[i] |= (1 << j);
f -= 1.0;
}
}
}
if (f >= 0.5) {
for (i = argval/2 - 1; i >= 0; i--) {
for (j = 0; j < 16; j++) {
if (fraction[i] & (1 << j)) {
fraction[i] &= ~(1 << j);
}
else {
fraction[i] |= (1 << j);
break;
}
}
if (j != 16) break;
}
}
for (i = 0; i < argval/2; i++) {
gen1((fraction[i]>>8)&0377);
gen1(fraction[i]&0377);
}
#endif OWNFLOAT
#endif
}
#include <float_cst>

View file

@ -2,6 +2,5 @@ Makefile
mach.c
mach.h
table
fppsim.h
tables1.c
tables1.h

View file

@ -12,8 +12,6 @@ static char rcsid[] = "$Header$";
* machine dependent back end routines for the Motorola 68000
*/
#include "fppsim.h"
con_part(sz,w) register sz; word w; {
while (part_size % sz)
@ -39,7 +37,8 @@ con_mult(sz) word sz; {
fprintf(codefile,".data4 %s\n",str);
}
#define ACKFLOAT 1
#define IEEEFLOAT
#define CODE_GENERATOR
#include <con_float>
#ifdef REGVARS

View file

@ -1023,20 +1023,10 @@ dvf $1==4 | | | | cal ".dvf4" asp 4 |
dvf $1==8 | | | | cal ".dvf8" asp 8 |
ngf $1==4 | | | | cal ".ngf4" |
ngf $1==8 | | | | cal ".ngf8" |
fif $1==4 | | | | cal ".fif4" |
fif $1==8 | | | | cal ".fif8" |
fef $1==4 | |
remove(ALL)
"move.l (sp)+,d0"
"clr.w -(sp)"
"move.l d0,-(sp)" | | cal ".fef4" |
fef $1==8 | |
remove(ALL)
"move.l (sp)+,d0"
"move.l (sp)+,d1"
"clr.w -(sp)"
"move.l d1,-(sp)"
"move.l d0,-(sp)" | | cal ".fef8" |
fif $1==4 | | | | lor 1 cal ".fif4" asp 4 |
fif $1==8 | | | | lor 1 cal ".fif8" asp 4 |
fef $1==4 | | | | lor 1 adp 0-2 cal ".fef4" asp 2 |
fef $1==8 | | | | lor 1 adp 0-2 cal ".fef8" asp 2 |
/* G R O U P VI : P O I N T E R A R I T H M E T I C */