Back to home page

OSCL-LXR

 
 

    


0001  # Alpha 21064 __udiv_qrnnd
0002  # Copyright (C) 1992, 1994, 1995, 2000 Free Software Foundation, Inc.
0003 
0004  # This file is part of GCC.
0005 
0006  # The GNU MP Library is free software; you can redistribute it and/or modify
0007  # it under the terms of the GNU General Public License as published by
0008  # the Free Software Foundation; either version 2 of the License, or (at your
0009  # option) any later version.
0010 
0011  # In addition to the permissions in the GNU General Public License, the
0012  # Free Software Foundation gives you unlimited permission to link the
0013  # compiled version of this file with other programs, and to distribute
0014  # those programs without any restriction coming from the use of this
0015  # file.  (The General Public License restrictions do apply in other
0016  # respects; for example, they cover modification of the file, and
0017  # distribution when not linked into another program.)
0018 
0019  # This file is distributed in the hope that it will be useful, but
0020  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0021  # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0022  # License for more details.
0023 
0024  # You should have received a copy of the GNU General Public License
0025  # along with GCC; see the file COPYING.  If not, write to the 
0026  # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
0027  # MA 02111-1307, USA.
0028 #include <asm/export.h>
0029 
0030         .set noreorder
0031         .set noat
0032 
0033     .text
0034 
0035     .globl __udiv_qrnnd
0036     .ent __udiv_qrnnd
0037 __udiv_qrnnd:
0038     .frame $30,0,$26,0
0039     .prologue 0
0040 
0041 #define cnt $2
0042 #define tmp $3
0043 #define rem_ptr $16
0044 #define n1  $17
0045 #define n0  $18
0046 #define d   $19
0047 #define qb  $20
0048 #define AT  $at
0049 
0050     ldiq    cnt,16
0051     blt d,$largedivisor
0052 
0053 $loop1: cmplt   n0,0,tmp
0054     addq    n1,n1,n1
0055     bis n1,tmp,n1
0056     addq    n0,n0,n0
0057     cmpule  d,n1,qb
0058     subq    n1,d,tmp
0059     cmovne  qb,tmp,n1
0060     bis n0,qb,n0
0061     cmplt   n0,0,tmp
0062     addq    n1,n1,n1
0063     bis n1,tmp,n1
0064     addq    n0,n0,n0
0065     cmpule  d,n1,qb
0066     subq    n1,d,tmp
0067     cmovne  qb,tmp,n1
0068     bis n0,qb,n0
0069     cmplt   n0,0,tmp
0070     addq    n1,n1,n1
0071     bis n1,tmp,n1
0072     addq    n0,n0,n0
0073     cmpule  d,n1,qb
0074     subq    n1,d,tmp
0075     cmovne  qb,tmp,n1
0076     bis n0,qb,n0
0077     cmplt   n0,0,tmp
0078     addq    n1,n1,n1
0079     bis n1,tmp,n1
0080     addq    n0,n0,n0
0081     cmpule  d,n1,qb
0082     subq    n1,d,tmp
0083     cmovne  qb,tmp,n1
0084     bis n0,qb,n0
0085     subq    cnt,1,cnt
0086     bgt cnt,$loop1
0087     stq n1,0(rem_ptr)
0088     bis $31,n0,$0
0089     ret $31,($26),1
0090 
0091 $largedivisor:
0092     and n0,1,$4
0093 
0094     srl n0,1,n0
0095     sll n1,63,tmp
0096     or  tmp,n0,n0
0097     srl n1,1,n1
0098 
0099     and d,1,$6
0100     srl d,1,$5
0101     addq    $5,$6,$5
0102 
0103 $loop2: cmplt   n0,0,tmp
0104     addq    n1,n1,n1
0105     bis n1,tmp,n1
0106     addq    n0,n0,n0
0107     cmpule  $5,n1,qb
0108     subq    n1,$5,tmp
0109     cmovne  qb,tmp,n1
0110     bis n0,qb,n0
0111     cmplt   n0,0,tmp
0112     addq    n1,n1,n1
0113     bis n1,tmp,n1
0114     addq    n0,n0,n0
0115     cmpule  $5,n1,qb
0116     subq    n1,$5,tmp
0117     cmovne  qb,tmp,n1
0118     bis n0,qb,n0
0119     cmplt   n0,0,tmp
0120     addq    n1,n1,n1
0121     bis n1,tmp,n1
0122     addq    n0,n0,n0
0123     cmpule  $5,n1,qb
0124     subq    n1,$5,tmp
0125     cmovne  qb,tmp,n1
0126     bis n0,qb,n0
0127     cmplt   n0,0,tmp
0128     addq    n1,n1,n1
0129     bis n1,tmp,n1
0130     addq    n0,n0,n0
0131     cmpule  $5,n1,qb
0132     subq    n1,$5,tmp
0133     cmovne  qb,tmp,n1
0134     bis n0,qb,n0
0135     subq    cnt,1,cnt
0136     bgt cnt,$loop2
0137 
0138     addq    n1,n1,n1
0139     addq    $4,n1,n1
0140     bne $6,$Odd
0141     stq n1,0(rem_ptr)
0142     bis $31,n0,$0
0143     ret $31,($26),1
0144 
0145 $Odd:
0146     /* q' in n0. r' in n1 */
0147     addq    n1,n0,n1
0148 
0149     cmpult  n1,n0,tmp   # tmp := carry from addq
0150     subq    n1,d,AT
0151     addq    n0,tmp,n0
0152     cmovne  tmp,AT,n1
0153 
0154     cmpult  n1,d,tmp
0155     addq    n0,1,AT
0156     cmoveq  tmp,AT,n0
0157     subq    n1,d,AT
0158     cmoveq  tmp,AT,n1
0159 
0160     stq n1,0(rem_ptr)
0161     bis $31,n0,$0
0162     ret $31,($26),1
0163 
0164     .end    __udiv_qrnnd
0165 EXPORT_SYMBOL(__udiv_qrnnd)