URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [lib/] [libcpu/] [m68k/] [m68040/] [fpsp/] [x_store.S] - Rev 158
Go to most recent revision | Compare with Previous | Blame | View Log
//// $Id: x_store.S,v 1.1.1.1 2001-07-10 09:56:17 chris Exp $//// x_store.sa 3.2 1/24/91//// store --- store operand to memory or register//// Used by underflow and overflow handlers.//// a6 = points to fp value to be stored.//// 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.X_STORE: //idnt 2,1 | Motorola 040 Floating Point Software Package|section 8fpreg_mask:.byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01#include "fpsp.defs"|xref mem_write|xref get_fline|xref g_opcls|xref g_dfmtou|xref reg_dest.global dest_ext.global dest_dbl.global dest_sgl.global storestore:btstb #E3,E_BYTE(%a6)beqs E1_stoE3_sto:movel CMDREG3B(%a6),%d0bfextu %d0{#6:#3},%d0 //isolate dest. reg from cmdreg3bsto_fp:lea fpreg_mask,%a1moveb (%a1,%d0.w),%d0 //convert reg# to dynamic register masktstb LOCAL_SGN(%a0)beqs is_posbsetb #sign_bit,LOCAL_EX(%a0)is_pos:fmovemx (%a0),%d0 //move to correct register//// if fp0-fp3 is being modified, we must put a copy// in the USER_FPn variable on the stack because all exception// handlers restore fp0-fp3 from there.//cmpb #0x80,%d0bnes not_fp0fmovemx %fp0-%fp0,USER_FP0(%a6)rtsnot_fp0:cmpb #0x40,%d0bnes not_fp1fmovemx %fp1-%fp1,USER_FP1(%a6)rtsnot_fp1:cmpb #0x20,%d0bnes not_fp2fmovemx %fp2-%fp2,USER_FP2(%a6)rtsnot_fp2:cmpb #0x10,%d0bnes not_fp3fmovemx %fp3-%fp3,USER_FP3(%a6)rtsnot_fp3:rtsE1_sto:bsrl g_opcls //returns opclass in d0cmpib #3,%d0beq opc011 //branch if opclass 3movel CMDREG1B(%a6),%d0bfextu %d0{#6:#3},%d0 //extract destination registerbras sto_fpopc011:bsrl g_dfmtou //returns dest format in d0// ;ext=00, sgl=01, dbl=10movel %a0,%a1 //save source addr in a1movel EXC_EA(%a6),%a0 //get the addresscmpil #0,%d0 //if dest format is extendedbeq dest_ext //then branchcmpil #1,%d0 //if dest format is singlebeq dest_sgl //then branch//// fall through to dest_dbl////// dest_dbl --- write double precision value to user space////Input// a0 -> destination address// a1 -> source in extended precision//Output// a0 -> destroyed// a1 -> destroyed// d0 -> 0////Changes extended precision to double precision.// Note: no attempt is made to round the extended value to double.// dbl_sign = ext_sign// dbl_exp = ext_exp - $3fff(ext bias) + $7ff(dbl bias)// get rid of ext integer bit// dbl_mant = ext_mant{62:12}//// --------------- --------------- ---------------// extended -> |s| exp | |1| ms mant | | ls mant |// --------------- --------------- ---------------// 95 64 63 62 32 31 11 0// | |// | |// | |// v v// --------------- ---------------// double -> |s|exp| mant | | mant |// --------------- ---------------// 63 51 32 31 0//dest_dbl:clrl %d0 //clear d0movew LOCAL_EX(%a1),%d0 //get exponentsubw #0x3fff,%d0 //subtract extended precision biascmpw #0x4000,%d0 //check if infbeqs inf //if so, special caseaddw #0x3ff,%d0 //add double precision biasswap %d0 //d0 now in upper wordlsll #4,%d0 //d0 now in proper place for dbl prec exptstb LOCAL_SGN(%a1)beqs get_mant //if positive, go process mantissabsetl #31,%d0 //if negative, put in sign information// ; before continuingbras get_mant //go process mantissainf:movel #0x7ff00000,%d0 //load dbl inf exponentclrl LOCAL_HI(%a1) //clear msbtstb LOCAL_SGN(%a1)beqs dbl_inf //if positive, go ahead and write itbsetl #31,%d0 //if negative put in sign informationdbl_inf:movel %d0,LOCAL_EX(%a1) //put the new exp back on the stackbras dbl_wrtget_mant:movel LOCAL_HI(%a1),%d1 //get ms mantissabfextu %d1{#1:#20},%d1 //get upper 20 bits of msorl %d1,%d0 //put these bits in ms word of doublemovel %d0,LOCAL_EX(%a1) //put the new exp back on the stackmovel LOCAL_HI(%a1),%d1 //get ms mantissamovel #21,%d0 //load shift countlsll %d0,%d1 //put lower 11 bits in upper bitsmovel %d1,LOCAL_HI(%a1) //build lower lword in memorymovel LOCAL_LO(%a1),%d1 //get ls mantissabfextu %d1{#0:#21},%d0 //get ls 21 bits of doubleorl %d0,LOCAL_HI(%a1) //put them in double resultdbl_wrt:movel #0x8,%d0 //byte count for double precision numberexg %a0,%a1 //a0=supervisor source, a1=user destbsrl mem_write //move the number to the user's memoryrts//// dest_sgl --- write single precision value to user space////Input// a0 -> destination address// a1 -> source in extended precision////Output// a0 -> destroyed// a1 -> destroyed// d0 -> 0////Changes extended precision to single precision.// sgl_sign = ext_sign// sgl_exp = ext_exp - $3fff(ext bias) + $7f(sgl bias)// get rid of ext integer bit// sgl_mant = ext_mant{62:12}//// --------------- --------------- ---------------// extended -> |s| exp | |1| ms mant | | ls mant |// --------------- --------------- ---------------// 95 64 63 62 40 32 31 12 0// | |// | |// | |// v v// ---------------// single -> |s|exp| mant |// ---------------// 31 22 0//dest_sgl:clrl %d0movew LOCAL_EX(%a1),%d0 //get exponentsubw #0x3fff,%d0 //subtract extended precision biascmpw #0x4000,%d0 //check if infbeqs sinf //if so, special caseaddw #0x7f,%d0 //add single precision biasswap %d0 //put exp in upper word of d0lsll #7,%d0 //shift it into single exp bitststb LOCAL_SGN(%a1)beqs get_sman //if positive, continuebsetl #31,%d0 //if negative, put in sign firstbras get_sman //get mantissasinf:movel #0x7f800000,%d0 //load single inf exp to d0tstb LOCAL_SGN(%a1)beqs sgl_wrt //if positive, continuebsetl #31,%d0 //if negative, put in sign infobras sgl_wrtget_sman:movel LOCAL_HI(%a1),%d1 //get ms mantissabfextu %d1{#1:#23},%d1 //get upper 23 bits of msorl %d1,%d0 //put these bits in ms word of singlesgl_wrt:movel %d0,L_SCR1(%a6) //put the new exp back on the stackmovel #0x4,%d0 //byte count for single precision numbertstl %a0 //users destination addressbeqs sgl_Dn //destination is a data registerexg %a0,%a1 //a0=supervisor source, a1=user destleal L_SCR1(%a6),%a0 //point a0 to databsrl mem_write //move the number to the user's memoryrtssgl_Dn:bsrl get_fline //returns fline word in d0andw #0x7,%d0 //isolate register numbermovel %d0,%d1 //d1 has size:reg formatted for reg_destorl #0x10,%d1 //reg_dest wants size added to reg#bral reg_dest //size is X, rts in reg_dest will// ;return to caller of dest_sgldest_ext:tstb LOCAL_SGN(%a1) //put back sign into exponent wordbeqs dstx_contbsetb #sign_bit,LOCAL_EX(%a1)dstx_cont:clrb LOCAL_SGN(%a1) //clear out the sign bytemovel #0x0c,%d0 //byte count for extended numberexg %a0,%a1 //a0=supervisor source, a1=user destbsrl mem_write //move the number to the user's memoryrts|end
Go to most recent revision | Compare with Previous | Blame | View Log
