~ubuntu-branches/ubuntu/breezy/avr-libc/breezy

« back to all changes in this revision

Viewing changes to libm/fplib/frexp.S

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2002-04-15 14:53:38 UTC
  • Revision ID: james.westby@ubuntu.com-20020415145338-c8hi0tn5bx74w7o3
Tags: upstream-20020203
ImportĀ upstreamĀ versionĀ 20020203

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  -*- Mode: Asm -*-  */
 
2
/*
 
3
    frexp.S is part of     FPlib V 0.3.0       ported to avr-as
 
4
    for copyright and details see readme.fplib
 
5
 
 
6
 *----------------------------------------------------------------------------------------
 
7
 *
 
8
 *      A = mantissa(A)  *integ = exponent(A)
 
9
 * e.g.
 
10
 * int integ
 
11
 * double fract = frexp( 3.45, &integ ) = frexp ( 2^2 * 0.8625 )
 
12
 * -> fract = 0.8625; *integ = 2
 
13
 *
 
14
 * fract(0) -> 0/0
 
15
 */
 
16
 
 
17
#include "gasava.inc"
 
18
#include "fplib.inc"
 
19
 
 
20
          TEXT_SEG(fplib, frexp)
 
21
          FUNCTION(frexp)
 
22
 
 
23
GLOBAL(frexp)
 
24
        MOV     ZH,rPH
 
25
        MOV     ZL,rPL
 
26
        BST     rA3,7
 
27
 
 
28
        RCALL   _U(__fp_split1) ;
 
29
        TST     rA3
 
30
        BREQ    _frexp_200
 
31
        SUBI    rA3,0x7E        ; 0.5 -> 0.5 * 2^0
 
32
                                ; 1.0 -> 0.5 * 2^1
 
33
        SBC     rB0,rB0         ; sign expand rA3
 
34
        ST      Z,rA3
 
35
        STD     Z+1,rB0
 
36
 
 
37
        ANDI    rA2,0x7F        ; mantissa is normalized
 
38
        LDI     rA3,0x3F        ; exponent for 0.5
 
39
        BLD     rA3,7
 
40
        RET
 
41
 
 
42
 _frexp_200:
 
43
        ST      Z,rA3
 
44
        STD     Z+1,rT1c
 
45
        RJMP    _U(__fp_zero)   ; frexp(0) returns 0 not A = 0x00800000 of fp_split1
 
46
 
 
47
          ENDFUNC
 
48
 
 
49