File indexing completed on 2025-05-11 08:23:49
0001 #include "fpsp-namespace.h"
0002 //
0003 //
0004 // smovecr.sa 3.1 12/10/90
0005 //
0006 // The entry point sMOVECR returns the constant at the
0007 // offset given in the instruction field.
0008 //
0009 // Input: An offset in the instruction word.
0010 //
0011 // Output: The constant rounded to the user's rounding
0012 // mode unchecked for overflow.
0013 //
0014 // Modified: fp0.
0015 //
0016 //
0017 // Copyright (C) Motorola, Inc. 1990
0018 // All Rights Reserved
0019 //
0020 // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
0021 // The copyright notice above does not evidence any
0022 // actual or intended publication of such source code.
0023
0024 //SMOVECR idnt 2,1 | Motorola 040 Floating Point Software Package
0025
0026 |section 8
0027
0028 #include "fpsp.defs"
0029
0030 |xref nrm_set
0031 |xref round
0032 |xref PIRN
0033 |xref PIRZRM
0034 |xref PIRP
0035 |xref SMALRN
0036 |xref SMALRZRM
0037 |xref SMALRP
0038 |xref BIGRN
0039 |xref BIGRZRM
0040 |xref BIGRP
0041
0042 FZERO: .long 00000000
0043 //
0044 // FMOVECR
0045 //
0046 .global smovcr
0047 smovcr:
0048 bfextu CMDREG1B(%a6){#9:#7},%d0 //get offset
0049 bfextu USER_FPCR(%a6){#26:#2},%d1 //get rmode
0050 //
0051 // check range of offset
0052 //
0053 tstb %d0 //if zero, offset is to pi
0054 beqs PI_TBL //it is pi
0055 cmpib #0x0a,%d0 //check range $01 - $0a
0056 bles Z_VAL //if in this range, return zero
0057 cmpib #0x0e,%d0 //check range $0b - $0e
0058 bles SM_TBL //valid constants in this range
0059 cmpib #0x2f,%d0 //check range $10 - $2f
0060 bles Z_VAL //if in this range, return zero
0061 cmpib #0x3f,%d0 //check range $30 - $3f
0062 ble BG_TBL //valid constants in this range
0063 Z_VAL:
0064 fmoves FZERO,%fp0
0065 rts
0066 PI_TBL:
0067 tstb %d1 //offset is zero, check for rmode
0068 beqs PI_RN //if zero, rn mode
0069 cmpib #0x3,%d1 //check for rp
0070 beqs PI_RP //if 3, rp mode
0071 PI_RZRM:
0072 leal PIRZRM,%a0 //rmode is rz or rm, load PIRZRM in a0
0073 bra set_finx
0074 PI_RN:
0075 leal PIRN,%a0 //rmode is rn, load PIRN in a0
0076 bra set_finx
0077 PI_RP:
0078 leal PIRP,%a0 //rmode is rp, load PIRP in a0
0079 bra set_finx
0080 SM_TBL:
0081 subil #0xb,%d0 //make offset in 0 - 4 range
0082 tstb %d1 //check for rmode
0083 beqs SM_RN //if zero, rn mode
0084 cmpib #0x3,%d1 //check for rp
0085 beqs SM_RP //if 3, rp mode
0086 SM_RZRM:
0087 leal SMALRZRM,%a0 //rmode is rz or rm, load SMRZRM in a0
0088 cmpib #0x2,%d0 //check if result is inex
0089 ble set_finx //if 0 - 2, it is inexact
0090 bra no_finx //if 3, it is exact
0091 SM_RN:
0092 leal SMALRN,%a0 //rmode is rn, load SMRN in a0
0093 cmpib #0x2,%d0 //check if result is inex
0094 ble set_finx //if 0 - 2, it is inexact
0095 bra no_finx //if 3, it is exact
0096 SM_RP:
0097 leal SMALRP,%a0 //rmode is rp, load SMRP in a0
0098 cmpib #0x2,%d0 //check if result is inex
0099 ble set_finx //if 0 - 2, it is inexact
0100 bra no_finx //if 3, it is exact
0101 BG_TBL:
0102 subil #0x30,%d0 //make offset in 0 - f range
0103 tstb %d1 //check for rmode
0104 beqs BG_RN //if zero, rn mode
0105 cmpib #0x3,%d1 //check for rp
0106 beqs BG_RP //if 3, rp mode
0107 BG_RZRM:
0108 leal BIGRZRM,%a0 //rmode is rz or rm, load BGRZRM in a0
0109 cmpib #0x1,%d0 //check if result is inex
0110 ble set_finx //if 0 - 1, it is inexact
0111 cmpib #0x7,%d0 //second check
0112 ble no_finx //if 0 - 7, it is exact
0113 bra set_finx //if 8 - f, it is inexact
0114 BG_RN:
0115 leal BIGRN,%a0 //rmode is rn, load BGRN in a0
0116 cmpib #0x1,%d0 //check if result is inex
0117 ble set_finx //if 0 - 1, it is inexact
0118 cmpib #0x7,%d0 //second check
0119 ble no_finx //if 0 - 7, it is exact
0120 bra set_finx //if 8 - f, it is inexact
0121 BG_RP:
0122 leal BIGRP,%a0 //rmode is rp, load SMRP in a0
0123 cmpib #0x1,%d0 //check if result is inex
0124 ble set_finx //if 0 - 1, it is inexact
0125 cmpib #0x7,%d0 //second check
0126 ble no_finx //if 0 - 7, it is exact
0127 // bra set_finx ;if 8 - f, it is inexact
0128 set_finx:
0129 orl #inx2a_mask,USER_FPSR(%a6) //set inex2/ainex
0130 no_finx:
0131 mulul #12,%d0 //use offset to point into tables
0132 movel %d1,L_SCR1(%a6) //load mode for round call
0133 bfextu USER_FPCR(%a6){#24:#2},%d1 //get precision
0134 tstl %d1 //check if extended precision
0135 //
0136 // Precision is extended
0137 //
0138 bnes not_ext //if extended, do not call round
0139 fmovemx (%a0,%d0),%fp0-%fp0 //return result in fp0
0140 rts
0141 //
0142 // Precision is single or double
0143 //
0144 not_ext:
0145 swap %d1 //rnd prec in upper word of d1
0146 addl L_SCR1(%a6),%d1 //merge rmode in low word of d1
0147 movel (%a0,%d0),FP_SCR1(%a6) //load first word to temp storage
0148 movel 4(%a0,%d0),FP_SCR1+4(%a6) //load second word
0149 movel 8(%a0,%d0),FP_SCR1+8(%a6) //load third word
0150 clrl %d0 //clear g,r,s
0151 lea FP_SCR1(%a6),%a0
0152 btstb #sign_bit,LOCAL_EX(%a0)
0153 sne LOCAL_SGN(%a0) //convert to internal ext. format
0154
0155 bsr round //go round the mantissa
0156
0157 bfclr LOCAL_SGN(%a0){#0:#8} //convert back to IEEE ext format
0158 beqs fin_fcr
0159 bsetb #sign_bit,LOCAL_EX(%a0)
0160 fin_fcr:
0161 fmovemx (%a0),%fp0-%fp0
0162 rts
0163
0164 |end