|
|
1.1 ! root 1: /*- ! 2: * Copyright (c) 1990 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * the Systems Programming Group of the University of Utah Computer ! 7: * Science Department. ! 8: * ! 9: * Redistribution and use in source and binary forms are permitted ! 10: * provided that: (1) source distributions retain this entire copyright ! 11: * notice and comment, and (2) distributions including binaries display ! 12: * the following acknowledgement: ``This product includes software ! 13: * developed by the University of California, Berkeley and its contributors'' ! 14: * in the documentation or other materials provided with the distribution ! 15: * and in all advertising materials mentioning features or use of this ! 16: * software. Neither the name of the University nor the names of its ! 17: * contributors may be used to endorse or promote products derived ! 18: * from this software without specific prior written permission. ! 19: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 20: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 21: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 22: * ! 23: * @(#)floor.s 5.1 (Berkeley) 5/17/90 ! 24: */ ! 25: ! 26: .text ! 27: .globl _floor,_ceil,_rint ! 28: ! 29: | floor(x) ! 30: | the largest integer no larger than x ! 31: _floor: ! 32: fmovel fpcr,d0 | save old FPCR ! 33: fmoved sp@(4),fp0 | get argument ! 34: fbun Lret | if NaN, return NaN ! 35: fboge Lrtz | >=0, round to zero ! 36: fmovel #0x20,fpcr | <0, round to -inf ! 37: jra Ldoit ! 38: ! 39: | ceil(x) ! 40: | -floor(-x), for all real x ! 41: _ceil: ! 42: fmovel fpcr,d0 | save old FPCR ! 43: fmoved sp@(4),fp0 | get argument ! 44: fbun Lret | if NaN, return NaN ! 45: fbolt Lrtz | <0, round to zero ! 46: fmovel #0x30,fpcr | >=0, round to inf ! 47: jra Ldoit ! 48: ! 49: Lrtz: ! 50: fmovel #0x10,fpcr ! 51: Ldoit: ! 52: fintd sp@(4),fp0 | truncate ! 53: fmovel d0,fpcr | restore old FPCR ! 54: Lret: ! 55: fmoved fp0,sp@- ! 56: movel sp@+,d0 ! 57: movel sp@+,d1 ! 58: rts ! 59: ! 60: | rint(x) ! 61: | delivers integer nearest x in direction of prevailing rounding mode ! 62: _rint: ! 63: fintd sp@(4),fp0 | use prevailing rounding mode ! 64: jra Lret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.