File:  [MW Coherent from dump] / coherent / b / lib / libm / i387 / ceil87.s
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

//////////
/ /usr/src/libm/i387/ceil87.s
/ i387 mathematics library
/ ceil(d), floor(d)
//////////

RASIZE	=	4

	.globl	ceil
	.globl	floor
	.globl	_floor

cwup	=	0xBFF		/ round up NDP control word
cwdown	=	0x7FF		/ round down NDP control word

d	=	RASIZE		/ arg offset

//////////
/ double
/ ceil(d)
/ double d;
//////////


ceil:
	fldl	d(%esp)		/ Load argument d.
	movw	%ax, $cwup	/ New control word to AX.
	jmp	.L0

//////////
/ double
/ floor(d)
/ double d;
/
/ _floor() rounds the NDP stacktop %st down to the int below.
/ It saves and restores the current NDP control word.
//////////

oldcw	=	0		/ old NDP control word offset off %esp
newcw	=	2		/ new NDP control word offset off %esp

floor:
	fldl	d(%esp)		/ Load argument d.

_floor:				/ d
	movw	%ax, $cwdown	/ New control word to AX.

.L0:				/ d in %st, new control word in AX.
	push	%eax		/ Claim two words.
	movw	newcw(%esp),%ax	/ Save new control word.
	fstcw	oldcw(%esp)	/ Save old control word.
	fldcw	newcw(%esp)	/ Load new control word.
	frndint			/ int(d)
	fldcw	oldcw(%esp)	/ Restore saved control word.
	pop	%eax		/ Clean stack.
	ret

/ end of ceil87.s

unix.superglobalmegacorp.com

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