improved floating point handling

This commit is contained in:
ceriel 1988-08-11 14:57:39 +00:00
parent 5aa128ea62
commit a9a2e027c8
3 changed files with 17 additions and 30 deletions

View file

@ -44,14 +44,17 @@ em4_t-c-:tmp.s compile con_float.o
em4_t--p: tmp.s compile con_float.o em4_t--p: tmp.s compile con_float.o
./compile -o em4_t--p -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o ./compile -o em4_t--p -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o
con_float.o: con_float.c compile con_float.o: con_float.c
./compile -c -L -O con_float.c case `ack_sys` in m68k2|pmds) \
acc -mm68k4 -c -L -O con_float.c;; \
*) acc -c -L -O con_float.c;; \
esac
compile: Makefile compile: Makefile
case `ack_sys` in sun*) MACH=sun2;; pmds*) MACH=pmds4;; \ case `ack_sys` in sun*) MACH=`ack_sys`; AS=-Ras=../../../lib/m68k2/as;; pmds*) MACH=pmds4;; \
m68_sysV_0) MACH=mantra;; \ m68_sysV_0) MACH=mantra;; \
m68k2) MACH=m68k2;; *) MACH=m68k4;; \ *) MACH=m68k4;; \
esac ; echo $$MACH -r.c -.m -fp '$$*' > compile; chmod +x compile esac ; echo $$MACH $$AS -r.c -.m -fp '$$*' > compile; chmod +x compile
install: all install: all
-mkdir $b24 $b44 -mkdir $b24 $b44
ls em2_???? | sed 's:em2_\(.*\):cp & $b24/em_\1:' | sh ls em2_???? | sed 's:em2_\(.*\):cp & $b24/em_\1:' | sh

View file

@ -20,32 +20,7 @@ con_float(argval, str, res)
while (argval--) *res++ = *p++; while (argval--) *res++ = *p++;
return; return;
} }
f = frexp(f, &i);
fl = f; fl = f;
fl = frexp(fl,&j);
if (i+j > 127) {
/* overflow situation. Unfortunately we don't have the
slightest idea where the floating point constant came
from, so, for the time being, just ignore
*/
*res++ = f < 0 ? 0377 : 0177;
*res++ = 0377;
*res++ = 0377;
*res = 0377;
return;
}
if (i+j < -127) {
/* underflow situation. Unfortunately we don't have the
slightest idea where the floating point constant came
from, so, for the time being, just ignore
*/
*res++ = f < 0 ? 0200 : 0;
*res++ = 0200;
*res++ = 0;
*res = 0;
return;
}
fl = ldexp(fl, i+j);
p = (char *) &fl; p = (char *) &fl;
while (argval--) *res++ = *p++; while (argval--) *res++ = *p++;
} }

View file

@ -177,6 +177,9 @@ dat6: add.l d2,a3 ; move.l d2,d3
bne 6b ; add.l d3,a3 bne 6b ; add.l d3,a3
bra datloop bra datloop
.sect .data
flt_label: .data4 0
.sect .text
dofloat: dofloat:
move.l d2,d0 move.l d2,d0
checkfsize checkfsize
@ -186,9 +189,11 @@ dofloat:
move.l a3,-(sp) move.l a3,-(sp)
add.l d0,a3 add.l d0,a3
move.l a4,-(sp) move.l a4,-(sp)
move.l a4,flt_label
move.l d0,-(sp) move.l d0,-(sp)
bsr _con_float bsr _con_float
lea 12(sp),sp lea 12(sp),sp
clr.l flt_label
movem.l (sp)+,a0/a1/d0-d2 movem.l (sp)+,a0/a1/d0-d2
1: 1:
tst.b (a4)+ ; bne 1b tst.b (a4)+ ; bne 1b
@ -200,6 +205,10 @@ _con_float:
rts rts
#else #else
__fptrp: __fptrp:
tst.l flt_label
beq 1f
rts
1:
move.l 4(sp),d0 move.l 4(sp),d0
mov d0,-(sp) mov d0,-(sp)
bra error bra error