source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/smovecr.s @ f9b93da

4.104.114.84.95
Last change on this file since f9b93da was f9b93da, checked in by Joel Sherrill <joel.sherrill@…>, on 04/16/97 at 17:33:04

Added the MC68040 Floating Point Support Package. This was ported
to RTEMS by Eric Norum. It is freely distributable and was acquired
from the Motorola WWW site. More info is in the FPSP README.

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