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

Annotation of OpenXM_contrib/gmp/mpn/x86/mod_34lsub1.asm, Revision 1.1.1.1

1.1       ohara       1: dnl  Generic x86 mpn_mod_32lsub1 -- mpn remainder modulo 2^24-1.
                      2:
                      3: dnl  Copyright 2000, 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      cycles/limb
                     26: C P5:     3.0
                     27: C P6:     3.66
                     28: C K6:     3.0
                     29: C K7:     1.3
                     30: C P4:     9
                     31:
                     32:
                     33: C mp_limb_t mpn_mod_34lsub1 (mp_srcptr src, mp_size_t size)
                     34: C
                     35:
                     36: defframe(PARAM_SIZE, 8)
                     37: defframe(PARAM_SRC,  4)
                     38:
                     39: dnl  re-use parameter space
                     40: define(SAVE_EBX, `PARAM_SRC')
                     41:
                     42:        TEXT
                     43:        ALIGN(16)
                     44: PROLOGUE(mpn_mod_34lsub1)
                     45: deflit(`FRAME',0)
                     46:
                     47:        movl    PARAM_SIZE, %ecx
                     48:        movl    PARAM_SRC, %edx
                     49:
                     50:        subl    $2, %ecx
                     51:        ja      L(three_or_more)
                     52:
                     53:        movl    (%edx), %eax
                     54:        jb      L(one)
                     55:
                     56:        movl    4(%edx), %ecx
                     57:        movl    %eax, %edx
                     58:        shrl    $24, %eax               C src[0] low
                     59:
                     60:        andl    $0xFFFFFF, %edx         C src[0] high
                     61:        addl    %edx, %eax
                     62:        movl    %ecx, %edx
                     63:
                     64:        andl    $0xFFFF, %ecx
                     65:        shrl    $16, %edx               C src[1] high
                     66:        addl    %edx, %eax
                     67:
                     68:        shll    $8, %ecx                C src[1] low
                     69:        addl    %ecx, %eax
                     70:
                     71: L(one):
                     72:        ret
                     73:
                     74:
                     75: L(three_or_more):
                     76:        C eax
                     77:        C ebx
                     78:        C ecx   size-2
                     79:        C edx   src
                     80:        C esi
                     81:        C edi
                     82:        C ebp
                     83:
                     84:        movl    %ebx, SAVE_EBX          C and arrange 16-byte loop alignment
                     85:        xorl    %ebx, %ebx
                     86:
                     87:        pushl   %esi    FRAME_pushl()
                     88:        xorl    %esi, %esi
                     89:
                     90:        pushl   %edi    FRAME_pushl()
                     91:        xorl    %eax, %eax              C and clear carry flag
                     92:
                     93:
                     94:        C offset 0x40 here
                     95: L(top):
                     96:        C eax   acc 0mod3
                     97:        C ebx   acc 1mod3
                     98:        C ecx   counter, limbs
                     99:        C edx   src
                    100:        C esi   acc 2mod3
                    101:        C edi
                    102:        C ebp
                    103:
                    104:        leal    12(%edx), %edx
                    105:        leal    -2(%ecx), %ecx
                    106:
                    107:        adcl    -12(%edx), %eax
                    108:        adcl    -8(%edx), %ebx
                    109:        adcl    -4(%edx), %esi
                    110:
                    111:        decl    %ecx
                    112:        jg      L(top)
                    113:
                    114:
                    115:        C ecx is -2, -1 or 0 representing 0, 1 or 2 more limbs, respectively
                    116:
                    117:        movl    $0xFFFFFFFF, %edi
                    118:        incl    %ecx
                    119:        js      L(combine)
                    120:
                    121:        adcl    (%edx), %eax
                    122:        movl    $0xFFFFFF00, %edi
                    123:        decl    %ecx
                    124:        js      L(combine)
                    125:
                    126:        adcl    4(%edx), %ebx
                    127:        movl    $0xFFFF0000, %edi
                    128:
                    129:
                    130: L(combine):
                    131:        C eax   acc 0mod3
                    132:        C ebx   acc 1mod3
                    133:        C ecx
                    134:        C edx
                    135:        C esi   acc 2mod3
                    136:        C edi   mask
                    137:        C ebp
                    138:
                    139:        sbbl    %ecx, %ecx              C carry
                    140:        movl    %eax, %edx              C 0mod3
                    141:
                    142:        shrl    $24, %eax               C 0mod3 high
                    143:        andl    %edi, %ecx              C carry masked
                    144:
                    145:        subl    %ecx, %eax              C apply carry
                    146:        movl    %ebx, %edi              C 1mod3
                    147:
                    148:        shrl    $16, %ebx               C 1mod3 high
                    149:        andl    $0x00FFFFFF, %edx       C 0mod3 low
                    150:
                    151:        addl    %edx, %eax              C apply 0mod3 low
                    152:        andl    $0xFFFF, %edi
                    153:
                    154:        shll    $8, %edi                C 1mod3 low
                    155:        addl    %ebx, %eax              C apply 1mod3 high
                    156:
                    157:        addl    %edi, %eax              C apply 1mod3 low
                    158:        movl    %esi, %edx              C 2mod3
                    159:
                    160:        shrl    $8, %esi                C 2mod3 high
                    161:        andl    $0xFF, %edx             C 2mod3 low
                    162:
                    163:        shll    $16, %edx               C 2mod3 low
                    164:        addl    %esi, %eax              C apply 2mod3 high
                    165:
                    166:        addl    %edx, %eax              C apply 2mod3 low
                    167:        popl    %edi    FRAME_popl()
                    168:
                    169:        movl    SAVE_EBX, %ebx
                    170:        popl    %esi    FRAME_popl()
                    171:
                    172:        ret
                    173:
                    174: EPILOGUE()

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