URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [m68k/] [m68040/] [fpsp/] [smovecr.S] - Rev 173
Compare with Previous | Blame | View Log
//// $Id: smovecr.S,v 1.2 2001-09-27 12:01:22 chris Exp $//// smovecr.sa 3.1 12/10/90//// The entry point sMOVECR returns the constant at the// offset given in the instruction field.//// Input: An offset in the instruction word.//// Output: The constant rounded to the user's rounding// mode unchecked for overflow.//// Modified: fp0.////// Copyright (C) Motorola, Inc. 1990// All Rights Reserved//// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA// The copyright notice above does not evidence any// actual or intended publication of such source code.//SMOVECR idnt 2,1 | Motorola 040 Floating Point Software Package|section 8#include "fpsp.defs"|xref nrm_set|xref round|xref PIRN|xref PIRZRM|xref PIRP|xref SMALRN|xref SMALRZRM|xref SMALRP|xref BIGRN|xref BIGRZRM|xref BIGRPFZERO: .long 00000000//// FMOVECR//.global smovcrsmovcr:bfextu CMDREG1B(%a6){#9:#7},%d0 //get offsetbfextu USER_FPCR(%a6){#26:#2},%d1 //get rmode//// check range of offset//tstb %d0 //if zero, offset is to pibeqs PI_TBL //it is picmpib #0x0a,%d0 //check range $01 - $0ables Z_VAL //if in this range, return zerocmpib #0x0e,%d0 //check range $0b - $0ebles SM_TBL //valid constants in this rangecmpib #0x2f,%d0 //check range $10 - $2fbles Z_VAL //if in this range, return zerocmpib #0x3f,%d0 //check range $30 - $3fble BG_TBL //valid constants in this rangeZ_VAL:fmoves FZERO,%fp0rtsPI_TBL:tstb %d1 //offset is zero, check for rmodebeqs PI_RN //if zero, rn modecmpib #0x3,%d1 //check for rpbeqs PI_RP //if 3, rp modePI_RZRM:leal PIRZRM,%a0 //rmode is rz or rm, load PIRZRM in a0bra set_finxPI_RN:leal PIRN,%a0 //rmode is rn, load PIRN in a0bra set_finxPI_RP:leal PIRP,%a0 //rmode is rp, load PIRP in a0bra set_finxSM_TBL:subil #0xb,%d0 //make offset in 0 - 4 rangetstb %d1 //check for rmodebeqs SM_RN //if zero, rn modecmpib #0x3,%d1 //check for rpbeqs SM_RP //if 3, rp modeSM_RZRM:leal SMALRZRM,%a0 //rmode is rz or rm, load SMRZRM in a0cmpib #0x2,%d0 //check if result is inexble set_finx //if 0 - 2, it is inexactbra no_finx //if 3, it is exactSM_RN:leal SMALRN,%a0 //rmode is rn, load SMRN in a0cmpib #0x2,%d0 //check if result is inexble set_finx //if 0 - 2, it is inexactbra no_finx //if 3, it is exactSM_RP:leal SMALRP,%a0 //rmode is rp, load SMRP in a0cmpib #0x2,%d0 //check if result is inexble set_finx //if 0 - 2, it is inexactbra no_finx //if 3, it is exactBG_TBL:subil #0x30,%d0 //make offset in 0 - f rangetstb %d1 //check for rmodebeqs BG_RN //if zero, rn modecmpib #0x3,%d1 //check for rpbeqs BG_RP //if 3, rp modeBG_RZRM:leal BIGRZRM,%a0 //rmode is rz or rm, load BGRZRM in a0cmpib #0x1,%d0 //check if result is inexble set_finx //if 0 - 1, it is inexactcmpib #0x7,%d0 //second checkble no_finx //if 0 - 7, it is exactbra set_finx //if 8 - f, it is inexactBG_RN:leal BIGRN,%a0 //rmode is rn, load BGRN in a0cmpib #0x1,%d0 //check if result is inexble set_finx //if 0 - 1, it is inexactcmpib #0x7,%d0 //second checkble no_finx //if 0 - 7, it is exactbra set_finx //if 8 - f, it is inexactBG_RP:leal BIGRP,%a0 //rmode is rp, load SMRP in a0cmpib #0x1,%d0 //check if result is inexble set_finx //if 0 - 1, it is inexactcmpib #0x7,%d0 //second checkble no_finx //if 0 - 7, it is exact// bra set_finx ;if 8 - f, it is inexactset_finx:orl #inx2a_mask,USER_FPSR(%a6) //set inex2/ainexno_finx:mulul #12,%d0 //use offset to point into tablesmovel %d1,L_SCR1(%a6) //load mode for round callbfextu USER_FPCR(%a6){#24:#2},%d1 //get precisiontstl %d1 //check if extended precision//// Precision is extended//bnes not_ext //if extended, do not call roundfmovemx (%a0,%d0),%fp0-%fp0 //return result in fp0rts//// Precision is single or double//not_ext:swap %d1 //rnd prec in upper word of d1addl L_SCR1(%a6),%d1 //merge rmode in low word of d1movel (%a0,%d0),FP_SCR1(%a6) //load first word to temp storagemovel 4(%a0,%d0),FP_SCR1+4(%a6) //load second wordmovel 8(%a0,%d0),FP_SCR1+8(%a6) //load third wordclrl %d0 //clear g,r,slea FP_SCR1(%a6),%a0btstb #sign_bit,LOCAL_EX(%a0)sne LOCAL_SGN(%a0) //convert to internal ext. formatbsr round //go round the mantissabfclr LOCAL_SGN(%a0){#0:#8} //convert back to IEEE ext formatbeqs fin_fcrbsetb #sign_bit,LOCAL_EX(%a0)fin_fcr:fmovemx (%a0),%fp0-%fp0rts|end
