improved floating point handling
This commit is contained in:
		
							parent
							
								
									5aa128ea62
								
							
						
					
					
						commit
						a9a2e027c8
					
				
					 3 changed files with 17 additions and 30 deletions
				
			
		|  | @ -44,14 +44,17 @@ em4_t-c-: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 | ||||
| 
 | ||||
| con_float.o:	con_float.c compile | ||||
| 	./compile -c -L -O con_float.c | ||||
| con_float.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 | ||||
| 		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;; \
 | ||||
| 				    m68k2) MACH=m68k2;; *) MACH=m68k4;; \
 | ||||
| 		esac ; echo $$MACH -r.c -.m -fp '$$*' > compile; chmod +x compile | ||||
| 				    *) MACH=m68k4;; \
 | ||||
| 		esac ; echo $$MACH $$AS -r.c -.m -fp '$$*' > compile; chmod +x compile | ||||
| install:	all | ||||
| 		-mkdir $b24 $b44 | ||||
| 		ls em2_???? | sed 's:em2_\(.*\):cp & $b24/em_\1:' | sh | ||||
|  |  | |||
|  | @ -20,32 +20,7 @@ con_float(argval, str, res) | |||
| 		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++; | ||||
| } | ||||
|  |  | |||
|  | @ -177,6 +177,9 @@ dat6:		add.l	d2,a3	;	move.l	d2,d3 | |||
| 		bne	6b	;	add.l	d3,a3 | ||||
| 		bra	datloop | ||||
| 
 | ||||
| .sect .data | ||||
| flt_label:	.data4 0 | ||||
| .sect .text | ||||
| dofloat: | ||||
| 		move.l	d2,d0 | ||||
| 		checkfsize | ||||
|  | @ -186,9 +189,11 @@ dofloat: | |||
| 		move.l	a3,-(sp) | ||||
| 		add.l	d0,a3 | ||||
| 		move.l	a4,-(sp) | ||||
| 		move.l	a4,flt_label | ||||
| 		move.l	d0,-(sp) | ||||
| 		bsr	_con_float | ||||
| 		lea	12(sp),sp | ||||
| 		clr.l	flt_label | ||||
| 		movem.l	(sp)+,a0/a1/d0-d2 | ||||
| 1: | ||||
| 		tst.b	(a4)+ ;		bne	1b | ||||
|  | @ -200,6 +205,10 @@ _con_float: | |||
| 		rts | ||||
| #else | ||||
| __fptrp: | ||||
| 		tst.l	flt_label | ||||
| 		beq	1f | ||||
| 		rts | ||||
| 1: | ||||
| 		move.l	4(sp),d0 | ||||
| 		mov	d0,-(sp) | ||||
| 		bra	error | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue