~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to msvc/gmp/mpn/x86i/mod_34lsub1.asm

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-05-17 02:46:26 UTC
  • Revision ID: james.westby@ubuntu.com-20060517024626-lljr08ftv9g9vefl
Tags: upstream-0.9h-20060510
ImportĀ upstreamĀ versionĀ 0.9h-20060510

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
;  Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
 
3
;
 
4
;  This file is part of the GNU MP Library.
 
5
;
 
6
;  The GNU MP Library is free software; you can redistribute it and/or
 
7
;  modify it under the terms of the GNU Lesser General Public License as
 
8
;  published by the Free Software Foundation; either version 2.1 of the
 
9
;  License, or (at your option) any later version.
 
10
;
 
11
;  The GNU MP Library is distributed in the hope that it will be useful,
 
12
;  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
;  Lesser General Public License for more details.
 
15
;
 
16
;  You should have received a copy of the GNU Lesser General Public
 
17
;  License along with the GNU MP Library; see the file COPYING.LIB.  If
 
18
;  not, write to the Free Software Foundation, Inc., 59 Temple Place -
 
19
;  Suite 330, Boston, MA 02111-1307, USA.
 
20
;
 
21
; Translation of AT&T syntax code by Brian Gladman 
 
22
 
 
23
%include        "x86i.inc"
 
24
 
 
25
    section .text
 
26
 
 
27
%define PARAM_SIZE    esp+frame+8
 
28
%define PARAM_SRC     esp+frame+4
 
29
 
 
30
; re-use parameter space 
 
31
%define SAVE_EBX        PARAM_SRC
 
32
 
 
33
        global  ___gmpn_mod_34lsub1
 
34
%ifdef  DLL
 
35
        export  ___gmpn_mod_34lsub1
 
36
%endif
 
37
 
 
38
    align   16
 
39
___gmpn_mod_34lsub1:
 
40
%assign       frame   0
 
41
    mov     ecx,[PARAM_SIZE]
 
42
    mov     edx,[PARAM_SRC]
 
43
    sub     ecx,2
 
44
    ja      Lthree_or_more
 
45
    mov     eax,[edx]
 
46
    jb      Lone
 
47
    mov     ecx,[4+edx]
 
48
    mov     edx,eax
 
49
    shr     eax,24                              ; src[0] low 
 
50
 
 
51
    and     edx,0xFFFFFF                ; src[0] high 
 
52
    add     eax,edx
 
53
    mov     edx,ecx
 
54
 
 
55
    and     ecx,0xFFFF
 
56
    shr     edx,16                              ; src[1] high 
 
57
    add     eax,edx
 
58
 
 
59
    shl     ecx,8                               ; src[1] low 
 
60
    add     eax,ecx
 
61
Lone:
 
62
    ret
 
63
 
 
64
; eax 
 
65
; ebx 
 
66
; ecx  size-2 
 
67
; edx  src 
 
68
; esi 
 
69
; edi 
 
70
; ebp 
 
71
 
 
72
Lthree_or_more:
 
73
    mov     [SAVE_EBX],ebx      ; and arrange 16-byte loop alignment 
 
74
    xor     ebx,ebx
 
75
        FR_push esi
 
76
    xor     esi,esi
 
77
        FR_push edi
 
78
    xor     eax,eax         ; and clear carry flag 
 
79
 
 
80
; offset 0x40 here 
 
81
; eax  acc 0mod3 
 
82
; ebx  acc 1mod3 
 
83
; ecx  counter,limbs 
 
84
; edx  src 
 
85
; esi  acc 2mod3 
 
86
; edi 
 
87
; ebp 
 
88
 
 
89
Ltop:
 
90
    lea     edx,[12+edx]
 
91
    lea     ecx,[-2+ecx]
 
92
    adc     eax,[-12+edx]
 
93
    adc     ebx,[-8+edx]
 
94
    adc     esi,[-4+edx]
 
95
    dec     ecx
 
96
    jg      Ltop
 
97
; ecx is -2,-1 or 0 representing 0,1 or 2 more limbs,respectively 
 
98
    mov     edi,0xFFFFFFFF
 
99
    inc     ecx
 
100
    js      Lcombine
 
101
    adc     eax,[edx]
 
102
    mov     edi,0xFFFFFF00
 
103
    dec     ecx
 
104
    js      Lcombine
 
105
    adc     ebx,[4+edx]
 
106
    mov     edi,0xFFFF0000
 
107
 
 
108
; eax  acc 0mod3 
 
109
; ebx  acc 1mod3 
 
110
; ecx 
 
111
; edx 
 
112
; esi  acc 2mod3 
 
113
; edi  mask 
 
114
; ebp 
 
115
 
 
116
Lcombine:
 
117
    sbb     ecx,ecx                     ; carry 
 
118
    mov     edx,eax         ; 0mod3 
 
119
    shr     eax,24          ; 0mod3 high 
 
120
    and     ecx,edi         ; carry masked 
 
121
    sub     eax,ecx         ; apply carry 
 
122
    mov     edi,ebx         ; 1mod3 
 
123
    shr     ebx,16          ; 1mod3 high 
 
124
    and     edx,0x00FFFFFF  ; 0mod3 low 
 
125
    add     eax,edx         ; apply 0mod3 low 
 
126
    and     edi,0xFFFF
 
127
    shl     edi,8                       ; 1mod3 low 
 
128
    add     eax,ebx         ; apply 1mod3 high 
 
129
    add     eax,edi         ; apply 1mod3 low 
 
130
    mov     edx,esi         ; 2mod3 
 
131
    shr     esi,8                       ; 2mod3 high 
 
132
    and     edx,0xFF        ; 2mod3 low 
 
133
    shl     edx,16          ; 2mod3 low 
 
134
    add     eax,esi         ; apply 2mod3 high 
 
135
    add     eax,edx         ; apply 2mod3 low 
 
136
        FR_pop  edi
 
137
    mov     ebx,[SAVE_EBX]
 
138
        FR_pop  es
 
139
    ret
 
140
 
 
141
        end