1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
11 * giantPorti486.s - i486-specific assembly routines.
15 * 17 Apr 1998 at Apple
19 #if defined (i386) || defined(__i386__)
23 * Multiply a vector a giantDigits, candVector, by a single giantDigit,
24 * plierDigit, adding results in prodVector.
26 * void VectorMultiply(
27 * giantDigit plierDigit,
28 * giantDigit *candVector,
29 * unsigned candLength,
30 * giantDigit *prodVector)
34 .globl _vectorMult_x86
37 * Stack locations, relative to adjusted bp.
39 #define LOCAL_SPACE 0x4
41 #define ARG_START (LOCAL_SPACE + 8) /* rtn ptr plus bp */
42 #define ARG_PLIER_DIGIT (ARG_START + 0)
43 #define ARG_CAND_VECTOR (ARG_START + 4) /* cached in ecx */
44 #define ARG_CAND_LENGTH (ARG_START + 8)
45 #define ARG_PROD_VECTOR (ARG_START + 12) /* cached in esi */
47 #define LOCAL_START (0)
48 #define LOC_CAND_DEX (LOCAL_START + 0) /* index into candVector */
58 subl $LOCAL_SPACE,%esp
64 /* esp not used again 'til we pop these off stack */
66 /* prodVector = %esi */
67 movl ARG_PROD_VECTOR(%ebp),%esi
70 /* 0 --> candDex in 0xf0(%ebp) */
73 /* candVector --> %ecx */
74 movl ARG_CAND_VECTOR(%ebp),%ecx
76 /* for(candDex=0; candDex<candLength; ++candDex) */
77 movl $0, LOC_CAND_DEX(%ebp)
79 /* make sure candLenth > 0 to start...*/
80 cmpl %ebx,ARG_CAND_LENGTH(%ebp)
84 /* branch back to top of for loop */
86 /* *candVector--> %eax */
92 /* plierDigit --> %edx */
93 movl ARG_PLIER_DIGIT(%ebp),%edx
97 * edx:eax := (plierDigit * *candVector) */
100 /* from here to end of loop:
104 /* prodLo += *prodVector */
107 /* add carry to hi digit */
110 /* prodLo += lastCarry */
112 /* add carry to hi digit */
115 /* *(prodVector++) = prodLo; */
119 /* lastCarry = prodHi */
123 incl LOC_CAND_DEX(%ebp)
125 /* top of loop if candDex < candLength */
126 movl ARG_CAND_LENGTH(%ebp),%eax
127 cmpl %eax,LOC_CAND_DEX(%ebp)
131 /* out of for loop */
132 /* *prodVector += lastCarry; */
136 /* return carry from last addition */
140 /* return lastCarry */
146 addl $LOCAL_SPACE,%esp