File:  [CSRG BSD Unix] / 40BSD / libc / gen / modf.s
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:53 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD40
BSD 4.0

#
#	double modf (value, iptr)
#		double value;
#		double *iptr;
#
#	Modf returns the fractional part of "value", and stores the integer
#	part indirectly through "iptr".
#
#	Entry point
#
	.text
	.align	1
	.globl	_modf
_modf:	.word	0x0000		# We use r0-r2, but do not save them
#
#	This instruction does the following:
#
#		Extend the long floating value at 4(ap) with 0, and
#		multiply it by 1.0.  Store the integer part of the result
#		in r2, and the fractional part of the result in r0-r1.
#
	emodf	4(ap),$0,$0f1.0,r2,r0	# How did you like
					# THAT, sports fans?
	jvs	iovfl			# Jump if integer overflow
	cvtld	r2,*12(ap)		# Else store integer result
	ret				#    and return
#
#	Integer overflow occurred...develop the integer part by
#	subtracting the fractional part from the argument.
#
iovfl:	subd3	r0,4(ap),*12(ap)	# Develop integer part
	ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.