📄 ppc_ftod.s
字号:
/* fpopt/ppc_ftod.S, pl_FPE_common, pl_linux 11/24/03 16:17:39 */
/*----------------------------------------------------------------------------- */
/* Copyright (c) 2003, IBM Corporation */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* * Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* * Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* * Neither the name of IBM nor the names of its contributors */
/* may be used to endorse or promote products derived from this */
/* software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, */
/* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */
/* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE */
/* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------- */
/* */
/* Function: convert single floating point to double */
/* Input: r3 */
/* Output: r3,r4 */
/* Notes: 1. No stack frame is created for this function, so the following */
/* registers must be preserved, as required by ABI specification: */
/* LR, CR0, R1, R2, R13-R31 */
/* 2. operation performed according to IEEE754-1985 standard. */
/* */
/*----------------------------------------------------------------------------- */
#include <ppc4xx.inc>
#include "fpeLib.inc"
function_prolog(__extendsfdf2)
mfcr r0 /* Use r0 to save CR */
/* Take single apart */
rlwinm. r8,r3,9,0xFF /* extract exponent (and set CR0) */
addi r9,r8,-1 /* make zero look like high value */
cmpli cr1,r9,0xFE /* r9 >= FE means zero/denorm/INF/NaN */
addi r9,r8,896 /* +1023 - 127 */
rlwinm r4,r3,29,0xE0000000 /* fill lower word with 3 lsb's of orig */
srawi r11,r3,3 /* position sign and fraction for DP */
bge cr1,unusual /* not a standard normalized number */
insert_exp:
rlwimi r11,r9,20,0x7FF00000 /* insert biased exponent */
do_store:
mr r3,r11 /* move first word */
/* second word already in r4 */
mtcr r0 /* restore condition register */
blr
/* */
INF_NaN:
oris r11,r11,0x7FF0 /* mark as INF/NaN */
rlwinm. r9,r3,0,0x007fffff /* if NaN, */
beq cr0,do_store
oris r11,r11,0x0008 /* make into QNaN */
b do_store /* and otherwise same as norm */
/* */
/* here we have a INF or NaN, or else a zero or denorm */
/* */
unusual:
bne INF_NaN /* if original exp not zero, then INF.. */
/* */
/* zero or denorm. */
/* */
rlwinm. r10,r3,0,0x7FFFFFFF /* clear sign. */
cntlzw r5,r10 /* get location of first bit */
ori r11,r3,0 /* just copy input (assume a zero) */
beq do_store /* input is a zero - r4 already set */
/* (assume that this branch is "free") */
/* */
/* here for a denorm */
/* note that this path is penalized, but zeros are considered to be much */
/* more common, and the zero argument path has been optimized */
/* */
addi r7,r5,-11 /* get rotate amount */
/* Note that the fraction is "pulled up" to its final position in the resulting */
/* double */
rlwnm r11,r10,r7,0x000FFFFF /* insert fraction (leading bit in bit 11) */
rlwnm r4,r10,r7,0xE0000000 /* low order bits to r4 */
/* The -3 is because the shift count is 3 less than the true value because */
/* the fractions are in different positions in the source single and target */
/* double. */
subfic r9,r7,897-3 /* compute biased exp */
rlwimi r11,r3,0,0x80000000 /* insert sign bit (Arrgh!) */
b insert_exp
function_epilog(__extendsfdf2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -