| Commit | Line | Data |
|---|---|---|
| b34b60bc JS |
1 | /* |
| 2 | * Written by J.T. Conklin <jtc@NetBSD.org>. | |
| 3 | * Public domain. | |
| 4 | * | |
| 74dfd0cf | 5 | * $NetBSD: s_ceil.S,v 1.8 2011/06/18 21:24:51 joerg Exp |
| b34b60bc JS |
6 | */ |
| 7 | ||
| 8 | #include <machine/asm.h> | |
| 9 | ||
| 10 | #include "abi.h" | |
| 11 | ||
| 12 | ENTRY(ceil) | |
| 13 | #ifdef __i386__ | |
| 14 | pushl %ebp | |
| 15 | movl %esp,%ebp | |
| 16 | subl $8,%esp | |
| 17 | ||
| 18 | fstcw -4(%ebp) /* store fpu control word */ | |
| 19 | movw -4(%ebp),%dx | |
| 20 | orw $0x0800,%dx /* round towards +oo */ | |
| 21 | andw $0xfbff,%dx | |
| 22 | movw %dx,-8(%ebp) | |
| 23 | fldcw -8(%ebp) /* load modfied control word */ | |
| 24 | ||
| 74dfd0cf | 25 | fldl 8(%ebp) /* round */ |
| b34b60bc JS |
26 | frndint |
| 27 | ||
| 28 | fldcw -4(%ebp) /* restore original control word */ | |
| 29 | ||
| 30 | leave | |
| 31 | #else | |
| 32 | fstcw -12(%rsp) | |
| 33 | movw -12(%rsp),%dx | |
| 34 | orw $0x0800,%dx | |
| 35 | andw $0xfbff,%dx | |
| 36 | movw %dx,-16(%rsp) | |
| 37 | fldcw -16(%rsp) | |
| 38 | movsd %xmm0,-8(%rsp) | |
| 39 | fldl -8(%rsp) | |
| 40 | frndint | |
| 41 | fldcw -12(%rsp) | |
| 42 | fstpl -8(%rsp) | |
| 43 | movsd -8(%rsp),%xmm0 | |
| 44 | #endif | |
| 45 | ret | |
| d04e8698 | 46 | END(ceil) |
| 70e34eb2 JM |
47 | |
| 48 | .section .note.GNU-stack,"",%progbits |