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

Annotation of OpenXM_contrib/gmp/mpn/arm/udiv.asm, Revision 1.1

1.1     ! ohara       1: dnl  ARM mpn_udiv_qrnnd -- divide a two limb dividend and a one limb divisor.
        !             2: dnl  Return quotient and store remainder through a supplied pointer.
        !             3:
        !             4: dnl  Copyright 2001 Free Software Foundation, Inc.
        !             5:
        !             6: dnl  This file is part of the GNU MP Library.
        !             7:
        !             8: dnl  The GNU MP Library is free software; you can redistribute it and/or modify
        !             9: dnl  it under the terms of the GNU Lesser General Public License as published
        !            10: dnl  by the Free Software Foundation; either version 2.1 of the License, or (at
        !            11: dnl  your option) any later version.
        !            12:
        !            13: dnl  The GNU MP Library is distributed in the hope that it will be useful, but
        !            14: dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            15: dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
        !            16: dnl  License for more details.
        !            17:
        !            18: dnl  You should have received a copy of the GNU Lesser General Public License
        !            19: dnl  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
        !            20: dnl  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
        !            21: dnl  MA 02111-1307, USA.
        !            22:
        !            23: include(`../config.m4')
        !            24:
        !            25: C INPUT PARAMETERS
        !            26: define(`rem_ptr',`r0')
        !            27: define(`n1',`r1')
        !            28: define(`n0',`r2')
        !            29: define(`d',`r3')
        !            30:
        !            31: C divstep -- develop one quotient bit.  Dividend in $1$2, divisor in $3.
        !            32: C Quotient bit is shifted into $2.
        !            33: define(`divstep',
        !            34:        `adcs   $2, $2, $2
        !            35:        adc     $1, $1, $1
        !            36:        cmp     $1, $3
        !            37:        subcs   $1, $1, $3')
        !            38:
        !            39: ASM_START()
        !            40: PROLOGUE(mpn_udiv_qrnnd)
        !            41:        mov     r12, #8                 C loop counter for both loops below
        !            42:        cmp     d, #0x80000000          C check divisor msb and clear carry
        !            43:        bcs     L(_large_divisor)
        !            44:
        !            45: L(oop):        divstep(n1,n0,d)
        !            46:        divstep(n1,n0,d)
        !            47:        divstep(n1,n0,d)
        !            48:        divstep(n1,n0,d)
        !            49:        sub     r12, r12, #1
        !            50:        teq     r12, #0
        !            51:        bne     L(oop)
        !            52:
        !            53:        str     n1, [ rem_ptr ]         C store remainder
        !            54:        adc     r0, n0, n0              C quotient: add last carry from divstep
        !            55:        mov     pc, lr
        !            56:
        !            57: L(_large_divisor):
        !            58:        stmfd   sp!, { r8, lr }
        !            59:
        !            60:        and     r8, n0, #1              C save lsb of dividend
        !            61:        mov     lr, n1, lsl #31
        !            62:        orrs    n0, lr, n0, lsr #1      C n0 = lo(n1n0 >> 1)
        !            63:        mov     n1, n1, lsr #1          C n1 = hi(n1n0 >> 1)
        !            64:
        !            65:        and     lr, d, #1               C save lsb of divisor
        !            66:        movs    d, d, lsr #1            C d = floor(orig_d / 2)
        !            67:        adc     d, d, #0                C d = ceil(orig_d / 2)
        !            68:
        !            69: L(oop2):
        !            70:        divstep(n1,n0,d)
        !            71:        divstep(n1,n0,d)
        !            72:        divstep(n1,n0,d)
        !            73:        divstep(n1,n0,d)
        !            74:        sub     r12, r12, #1
        !            75:        teq     r12, #0
        !            76:        bne     L(oop2)
        !            77:
        !            78:        adc     n0, n0, n0              C shift and add last carry from divstep
        !            79:        add     n1, r8, n1, lsl #1      C shift in omitted dividend lsb
        !            80:        tst     lr, lr                  C test saved divisor lsb
        !            81:        beq     L(_even_divisor)
        !            82:
        !            83:        rsb     d, lr, d, lsl #1        C restore orig d value
        !            84:        adds    n1, n1, n0              C fix remainder for omitted divisor lsb
        !            85:        addcs   n0, n0, #1              C adjust quotient if rem. fix carried
        !            86:        subcs   n1, n1, d               C adjust remainder accordingly
        !            87:        cmp     n1, d                   C remainder >= divisor?
        !            88:        subcs   n1, n1, d               C adjust remainder
        !            89:        addcs   n0, n0, #1              C adjust quotient
        !            90:
        !            91: L(_even_divisor):
        !            92:        str     n1, [ rem_ptr ]         C store remainder
        !            93:        mov     r0, n0                  C quotient
        !            94:        ldmfd   sp!, { r8, pc }
        !            95: EPILOGUE(mpn_udiv_qrnnd)

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