1*52706Sbostic/*- 2*52706Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*52706Sbostic * All rights reserved. 4*52706Sbostic * 5*52706Sbostic * This code is derived from software contributed to Berkeley by 6*52706Sbostic * Ralph Campbell. 7*52706Sbostic * 8*52706Sbostic * %sccs.include.redist.c% 9*52706Sbostic */ 10*52706Sbostic 11*52706Sbostic#if defined(LIBC_SCCS) && !defined(lint) 12*52706Sbostic ASMSTR("@(#)ldexp.s 5.1 (Berkeley) 02/29/92") 13*52706Sbostic#endif /* LIBC_SCCS and not lint */ 14*52706Sbostic 15*52706Sbostic#include "DEFS.h" 16*52706Sbostic 17*52706Sbostic .sdata 18*52706Sbosticinfinity: 19*52706Sbostic .word 0x7ff00000 # IEEE infinity 20*52706Sbostic .text 21*52706Sbostic 22*52706Sbostic/* 23*52706Sbostic * double ldexp(val, exp) 24*52706Sbostic * returns: val * (2**exp), for integer exp 25*52706Sbostic */ 26*52706SbosticLEAF(ldexp) 27*52706Sbostic .set noreorder 28*52706Sbostic mfc1 t0, $f13 29*52706Sbostic mov.d $f0, $f12 30*52706Sbostic sll t1, t0, 1 31*52706Sbostic srl t1, t1, 21 32*52706Sbostic addu t1, t1, a2 33*52706Sbostic blez t1, 3f 34*52706Sbostic slti t2, t1, 2047 35*52706Sbostic beq t2, zero, 2f 36*52706Sbostic sll a2, a2, 20 37*52706Sbostic addu t0, t0, a2 38*52706Sbostic mtc1 t0, $f1 39*52706Sbostic1: 40*52706Sbostic j ra 41*52706Sbostic nop 42*52706Sbostic2: 43*52706Sbostic lwc1 $f1, infinity 44*52706Sbostic bgez t0, 1b 45*52706Sbostic mtc1 zero, $f0 46*52706Sbostic j ra 47*52706Sbostic neg.d $f0, $f0 48*52706Sbostic3: 49*52706Sbostic blt t1, -51, 9f 50*52706Sbostic mfc1 t5, $f13 51*52706Sbostic li t2, 0x80000000 52*52706Sbostic sll t5, t5, 11 53*52706Sbostic blt t1, -30, 7f 54*52706Sbostic or t5, t5, t2 55*52706Sbostic srl t5, t5, 11 56*52706Sbostic mfc1 t4, $f12 57*52706Sbostic addiu t1, t1, -1 58*52706Sbostic sll t3, t5, t1 59*52706Sbostic srl t2, t4, t1 60*52706Sbostic subu t1, zero, t1 61*52706Sbostic srl t4, t4, t1 62*52706Sbostic or t4, t4, t3 63*52706Sbostic bgez t2, 6f 64*52706Sbostic srl t5, t5, t1 65*52706Sbostic addiu t4, t4, 1 66*52706Sbostic sltiu t6, t4, 1 67*52706Sbostic sll t2, t2, 1 68*52706Sbostic bne t2, zero, 6f 69*52706Sbostic addu t5, t5, t6 70*52706Sbostic and t4, t4, ~1 71*52706Sbostic6: 72*52706Sbostic mtc1 t4, $f0 73*52706Sbostic bgez t0, 1b 74*52706Sbostic mtc1 t5, $f1 75*52706Sbostic j ra 76*52706Sbostic neg.d $f0, $f0 77*52706Sbostic7: 78*52706Sbostic mtc1 zero, $f1 79*52706Sbostic addiu t1, t1, 20 80*52706Sbostic sll t2, t5, t1 81*52706Sbostic subu t1, zero, t1 82*52706Sbostic bgez t2, 8f 83*52706Sbostic srl t4, t5, t1 84*52706Sbostic addiu t4, t4, 1 85*52706Sbostic sltiu t6, t4, 1 86*52706Sbostic sll t2, t2, 1 87*52706Sbostic bne t2, zero, 8f 88*52706Sbostic mtc1 t6, $f1 89*52706Sbostic and t4, t4, ~1 90*52706Sbostic8: 91*52706Sbostic bgez t0, 1b 92*52706Sbostic mtc1 t4, $f0 93*52706Sbostic j ra 94*52706Sbostic neg.d $f0, $f0 95*52706Sbostic9: 96*52706Sbostic mtc1 zero, $f0 97*52706Sbostic bgez t0, 1b 98*52706Sbostic mtc1 zero, $f1 99*52706Sbostic j ra 100*52706Sbostic neg.d $f0, $f0 101*52706Sbostic .set reorder 102*52706SbosticEND(ldexp) 103