Subject: Re: VS4000/60, modf, and EMODD
To: Chuck Dickman <chd_1@nktelco.net>
From: Lord Isildur <mrfusion@uranium.vaxpower.org>
List: port-vax
Date: 01/31/2002 02:07:20
ah yes, this is still not supported in the emulation (right ragge?) 
i ran into this same issue on an nvax machine with printf calling modf 
during the printing of %f and %d formatted stuff. my workaround was to 
replace the inlined emodd in the library with some other bits that do the 
same thing. heres what i wrote: 

----
ENTRY(modf, 0)
/*	emodd	4(ap),$0,$0f1.0,r2,r0
 * emodd is not supported on the NVAX! (a violation of the VARM, too)
 * so, we so (almost) the same thing now with a few instructions. 
 * -changed by isildur, 15-jul-2001 
 */
	/* *12(ap) is where the integer component goes, r0 is
	 * where the fraction component goes */

	cvtdl   4(ap),r2		# get the integer part out
	jvs	1f			# integer overflow
	cvtld	r2,*12(ap)		# put it in float format, in dest
	subd3 	*12(ap),4(ap),r0	# put fraction in r0
	ret
1:
	subl2	$24,sp			#paranoia
	movd	4(ap),-8(fp)		#copy original value
2:
	movd	$0f0.0,-16(fp)
	bicl3	$0xffff007f,-8(fp),-24(fp)	#copy sign bit too
	bisl2	-24(fp),-16(fp)		#close integer value now
	subd2	-16(fp),-8(fp)		#it's much closer to just a fraction
	cvtdl	-8(fp),-24(fp)		#convert to integer
	jvs	2b			#still not enough
	cvtld	-24(fp),-16(fp)		#get the remaining integer part
	subd3	-16(fp),-8(fp),r0	#put fraction in r0
	bicl2	$0x8000,r0		# ugly, clear sign bit
	subd3	r0,4(ap),*12(ap)	#put integer component back
	addl2	$24,sp			#paranoia
	ret
					/* we don't handle an overflow! */
----

with a couple lines to glue it in where you need it, this should work.
it's been running on my system since the summer with no problems, including
having the whole source tree recompiled to use it. 

happy hacking,
isildur

On Wed, 30 Jan 2002, Chuck Dickman wrote:

> I have been trying to run an SSL web server on my VS4000/60. 
> When I start it, it crashes with an error about an unimplemented
> instruction. I traced this down to an EMODD instruction in
> the math library function modf. The hardware support page
> says that POLYD is not supported on the VS4000/60 and in the
> same source file I see EMODD stuff.
> 
> Is the EMODD instruction not supported along with POLYD?
> 
> Are there any work arounds? I guess I could modify the SSL
> source or the library itself.
> 
> Suggestions?
> 
> -chuck
>