From: ceriel Date: Thu, 28 Apr 1988 15:16:07 +0000 (+0000) Subject: Added floating point support X-Git-Tag: release-5-5~3299 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=43de234b53c9c2143f559c540403a0711e570750;p=ack.git Added floating point support --- diff --git a/mach/mantra/int/.distr b/mach/mantra/int/.distr index f3db6bb46..53064dfc1 100644 --- a/mach/mantra/int/.distr +++ b/mach/mantra/int/.distr @@ -16,3 +16,4 @@ mloop9 mloopa mloopb mloopc +con_float.c diff --git a/mach/mantra/int/Makefile b/mach/mantra/int/Makefile index 952c3557a..f7970db6f 100644 --- a/mach/mantra/int/Makefile +++ b/mach/mantra/int/Makefile @@ -4,7 +4,7 @@ P = mloop FILES=deffile $P0 $P1 $P2 $P3 $P4 $P5 $P6 $P7 $P8 $P9 $Pa $Pb $Pc CPP=../../../lib/cpp b=../../../lib/int -FLTRAP=-DFLTRAP +FLTRAP= all: $(INTS) em @@ -14,41 +14,44 @@ em: em.c tmp.s: $(FILES) cat $(FILES) > tmp.s -em2_t---: tmp.s compile - ./compile -o em2_t--- -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s +em2_t---: tmp.s compile con_float.o + ./compile -o em2_t--- -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o -em2_----: tmp.s compile - ./compile -o em2_---- -P $(FLTRAP) -Dopfreq=0 -Dlast=0 -Dcount=0 -Dtest=0 -Dflow=0 -Dprof=0 tmp.s +em2_----: tmp.s compile con_float.o + ./compile -o em2_---- -P $(FLTRAP) -Dopfreq=0 -Dlast=0 -Dcount=0 -Dtest=0 -Dflow=0 -Dprof=0 tmp.s con_float.o -em2_t-cp: tmp.s compile - ./compile -o em2_t-cp -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s +em2_t-cp: tmp.s compile con_float.o + ./compile -o em2_t-cp -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o -em2_t-c-: tmp.s compile - ./compile -o em2_t-c- -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s +em2_t-c-: tmp.s compile con_float.o + ./compile -o em2_t-c- -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o -em2_t--p: tmp.s compile - ./compile -o em2_t--p -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s +em2_t--p: tmp.s compile con_float.o + ./compile -o em2_t--p -P $(FLTRAP) -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o -em4_t---: tmp.s compile - ./compile -o em4_t--- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s +em4_t---: tmp.s compile con_float.o + ./compile -o em4_t--- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o -em4_----: tmp.s compile - ./compile -o em4_---- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=0 -Dcount=0 -Dtest=0 -Dflow=0 -Dprof=0 tmp.s +em4_----: tmp.s compile con_float.o + ./compile -o em4_---- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=0 -Dcount=0 -Dtest=0 -Dflow=0 -Dprof=0 tmp.s con_float.o -em4_t-cp: tmp.s compile - ./compile -o em4_t-cp -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s +em4_t-cp: tmp.s compile con_float.o + ./compile -o em4_t-cp -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s con_float.o -em4_t-c-:tmp.s compile - ./compile -o em4_t-c- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s +em4_t-c-:tmp.s compile con_float.o + ./compile -o em4_t-c- -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=1 -Dtest=1 -Dflow=0 -Dprof=0 tmp.s con_float.o -em4_t--p: tmp.s compile - ./compile -o em4_t--p -P $(FLTRAP) -Dlword -Dopfreq=0 -Dlast=1 -Dcount=0 -Dtest=1 -Dflow=0 -Dprof=1 tmp.s +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 + +con_float.o: con_float.c compile + ./compile -c -L -O con_float.c compile: Makefile case `ack_sys` in sun*) MACH=sun2;; pmds*) MACH=pmds4;; \ m68_sysV_0) MACH=mantra;; \ m68k2) MACH=m68k2;; *) MACH=m68k4;; \ - esac ; echo $$MACH -.m '$$*' > compile; chmod +x compile + esac ; echo $$MACH -r.c -.m -fp '$$*' > compile; chmod +x compile install: all -mkdir $b24 $b44 ls em2_???? | sed 's:em2_\(.*\):cp & $b24/em_\1:' | sh diff --git a/mach/mantra/int/con_float.c b/mach/mantra/int/con_float.c new file mode 100644 index 000000000..328f8cae1 --- /dev/null +++ b/mach/mantra/int/con_float.c @@ -0,0 +1,51 @@ +/* unfortunately, we cannot just do an atof and convert result to float + is neccessary, because that might result in over/underflow at an + unexpected moment. For the time being, overflow in floating point + constants goes undetected +*/ +con_float(argval, str, res) + char *str, *res; +{ + double f; + double atof(); + int i; + double frexp(), ldexp(); + int j; + float fl; + char *p; + + f = atof(str); + if (f == 0 || argval == 8) { + p = (char *) &f; + while (argval--) *res++ = *p++; + return; + } + f = frexp(f, &i); + 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; + while (argval--) *res++ = *p++; +} diff --git a/mach/mantra/int/deffile b/mach/mantra/int/deffile index c45b43494..7ae37af90 100644 --- a/mach/mantra/int/deffile +++ b/mach/mantra/int/deffile @@ -86,4 +86,5 @@ bcc 7f ;\ cmp.l a6,a0 ;\ bcc 6f +#define checkfsize cmp.w #4,d0 ; beq 4f ; cmp.w #8,d0 ; beq 8f ; bra e_oddz diff --git a/mach/mantra/int/mloop0 b/mach/mantra/int/mloop0 index 1176b0f8c..36bc9c3b8 100644 --- a/mach/mantra/int/mloop0 +++ b/mach/mantra/int/mloop0 @@ -174,13 +174,33 @@ dat6: add.l d2,a3 ; move.l d2,d3 bne 6b ; add.l d3,a3 bra datloop -dofloat: add.l d2,a3 - bsr atof ; bra datloop +dofloat: + move.l d2,d0 + checkfsize +4: +8: + movem.l a0/a1/d0-d2,-(sp) + move.l a3,-(sp) + add.l d0,a3 + move.l a4,-(sp) + move.l d0,-(sp) + bsr _con_float + lea 12(sp),sp + movem.l (sp)+,a0/a1/d0-d2 +1: + tst.b (a4)+ ; bne 1b + bra datloop +#ifdef FLTRAP !DUMMY ASCII TO FLOAT ROUTINE -atof: tst.b (a4)+ ; bne atof +_con_float: rts - +#else +__fptrp: + move.l 4(sp),d0 + mov d0,-(sp) + bra error +#endif blshift: move.l a1,a0 ; move.l #1024,d0 move.l d1,-(sp) tst.l -(sp) diff --git a/mach/mantra/int/mloop5 b/mach/mantra/int/mloop5 index 570ae1f20..a2e7a5e69 100644 --- a/mach/mantra/int/mloop5 +++ b/mach/mantra/int/mloop5 @@ -175,12 +175,162 @@ cuu_z: mov (sp)+,d0 ; mov (sp)+,d1 5: jmp (a4) !-------------------------------------------------------------------------- +#ifdef FLTRAP cuf_z: cfu_z: cff_z: cfi_z: cif_z: mov (sp)+,d0 ; subt (sp)+,d0 ext.l d0 sub.l d0,sp -#ifdef FLTRAP bra flnim !floating point not implemented #else +cfu_z: + clr.l d0 + mov (sp)+,d0 + clr.l d1 + mov (sp)+,d1 + move.l d1,-(sp) + move.l d0,-(sp) + checksize +2: + move.l #4,(sp) + cmp #4,d1 + bne 1f + jsr .cfu + add #8,sp +2: + mov #4,-(sp) + mov #2,-(sp) + bra cuu_z +1: + cmp #8,d1 + beq 1f + bra e_oddz +1: + jsr .cfu + add #12,sp + bra 2b +4: + mov d1,d0 + checkfsize +4: + jsr .cfu + add #8,sp + jmp (a4) +8: + jsr .cfu + add #12,sp + jmp (a4) +cfi_z: + clr.l d0 + mov (sp)+,d0 + clr.l d1 + mov (sp)+,d1 + move.l d1,-(sp) + move.l d0,-(sp) + checksize +2: + move.l #4,(sp) + cmp #4,d1 + bne 1f + jsr .cfi + add #8,sp +2: + mov #4,-(sp) + mov #2,-(sp) + bra cii_z +1: + cmp #8,d1 + beq 1f + bra e_oddz +1: + jsr .cfi + add #12,sp + bra 2b +4: + mov d1,d0 + checkfsize +4: + jsr .cfi + add #8,sp + jmp (a4) +8: + jsr .cfi + add #12,sp + jmp (a4) +cuf_z: + mov (sp)+,d0 + checkfsize +4: + mov (sp)+,d0 + checksize +2: + clr.l d0 + move.w (sp)+,d0 + move.l d0,-(sp) +4: + move.l #4,-(sp) + jsr .cuf4 + add #4,sp + jmp (a4) +8: + mov (sp)+,d0 + checksize +2: + clr.l d0 + move.w (sp)+,d0 + move.l d0,-(sp) +4: + move.l #4,-(sp) + jsr .cuf8 + jmp (a4) + +cif_z: + mov (sp)+,d0 + checkfsize +4: + mov (sp)+,d0 + checksize +2: + move.w (sp)+,d0 + ext.l d0 + move.l d0,-(sp) +4: + move.l #4,-(sp) + jsr .cif4 + add #4,sp + jmp (a4) +8: + mov (sp)+,d0 + checksize +2: + move.w (sp)+,d0 + ext.l d0 + move.l d0,-(sp) +4: + move.l #4,-(sp) + jsr .cif8 + jmp (a4) + +cff_z: + mov (sp)+,d0 ; + checkfsize +4: + mov (sp)+,d0 ; cmp #4,d0 ; beq 1f + cmp #8,d0 ; beq 2f + bra e_oddz +2: + jsr .cff4 + add #4,sp +1: + jmp (a4) +8: + mov (sp)+,d0 ; cmp #8,d0 ; beq 1f + cmp #4,d0 ; beq 2f + bra e_oddz +2: + move.l (sp)+,d0 + clr.l -(sp) + move.l d0,-(sp) + jsr .cff8 +1: jmp (a4) #endif diff --git a/mach/mantra/int/mloop7 b/mach/mantra/int/mloop7 index 8ca62c23a..408dd5e9f 100644 --- a/mach/mantra/int/mloop7 +++ b/mach/mantra/int/mloop7 @@ -101,25 +101,151 @@ sru_l: adroff ; move.w (a5),d0 !------------------------------------------------------------------------------ ! DUMMY FLOATING POINT ROUTINES !------------------------------------------------------------------------------ -adf_l: sbf_l: mlf_l: dvf_l: +adf_l: adroff ; move.w (a5),d0 -1: add.l d0,sp +1: #ifdef FLTRAP bra flnim #else + checkfsize +4: + jsr .adf4 + add.l #4,sp + jmp (a4) +8: + jsr .adf8 + add.l #8,sp + jmp (a4) +#endif +adf_z: + mov (sp)+,d0 ; bra 1b +adf_s0: + move.l #0,d0 ; move.b (a3)+,d0 + bra 1b + +sbf_l: + adroff ; move.w (a5),d0 +1: +#ifdef FLTRAP + bra flnim +#else + checkfsize +4: + jsr .sbf4 + add.l #4,sp + jmp (a4) +8: + jsr .sbf8 + add.l #8,sp + jmp (a4) +#endif +sbf_z: + mov (sp)+,d0 ; bra 1b +sbf_s0: + move.l #0,d0 ; move.b (a3)+,d0 + bra 1b + +mlf_l: + adroff ; move.w (a5),d0 +1: +#ifdef FLTRAP + bra flnim +#else + checkfsize +4: + jsr .mlf4 + add.l #4,sp + jmp (a4) +8: + jsr .mlf8 + add.l #8,sp jmp (a4) #endif -adf_z: sbf_z: mlf_z: dvf_z: +mlf_z: mov (sp)+,d0 ; bra 1b -adf_s0: sbf_s0: mlf_s0: dvf_s0: +mlf_s0: move.l #0,d0 ; move.b (a3)+,d0 bra 1b -fef_l: sub.l wrd,sp -fif_l: ngf_l: adroff -fef_z: + +dvf_l: + adroff ; move.w (a5),d0 +1: +#ifdef FLTRAP + bra flnim +#else + checkfsize +4: + jsr .dvf4 + add.l #4,sp + jmp (a4) +8: + jsr .dvf8 + add.l #8,sp + jmp (a4) +#endif +dvf_z: + mov (sp)+,d0 ; bra 1b +dvf_s0: + move.l #0,d0 ; move.b (a3)+,d0 + bra 1b + +ngf_l: adroff ; move.w (a5),d0 +1: +#ifdef FLTRAP + bra flnim +#else + checkfsize +4: + jsr .ngf4 + jmp (a4) +8: + jsr .ngf8 + jmp (a4) +#endif +ngf_z: + mov (sp)+,d0 ; bra 1b + +fif_l: adroff ; move.w (a5),d0 +1: +#ifdef FLTRAP + bra flnim +#else + checkfsize +4: + jsr .fif4 + jmp (a4) +8: + jsr .fif8 + jmp (a4) +#endif +fif_z: + mov (sp)+,d0 ; bra 1b + +fef_l: adroff ; move.w (a5),d0 +1: #ifdef FLTRAP bra flnim #else + checkfsize +4: + move.l (sp)+,d0 + clr.l -(sp) + move.l d0,-(sp) + jsr .fef4 +#ifndef lword + add.l #2,sp +#endif + jmp (a4) +8: + move.l (sp)+,d0 + move.l (sp)+,d1 + clr.l -(sp) + move.l d1,-(sp) + move.l d0,-(sp) + jsr .fef8 +#ifndef lword + add.l #2,sp +#endif jmp (a4) #endif -ngf_z: fif_z: add.l wrd,sp ; bra fef_z +fef_z: mov (sp)+,d0 ; bra 1b diff --git a/mach/mantra/int/mloop8 b/mach/mantra/int/mloop8 index 3d79a8e0f..0b548c48a 100644 --- a/mach/mantra/int/mloop8 +++ b/mach/mantra/int/mloop8 @@ -133,11 +133,22 @@ cms_s0: move.l d6,d0 ; move.b (a3)+,d0 ! DUMMY FLOAT ROUTINES. POINTER ADJUSTMENT AND WARNING cmf_s0: move.l d6,d0 ; move.b (a3)+,d0 +#ifdef FLTRAP 9: add.w d0,d0 ; add.l d0,sp cl -(sp) -#ifdef FLTRAP bra flnim #else +9: + checkfsize +4: + jsr .cmf4 + lea 8(sp),sp + mov d0,-(sp) + jmp (a4) +8: + jsr .cmf8 + lea 16(sp),sp + mov d0,-(sp) jmp (a4) #endif cmf_l: adroff ; move.w (a5),d0 ; bra 9b diff --git a/mach/mantra/int/mloop9 b/mach/mantra/int/mloop9 index 37fb74d86..344d385ae 100644 --- a/mach/mantra/int/mloop9 +++ b/mach/mantra/int/mloop9 @@ -185,7 +185,8 @@ str_s0: move.l d6,d0 ; move.b (a3)+,d0 3: move.l d1,-(sp) move.l d1,-(sp) ; add.l #1280,(sp) bsr _Xbreak ; testen (sp)+ -4: beq 1f ; bsr e_heap ; jmp (a4) +4: beq 1f ; testen (sp)+ ; bsr e_heap ; + move.l (sp)+,d1 ; jmp (a4) 1: move.l (sp)+,d1 ; bra 5b !---------------------------------------------------------------------------- diff --git a/mach/mantra/int/mloopa b/mach/mantra/int/mloopa index 8f47b8274..d3d0a88fe 100644 --- a/mach/mantra/int/mloopa +++ b/mach/mantra/int/mloopa @@ -28,8 +28,8 @@ e_badmon: mov #0x19,-(sp) ; bra error e_badlin: mov #0x1A,-(sp) ; bra error e_badgto: mov #0x1B,-(sp) ; bra error -flnim: mov #0xB,-(sp) ; bra error -no8bar: mov #0xC,-(sp) ; bra error +flnim: bra e_illins +no8bar: bra e_oddz !--------------------------------------------------------------------------- ! ERRORS AND TRAPS !----------------------------------------------------------------------------