196625Stjr/*	$OpenBSD: s_ceil.S,v 1.5 2022/12/27 17:10:07 jmc Exp $ */
296625Stjr/*
396625Stjr * Written by J.T. Conklin <jtc@netbsd.org>.
496625Stjr * Public domain.
596625Stjr */
696625Stjr
796625Stjr#include "DEFS.h"
896625Stjr
996625StjrENTRY(ceil)
1096625Stjr	subl	$8,%esp
1196625Stjr
1296625Stjr	fstcw	4(%esp)		/* store fpu control word */
1396625Stjr	movw	4(%esp),%dx
1496625Stjr	orw	$0x0800,%dx		/* round towards +oo */
1596625Stjr	andw	$0xfbff,%dx
1696625Stjr	movw	%dx,(%esp)
1796625Stjr	fldcw	(%esp)		/* load modified control word */
1896625Stjr
1996625Stjr	fldl	12(%esp);		/* round */
2096625Stjr	frndint
2196625Stjr
2296625Stjr	fldcw	4(%esp)		/* restore original control word */
2396625Stjr
2496625Stjr	addl	$8,%esp
2596625Stjr	ret
2696625StjrEND_STD(ceil)
2796625Stjr