/* Copyright (c) 1988, 1989 by Sun Microsystems, Inc. */
/* @(#)fr-sun386.il 22.1 89/08/10 Copyright 1988, 1989 Sun Micro */

	.inline	vfradd, 0
	movl	(%esp), %eax
	addl	4(%esp), %eax
/ASM
	.noopt
	.byte	0x71, 0x07		/* SHORT FORM jno	.+9 */
	incw	fract_overflows
	.optim
/ASMEND
	.end

	.inline	vfrsub, 0
	movl	(%esp), %eax
	subl	4(%esp), %eax
/ASM
	.noopt
	.byte	0x71, 0x07		/* SHORT FORM jno	.+9 */
	incw	fract_overflows
	.optim
/ASMEND
	.end

	.inline	frmul, 0
	movl	(%esp), %eax
	imull	4(%esp)
	shrdl	$16, %edx, %eax
	.end

	.inline	vfrmul, 0
	movl	(%esp), %eax
	imull	4(%esp)		/* %eax & %edx contain the 64-bit result */
	shrdl	$16, %edx, %eax	/* now %eax contains the "fract" result */
/* NOTE: multiplying two SIGNED 32-bit numbers gives a 63-bit SIGNED result */
/*	 Therefore, overflow has occured iff bits 15 to 31 of the upper half */
/*	are not all 0 or all 1 ( 17 bits but we can ignore the highest */
/*	This means that we shift by 15 bits NOT by 16 */
	sarl	$15, %edx	/* Arithmetic shift -- sign bit replicated */
/* Now, %edx contains the "fract" excess ( 15 bits ) - sign extended */
/* plus the signbit of result fract is the LSB of %edx. */
		/* Check if the excess is Zero */
	andl	%edx, %edx
/ASM
	.noopt
	.byte	0x74, 0x0A		/* SHORT FORM jz	.+12 */
		/* Check if the excess is -1 ( i.e. just a sign extension ) */
	incl	%edx
	.byte	0x74, 0x07		/* SHORT FORM jz	.+09 */
	incw	fract_overflows
	.optim
/ASMEND
	.end
