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

Annotation of OpenXM_contrib/gmp/mpn/x86/diveby3.asm, Revision 1.1.1.2

1.1       maekawa     1: dnl  x86 mpn_divexact_by3 -- mpn division by 3, expecting no remainder.
                      2:
1.1.1.2 ! ohara       3: dnl  Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
1.1       maekawa     4: dnl
                      5: dnl  This file is part of the GNU MP Library.
                      6: dnl
                      7: dnl  The GNU MP Library is free software; you can redistribute it and/or
                      8: dnl  modify it under the terms of the GNU Lesser General Public License as
                      9: dnl  published by the Free Software Foundation; either version 2.1 of the
                     10: dnl  License, or (at your option) any later version.
                     11: dnl
                     12: dnl  The GNU MP Library is distributed in the hope that it will be useful,
                     13: dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14: dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     15: dnl  Lesser General Public License for more details.
                     16: dnl
                     17: dnl  You should have received a copy of the GNU Lesser General Public
                     18: dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
                     19: dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
                     20: dnl  Suite 330, Boston, MA 02111-1307, USA.
                     21:
1.1.1.2 ! ohara      22: include(`../config.m4')
1.1       maekawa    23:
                     24:
1.1.1.2 ! ohara      25: C      cycles/limb
        !            26: C P54     18.0
        !            27: C P55     17.0
        !            28: C P6      14.0
        !            29: C K6      14.0
        !            30: C K7      10.0
        !            31: C P4      24.0
1.1       maekawa    32:
                     33:
                     34: C mp_limb_t mpn_divexact_by3c (mp_ptr dst, mp_srcptr src, mp_size_t size,
                     35: C                              mp_limb_t carry);
                     36:
                     37: defframe(PARAM_CARRY,16)
                     38: defframe(PARAM_SIZE, 12)
                     39: defframe(PARAM_SRC,   8)
                     40: defframe(PARAM_DST,   4)
                     41:
                     42: dnl  multiplicative inverse of 3, modulo 2^32
                     43: deflit(INVERSE_3,       0xAAAAAAAB)
                     44:
                     45: dnl  ceil(b/3) and ceil(b*2/3) where b=2^32
                     46: deflit(ONE_THIRD_CEIL,  0x55555556)
                     47: deflit(TWO_THIRDS_CEIL, 0xAAAAAAAB)
                     48:
1.1.1.2 ! ohara      49:        TEXT
1.1       maekawa    50:        ALIGN(8)
                     51:
                     52: PROLOGUE(mpn_divexact_by3c)
                     53: deflit(`FRAME',0)
                     54:
                     55:        movl    PARAM_SRC, %ecx
                     56:        pushl   %ebp            FRAME_pushl()
                     57:
                     58:        movl    PARAM_SIZE, %ebp
                     59:        pushl   %edi            FRAME_pushl()
                     60:
                     61:        movl    PARAM_DST, %edi
                     62:        pushl   %esi            FRAME_pushl()
                     63:
                     64:        movl    $INVERSE_3, %esi
                     65:        pushl   %ebx            FRAME_pushl()
                     66:
                     67:        leal    (%ecx,%ebp,4), %ecx
                     68:        movl    PARAM_CARRY, %ebx
                     69:
                     70:        leal    (%edi,%ebp,4), %edi
                     71:        negl    %ebp
                     72:
                     73:
                     74:        ALIGN(8)
                     75: L(top):
                     76:        C eax   scratch, low product
                     77:        C ebx   carry limb (0 to 3)
                     78:        C ecx   &src[size]
                     79:        C edx   scratch, high product
                     80:        C esi   multiplier
                     81:        C edi   &dst[size]
                     82:        C ebp   counter, limbs, negative
                     83:
                     84:        movl    (%ecx,%ebp,4), %eax
                     85:
                     86:        subl    %ebx, %eax
                     87:
                     88:        setc    %bl
                     89:
                     90:        imull   %esi
                     91:
                     92:        cmpl    $ONE_THIRD_CEIL, %eax
                     93:        movl    %eax, (%edi,%ebp,4)
                     94:
                     95:        sbbl    $-1, %ebx       C +1 if eax>=ceil(b/3)
                     96:        cmpl    $TWO_THIRDS_CEIL, %eax
                     97:
                     98:        sbbl    $-1, %ebx       C +1 if eax>=ceil(b*2/3)
                     99:        incl    %ebp
                    100:
                    101:        jnz     L(top)
                    102:
                    103:
                    104:        movl    %ebx, %eax
                    105:        popl    %ebx
                    106:        popl    %esi
                    107:        popl    %edi
                    108:        popl    %ebp
                    109:        ret
                    110:
                    111: EPILOGUE()

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