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

Annotation of OpenXM_contrib/gmp/mpn/x86/pentium4/sse2/sub_n.asm, Revision 1.1

1.1     ! ohara       1: dnl  Intel Pentium-4 mpn_sub_n -- mpn subtraction.
        !             2:
        !             3: dnl  Copyright 2001, 2002 Free Software Foundation, Inc.
        !             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:
        !            22: include(`../config.m4')
        !            23:
        !            24:
        !            25: C P4: 4.0 cycles/limb if dst!=src1 and dst!=src2
        !            26: C     6.0 cycles/limb if dst==src1 or dst==src2
        !            27:
        !            28:
        !            29: C mp_limb_t mpn_sub_n (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
        !            30: C                      mp_size_t size);
        !            31: C mp_limb_t mpn_sub_nc (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
        !            32: C                       mp_size_t size, mp_limb_t carry);
        !            33: C
        !            34: C The main loop code is 2x unrolled so that the carry bit can alternate
        !            35: C between mm0 and mm1.
        !            36:
        !            37: defframe(PARAM_CARRY,20)
        !            38: defframe(PARAM_SIZE, 16)
        !            39: defframe(PARAM_SRC2, 12)
        !            40: defframe(PARAM_SRC1, 8)
        !            41: defframe(PARAM_DST,  4)
        !            42:
        !            43: dnl  re-use parameter space
        !            44: define(SAVE_EBX,`PARAM_SRC1')
        !            45:
        !            46:        TEXT
        !            47:        ALIGN(8)
        !            48:
        !            49: PROLOGUE(mpn_sub_nc)
        !            50: deflit(`FRAME',0)
        !            51:
        !            52:        movd    PARAM_CARRY, %mm0
        !            53:        jmp     L(start_nc)
        !            54:
        !            55: EPILOGUE()
        !            56:
        !            57:        ALIGN(8)
        !            58: PROLOGUE(mpn_sub_n)
        !            59: deflit(`FRAME',0)
        !            60:        pxor    %mm0, %mm0
        !            61: L(start_nc):
        !            62:        movl    PARAM_SRC1, %eax
        !            63:        movl    %ebx, SAVE_EBX
        !            64:        movl    PARAM_SRC2, %ebx
        !            65:        movl    PARAM_DST, %edx
        !            66:        movl    PARAM_SIZE, %ecx
        !            67:
        !            68:        leal    (%eax,%ecx,4), %eax     C src1 end
        !            69:        leal    (%ebx,%ecx,4), %ebx     C src2 end
        !            70:        leal    (%edx,%ecx,4), %edx     C dst end
        !            71:        negl    %ecx                    C -size
        !            72:
        !            73: L(top):
        !            74:        C eax   src1 end
        !            75:        C ebx   src2 end
        !            76:        C ecx   counter, limbs, negative
        !            77:        C edx   dst end
        !            78:        C mm0   carry bit
        !            79:
        !            80:        movd    (%eax,%ecx,4), %mm1
        !            81:        movd    (%ebx,%ecx,4), %mm2
        !            82:        psubq   %mm2, %mm1
        !            83:
        !            84:        psubq   %mm0, %mm1
        !            85:        movd    %mm1, (%edx,%ecx,4)
        !            86:
        !            87:        psrlq   $63, %mm1
        !            88:
        !            89:        addl    $1, %ecx
        !            90:        jz      L(done_mm1)
        !            91:
        !            92:        movd    (%eax,%ecx,4), %mm0
        !            93:        movd    (%ebx,%ecx,4), %mm2
        !            94:        psubq   %mm2, %mm0
        !            95:
        !            96:        psubq   %mm1, %mm0
        !            97:        movd    %mm0, (%edx,%ecx,4)
        !            98:
        !            99:        psrlq   $63, %mm0
        !           100:
        !           101:        addl    $1, %ecx
        !           102:        jnz     L(top)
        !           103:
        !           104:
        !           105:        movd    %mm0, %eax
        !           106:        movl    SAVE_EBX, %ebx
        !           107:        emms
        !           108:        ret
        !           109:
        !           110: L(done_mm1):
        !           111:        movd    %mm1, %eax
        !           112:        movl    SAVE_EBX, %ebx
        !           113:        emms
        !           114:        ret
        !           115:
        !           116: EPILOGUE()

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