OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [m68k/] [m68040/] [fpsp/] [smovecr.S] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
//
2
//      $Id: smovecr.S,v 1.2 2001-09-27 12:01:22 chris Exp $
3
//
4
//      smovecr.sa 3.1 12/10/90
5
//
6
//      The entry point sMOVECR returns the constant at the
7
//      offset given in the instruction field.
8
//
9
//      Input: An offset in the instruction word.
10
//
11
//      Output: The constant rounded to the user's rounding
12
//              mode unchecked for overflow.
13
//
14
//      Modified: fp0.
15
//
16
//
17
//              Copyright (C) Motorola, Inc. 1990
18
//                      All Rights Reserved
19
//
20
//      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
21
//      The copyright notice above does not evidence any
22
//      actual or intended publication of such source code.
23
 
24
//SMOVECR       idnt    2,1 | Motorola 040 Floating Point Software Package
25
 
26
        |section 8
27
 
28
#include "fpsp.defs"
29
 
30
        |xref   nrm_set
31
        |xref   round
32
        |xref   PIRN
33
        |xref   PIRZRM
34
        |xref   PIRP
35
        |xref   SMALRN
36
        |xref   SMALRZRM
37
        |xref   SMALRP
38
        |xref   BIGRN
39
        |xref   BIGRZRM
40
        |xref   BIGRP
41
 
42
FZERO:  .long   00000000
43
//
44
//      FMOVECR
45
//
46
        .global smovcr
47
smovcr:
48
        bfextu  CMDREG1B(%a6){#9:#7},%d0 //get offset
49
        bfextu  USER_FPCR(%a6){#26:#2},%d1 //get rmode
50
//
51
// check range of offset
52
//
53
        tstb    %d0             //if zero, offset is to pi
54
        beqs    PI_TBL          //it is pi
55
        cmpib   #0x0a,%d0               //check range $01 - $0a
56
        bles    Z_VAL           //if in this range, return zero
57
        cmpib   #0x0e,%d0               //check range $0b - $0e
58
        bles    SM_TBL          //valid constants in this range
59
        cmpib   #0x2f,%d0               //check range $10 - $2f
60
        bles    Z_VAL           //if in this range, return zero
61
        cmpib   #0x3f,%d0               //check range $30 - $3f
62
        ble     BG_TBL          //valid constants in this range
63
Z_VAL:
64
        fmoves  FZERO,%fp0
65
        rts
66
PI_TBL:
67
        tstb    %d1             //offset is zero, check for rmode
68
        beqs    PI_RN           //if zero, rn mode
69
        cmpib   #0x3,%d1                //check for rp
70
        beqs    PI_RP           //if 3, rp mode
71
PI_RZRM:
72
        leal    PIRZRM,%a0      //rmode is rz or rm, load PIRZRM in a0
73
        bra     set_finx
74
PI_RN:
75
        leal    PIRN,%a0                //rmode is rn, load PIRN in a0
76
        bra     set_finx
77
PI_RP:
78
        leal    PIRP,%a0                //rmode is rp, load PIRP in a0
79
        bra     set_finx
80
SM_TBL:
81
        subil   #0xb,%d0                //make offset in 0 - 4 range
82
        tstb    %d1             //check for rmode
83
        beqs    SM_RN           //if zero, rn mode
84
        cmpib   #0x3,%d1                //check for rp
85
        beqs    SM_RP           //if 3, rp mode
86
SM_RZRM:
87
        leal    SMALRZRM,%a0    //rmode is rz or rm, load SMRZRM in a0
88
        cmpib   #0x2,%d0                //check if result is inex
89
        ble     set_finx        //if 0 - 2, it is inexact
90
        bra     no_finx         //if 3, it is exact
91
SM_RN:
92
        leal    SMALRN,%a0      //rmode is rn, load SMRN in a0
93
        cmpib   #0x2,%d0                //check if result is inex
94
        ble     set_finx        //if 0 - 2, it is inexact
95
        bra     no_finx         //if 3, it is exact
96
SM_RP:
97
        leal    SMALRP,%a0      //rmode is rp, load SMRP in a0
98
        cmpib   #0x2,%d0                //check if result is inex
99
        ble     set_finx        //if 0 - 2, it is inexact
100
        bra     no_finx         //if 3, it is exact
101
BG_TBL:
102
        subil   #0x30,%d0               //make offset in 0 - f range
103
        tstb    %d1             //check for rmode
104
        beqs    BG_RN           //if zero, rn mode
105
        cmpib   #0x3,%d1                //check for rp
106
        beqs    BG_RP           //if 3, rp mode
107
BG_RZRM:
108
        leal    BIGRZRM,%a0     //rmode is rz or rm, load BGRZRM in a0
109
        cmpib   #0x1,%d0                //check if result is inex
110
        ble     set_finx        //if 0 - 1, it is inexact
111
        cmpib   #0x7,%d0                //second check
112
        ble     no_finx         //if 0 - 7, it is exact
113
        bra     set_finx        //if 8 - f, it is inexact
114
BG_RN:
115
        leal    BIGRN,%a0       //rmode is rn, load BGRN in a0
116
        cmpib   #0x1,%d0                //check if result is inex
117
        ble     set_finx        //if 0 - 1, it is inexact
118
        cmpib   #0x7,%d0                //second check
119
        ble     no_finx         //if 0 - 7, it is exact
120
        bra     set_finx        //if 8 - f, it is inexact
121
BG_RP:
122
        leal    BIGRP,%a0       //rmode is rp, load SMRP in a0
123
        cmpib   #0x1,%d0                //check if result is inex
124
        ble     set_finx        //if 0 - 1, it is inexact
125
        cmpib   #0x7,%d0                //second check
126
        ble     no_finx         //if 0 - 7, it is exact
127
//      bra     set_finx        ;if 8 - f, it is inexact
128
set_finx:
129
        orl     #inx2a_mask,USER_FPSR(%a6) //set inex2/ainex
130
no_finx:
131
        mulul   #12,%d0                 //use offset to point into tables
132
        movel   %d1,L_SCR1(%a6)         //load mode for round call
133
        bfextu  USER_FPCR(%a6){#24:#2},%d1      //get precision
134
        tstl    %d1                     //check if extended precision
135
//
136
// Precision is extended
137
//
138
        bnes    not_ext                 //if extended, do not call round
139
        fmovemx (%a0,%d0),%fp0-%fp0             //return result in fp0
140
        rts
141
//
142
// Precision is single or double
143
//
144
not_ext:
145
        swap    %d1                     //rnd prec in upper word of d1
146
        addl    L_SCR1(%a6),%d1         //merge rmode in low word of d1
147
        movel   (%a0,%d0),FP_SCR1(%a6)  //load first word to temp storage
148
        movel   4(%a0,%d0),FP_SCR1+4(%a6)       //load second word
149
        movel   8(%a0,%d0),FP_SCR1+8(%a6)       //load third word
150
        clrl    %d0                     //clear g,r,s
151
        lea     FP_SCR1(%a6),%a0
152
        btstb   #sign_bit,LOCAL_EX(%a0)
153
        sne     LOCAL_SGN(%a0)          //convert to internal ext. format
154
 
155
        bsr     round                   //go round the mantissa
156
 
157
        bfclr   LOCAL_SGN(%a0){#0:#8}   //convert back to IEEE ext format
158
        beqs    fin_fcr
159
        bsetb   #sign_bit,LOCAL_EX(%a0)
160
fin_fcr:
161
        fmovemx (%a0),%fp0-%fp0
162
        rts
163
 
164
        |end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.