[BACK]Return to rshift.asm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpn / m68k

Annotation of OpenXM_contrib/gmp/mpn/m68k/rshift.asm, Revision 1.1.1.1

1.1       ohara       1: dnl  mc68020 mpn_rshift -- mpn right shift.
                      2: dnl
                      3: dnl            cycles/limb
                      4: dnl         shift==1  shift>1
                      5: dnl  68040:    7.0      9.5
                      6:
                      7: dnl  Copyright 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
                      8: dnl
                      9: dnl  This file is part of the GNU MP Library.
                     10: dnl
                     11: dnl  The GNU MP Library is free software; you can redistribute it and/or
                     12: dnl  modify it under the terms of the GNU Lesser General Public License as
                     13: dnl  published by the Free Software Foundation; either version 2.1 of the
                     14: dnl  License, or (at your option) any later version.
                     15: dnl
                     16: dnl  The GNU MP Library is distributed in the hope that it will be useful,
                     17: dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18: dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     19: dnl  Lesser General Public License for more details.
                     20: dnl
                     21: dnl  You should have received a copy of the GNU Lesser General Public
                     22: dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
                     23: dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
                     24: dnl  Suite 330, Boston, MA 02111-1307, USA.
                     25:
                     26: include(`../config.m4')
                     27:
                     28:
                     29: C INPUT PARAMETERS
                     30: C res_ptr      (sp + 4)
                     31: C s_ptr                (sp + 8)
                     32: C s_size       (sp + 16)
                     33: C cnt          (sp + 12)
                     34:
                     35: define(res_ptr, `a1')
                     36: define(s_ptr,   `a0')
                     37: define(s_size,  `d6')
                     38: define(cnt,     `d4')
                     39:
                     40: PROLOGUE(mpn_rshift)
                     41: C Save used registers on the stack.
                     42:        moveml  d2-d6/a2, M(-,sp)
                     43:
                     44: C Copy the arguments to registers.
                     45:        movel   M(sp,28), res_ptr
                     46:        movel   M(sp,32), s_ptr
                     47:        movel   M(sp,36), s_size
                     48:        movel   M(sp,40), cnt
                     49:
                     50:        moveql  #1, d5
                     51:        cmpl    d5, cnt
                     52:        bne     L(Lnormal)
                     53:        cmpl    res_ptr, s_ptr
                     54:        bls     L(Lspecial)             C jump if res_ptr >= s_ptr
                     55:
                     56: ifelse(scale_available_p,1,`
                     57:        lea     M(res_ptr,s_size,l,4), a2
                     58: ',`
                     59:        movel   s_size, d0
                     60:        asll    #2, d0
                     61:        lea     M(res_ptr,d0,l), a2
                     62: ')
                     63:        cmpl    s_ptr, a2
                     64:        bls     L(Lspecial)             C jump if s_ptr >= res_ptr + s_size
                     65:
                     66: L(Lnormal:)
                     67:        moveql  #32, d5
                     68:        subl    cnt, d5
                     69:        movel   M(s_ptr,+), d2
                     70:        movel   d2, d0
                     71:        lsll    d5, d0          C compute carry limb
                     72:
                     73:        lsrl    cnt, d2
                     74:        movel   d2, d1
                     75:        subql   #1, s_size
                     76:        beq     L(Lend)
                     77:        lsrl    #1, s_size
                     78:        bcs     L(L1)
                     79:        subql   #1, s_size
                     80:
                     81: L(Loop:)
                     82:        movel   M(s_ptr,+), d2
                     83:        movel   d2, d3
                     84:        lsll    d5, d3
                     85:        orl     d3, d1
                     86:        movel   d1, M(res_ptr,+)
                     87:        lsrl    cnt, d2
                     88: L(L1:)
                     89:        movel   M(s_ptr,+), d1
                     90:        movel   d1, d3
                     91:        lsll    d5, d3
                     92:        orl     d3, d2
                     93:        movel   d2, M(res_ptr,+)
                     94:        lsrl    cnt, d1
                     95:
                     96:        dbf     s_size, L(Loop)
                     97:        subl    #0x10000, s_size
                     98:        bcc     L(Loop)
                     99:
                    100: L(Lend:)
                    101:        movel   d1, M(res_ptr)  C store most significant limb
                    102:
                    103: C Restore used registers from stack frame.
                    104:        moveml  M(sp,+), d2-d6/a2
                    105:        rts
                    106:
                    107: C We loop from most significant end of the arrays, which is only permissable
                    108: C if the source and destination don't overlap, since the function is
                    109: C documented to work for overlapping source and destination.
                    110:
                    111: L(Lspecial:)
                    112: ifelse(scale_available_p,1,`
                    113:        lea     M(s_ptr,s_size,l,4), s_ptr
                    114:        lea     M(res_ptr,s_size,l,4), res_ptr
                    115: ',`
                    116:        movel   s_size, d0
                    117:        asll    #2, d0
                    118:        addl    d0, s_ptr
                    119:        addl    d0, res_ptr
                    120: ')
                    121:
                    122:        clrl    d0                      C initialize carry
                    123:        eorw    #1, s_size
                    124:        lsrl    #1, s_size
                    125:        bcc     L(LL1)
                    126:        subql   #1, s_size
                    127:
                    128: L(LLoop:)
                    129:        movel   M(-,s_ptr), d2
                    130:        roxrl   #1, d2
                    131:        movel   d2, M(-,res_ptr)
                    132: L(LL1:)
                    133:        movel   M(-,s_ptr), d2
                    134:        roxrl   #1, d2
                    135:        movel   d2, M(-,res_ptr)
                    136:
                    137:        dbf     s_size, L(LLoop)
                    138:        roxrl   #1, d0          C save cy in msb
                    139:        subl    #0x10000, s_size
                    140:        bcs     L(LLend)
                    141:        addl    d0, d0          C restore cy
                    142:        bra     L(LLoop)
                    143:
                    144: L(LLend:)
                    145: C Restore used registers from stack frame.
                    146:        moveml  M(sp,+), d2-d6/a2
                    147:        rts
                    148:
                    149: EPILOGUE(mpn_rshift)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>