Hannes Tschofenig
/
aes-gcm-test-program
Example program to test AES-GCM functionality. Used for a workshop
SSL/include/polarssl/bn_mul.h@0:796d0f61a05b, 2018-09-27 (annotated)
- Committer:
- HannesTschofenig
- Date:
- Thu Sep 27 06:34:22 2018 +0000
- Revision:
- 0:796d0f61a05b
Example AES-GCM test program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
HannesTschofenig | 0:796d0f61a05b | 1 | /** |
HannesTschofenig | 0:796d0f61a05b | 2 | * \file bn_mul.h |
HannesTschofenig | 0:796d0f61a05b | 3 | * |
HannesTschofenig | 0:796d0f61a05b | 4 | * \brief Multi-precision integer library |
HannesTschofenig | 0:796d0f61a05b | 5 | * |
HannesTschofenig | 0:796d0f61a05b | 6 | * Copyright (C) 2006-2010, Brainspark B.V. |
HannesTschofenig | 0:796d0f61a05b | 7 | * |
HannesTschofenig | 0:796d0f61a05b | 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
HannesTschofenig | 0:796d0f61a05b | 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
HannesTschofenig | 0:796d0f61a05b | 10 | * |
HannesTschofenig | 0:796d0f61a05b | 11 | * All rights reserved. |
HannesTschofenig | 0:796d0f61a05b | 12 | * |
HannesTschofenig | 0:796d0f61a05b | 13 | * This program is free software; you can redistribute it and/or modify |
HannesTschofenig | 0:796d0f61a05b | 14 | * it under the terms of the GNU General Public License as published by |
HannesTschofenig | 0:796d0f61a05b | 15 | * the Free Software Foundation; either version 2 of the License, or |
HannesTschofenig | 0:796d0f61a05b | 16 | * (at your option) any later version. |
HannesTschofenig | 0:796d0f61a05b | 17 | * |
HannesTschofenig | 0:796d0f61a05b | 18 | * This program is distributed in the hope that it will be useful, |
HannesTschofenig | 0:796d0f61a05b | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
HannesTschofenig | 0:796d0f61a05b | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
HannesTschofenig | 0:796d0f61a05b | 21 | * GNU General Public License for more details. |
HannesTschofenig | 0:796d0f61a05b | 22 | * |
HannesTschofenig | 0:796d0f61a05b | 23 | * You should have received a copy of the GNU General Public License along |
HannesTschofenig | 0:796d0f61a05b | 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
HannesTschofenig | 0:796d0f61a05b | 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
HannesTschofenig | 0:796d0f61a05b | 26 | */ |
HannesTschofenig | 0:796d0f61a05b | 27 | /* |
HannesTschofenig | 0:796d0f61a05b | 28 | * Multiply source vector [s] with b, add result |
HannesTschofenig | 0:796d0f61a05b | 29 | * to destination vector [d] and set carry c. |
HannesTschofenig | 0:796d0f61a05b | 30 | * |
HannesTschofenig | 0:796d0f61a05b | 31 | * Currently supports: |
HannesTschofenig | 0:796d0f61a05b | 32 | * |
HannesTschofenig | 0:796d0f61a05b | 33 | * . IA-32 (386+) . AMD64 / EM64T |
HannesTschofenig | 0:796d0f61a05b | 34 | * . IA-32 (SSE2) . Motorola 68000 |
HannesTschofenig | 0:796d0f61a05b | 35 | * . PowerPC, 32-bit . MicroBlaze |
HannesTschofenig | 0:796d0f61a05b | 36 | * . PowerPC, 64-bit . TriCore |
HannesTschofenig | 0:796d0f61a05b | 37 | * . SPARC v8 . ARM v3+ |
HannesTschofenig | 0:796d0f61a05b | 38 | * . Alpha . MIPS32 |
HannesTschofenig | 0:796d0f61a05b | 39 | * . C, longlong . C, generic |
HannesTschofenig | 0:796d0f61a05b | 40 | */ |
HannesTschofenig | 0:796d0f61a05b | 41 | #ifndef POLARSSL_BN_MUL_H |
HannesTschofenig | 0:796d0f61a05b | 42 | #define POLARSSL_BN_MUL_H |
HannesTschofenig | 0:796d0f61a05b | 43 | |
HannesTschofenig | 0:796d0f61a05b | 44 | #include "bignum.h" |
HannesTschofenig | 0:796d0f61a05b | 45 | |
HannesTschofenig | 0:796d0f61a05b | 46 | #if defined(POLARSSL_HAVE_ASM) |
HannesTschofenig | 0:796d0f61a05b | 47 | |
HannesTschofenig | 0:796d0f61a05b | 48 | #if defined(__GNUC__) |
HannesTschofenig | 0:796d0f61a05b | 49 | #if defined(__i386__) |
HannesTschofenig | 0:796d0f61a05b | 50 | |
HannesTschofenig | 0:796d0f61a05b | 51 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 52 | asm( " \ |
HannesTschofenig | 0:796d0f61a05b | 53 | movl %%ebx, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 54 | movl %5, %%esi; \ |
HannesTschofenig | 0:796d0f61a05b | 55 | movl %6, %%edi; \ |
HannesTschofenig | 0:796d0f61a05b | 56 | movl %7, %%ecx; \ |
HannesTschofenig | 0:796d0f61a05b | 57 | movl %8, %%ebx; \ |
HannesTschofenig | 0:796d0f61a05b | 58 | " |
HannesTschofenig | 0:796d0f61a05b | 59 | |
HannesTschofenig | 0:796d0f61a05b | 60 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 61 | " \ |
HannesTschofenig | 0:796d0f61a05b | 62 | lodsl; \ |
HannesTschofenig | 0:796d0f61a05b | 63 | mull %%ebx; \ |
HannesTschofenig | 0:796d0f61a05b | 64 | addl %%ecx, %%eax; \ |
HannesTschofenig | 0:796d0f61a05b | 65 | adcl $0, %%edx; \ |
HannesTschofenig | 0:796d0f61a05b | 66 | addl (%%edi), %%eax; \ |
HannesTschofenig | 0:796d0f61a05b | 67 | adcl $0, %%edx; \ |
HannesTschofenig | 0:796d0f61a05b | 68 | movl %%edx, %%ecx; \ |
HannesTschofenig | 0:796d0f61a05b | 69 | stosl; \ |
HannesTschofenig | 0:796d0f61a05b | 70 | " |
HannesTschofenig | 0:796d0f61a05b | 71 | |
HannesTschofenig | 0:796d0f61a05b | 72 | #if defined(POLARSSL_HAVE_SSE2) |
HannesTschofenig | 0:796d0f61a05b | 73 | |
HannesTschofenig | 0:796d0f61a05b | 74 | #define MULADDC_HUIT \ |
HannesTschofenig | 0:796d0f61a05b | 75 | " \ |
HannesTschofenig | 0:796d0f61a05b | 76 | movd %%ecx, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 77 | movd %%ebx, %%mm0; \ |
HannesTschofenig | 0:796d0f61a05b | 78 | movd (%%edi), %%mm3; \ |
HannesTschofenig | 0:796d0f61a05b | 79 | paddq %%mm3, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 80 | movd (%%esi), %%mm2; \ |
HannesTschofenig | 0:796d0f61a05b | 81 | pmuludq %%mm0, %%mm2; \ |
HannesTschofenig | 0:796d0f61a05b | 82 | movd 4(%%esi), %%mm4; \ |
HannesTschofenig | 0:796d0f61a05b | 83 | pmuludq %%mm0, %%mm4; \ |
HannesTschofenig | 0:796d0f61a05b | 84 | movd 8(%%esi), %%mm6; \ |
HannesTschofenig | 0:796d0f61a05b | 85 | pmuludq %%mm0, %%mm6; \ |
HannesTschofenig | 0:796d0f61a05b | 86 | movd 12(%%esi), %%mm7; \ |
HannesTschofenig | 0:796d0f61a05b | 87 | pmuludq %%mm0, %%mm7; \ |
HannesTschofenig | 0:796d0f61a05b | 88 | paddq %%mm2, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 89 | movd 4(%%edi), %%mm3; \ |
HannesTschofenig | 0:796d0f61a05b | 90 | paddq %%mm4, %%mm3; \ |
HannesTschofenig | 0:796d0f61a05b | 91 | movd 8(%%edi), %%mm5; \ |
HannesTschofenig | 0:796d0f61a05b | 92 | paddq %%mm6, %%mm5; \ |
HannesTschofenig | 0:796d0f61a05b | 93 | movd 12(%%edi), %%mm4; \ |
HannesTschofenig | 0:796d0f61a05b | 94 | paddq %%mm4, %%mm7; \ |
HannesTschofenig | 0:796d0f61a05b | 95 | movd %%mm1, (%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 96 | movd 16(%%esi), %%mm2; \ |
HannesTschofenig | 0:796d0f61a05b | 97 | pmuludq %%mm0, %%mm2; \ |
HannesTschofenig | 0:796d0f61a05b | 98 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 99 | movd 20(%%esi), %%mm4; \ |
HannesTschofenig | 0:796d0f61a05b | 100 | pmuludq %%mm0, %%mm4; \ |
HannesTschofenig | 0:796d0f61a05b | 101 | paddq %%mm3, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 102 | movd 24(%%esi), %%mm6; \ |
HannesTschofenig | 0:796d0f61a05b | 103 | pmuludq %%mm0, %%mm6; \ |
HannesTschofenig | 0:796d0f61a05b | 104 | movd %%mm1, 4(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 105 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 106 | movd 28(%%esi), %%mm3; \ |
HannesTschofenig | 0:796d0f61a05b | 107 | pmuludq %%mm0, %%mm3; \ |
HannesTschofenig | 0:796d0f61a05b | 108 | paddq %%mm5, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 109 | movd 16(%%edi), %%mm5; \ |
HannesTschofenig | 0:796d0f61a05b | 110 | paddq %%mm5, %%mm2; \ |
HannesTschofenig | 0:796d0f61a05b | 111 | movd %%mm1, 8(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 112 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 113 | paddq %%mm7, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 114 | movd 20(%%edi), %%mm5; \ |
HannesTschofenig | 0:796d0f61a05b | 115 | paddq %%mm5, %%mm4; \ |
HannesTschofenig | 0:796d0f61a05b | 116 | movd %%mm1, 12(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 117 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 118 | paddq %%mm2, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 119 | movd 24(%%edi), %%mm5; \ |
HannesTschofenig | 0:796d0f61a05b | 120 | paddq %%mm5, %%mm6; \ |
HannesTschofenig | 0:796d0f61a05b | 121 | movd %%mm1, 16(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 122 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 123 | paddq %%mm4, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 124 | movd 28(%%edi), %%mm5; \ |
HannesTschofenig | 0:796d0f61a05b | 125 | paddq %%mm5, %%mm3; \ |
HannesTschofenig | 0:796d0f61a05b | 126 | movd %%mm1, 20(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 127 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 128 | paddq %%mm6, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 129 | movd %%mm1, 24(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 130 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 131 | paddq %%mm3, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 132 | movd %%mm1, 28(%%edi); \ |
HannesTschofenig | 0:796d0f61a05b | 133 | addl $32, %%edi; \ |
HannesTschofenig | 0:796d0f61a05b | 134 | addl $32, %%esi; \ |
HannesTschofenig | 0:796d0f61a05b | 135 | psrlq $32, %%mm1; \ |
HannesTschofenig | 0:796d0f61a05b | 136 | movd %%mm1, %%ecx; \ |
HannesTschofenig | 0:796d0f61a05b | 137 | " |
HannesTschofenig | 0:796d0f61a05b | 138 | |
HannesTschofenig | 0:796d0f61a05b | 139 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 140 | " \ |
HannesTschofenig | 0:796d0f61a05b | 141 | emms; \ |
HannesTschofenig | 0:796d0f61a05b | 142 | movl %4, %%ebx; \ |
HannesTschofenig | 0:796d0f61a05b | 143 | movl %%ecx, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 144 | movl %%edi, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 145 | movl %%esi, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 146 | " \ |
HannesTschofenig | 0:796d0f61a05b | 147 | : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 148 | : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 149 | : "eax", "ecx", "edx", "esi", "edi" \ |
HannesTschofenig | 0:796d0f61a05b | 150 | ); |
HannesTschofenig | 0:796d0f61a05b | 151 | |
HannesTschofenig | 0:796d0f61a05b | 152 | #else |
HannesTschofenig | 0:796d0f61a05b | 153 | |
HannesTschofenig | 0:796d0f61a05b | 154 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 155 | " \ |
HannesTschofenig | 0:796d0f61a05b | 156 | movl %4, %%ebx; \ |
HannesTschofenig | 0:796d0f61a05b | 157 | movl %%ecx, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 158 | movl %%edi, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 159 | movl %%esi, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 160 | " \ |
HannesTschofenig | 0:796d0f61a05b | 161 | : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 162 | : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 163 | : "eax", "ecx", "edx", "esi", "edi" \ |
HannesTschofenig | 0:796d0f61a05b | 164 | ); |
HannesTschofenig | 0:796d0f61a05b | 165 | #endif /* SSE2 */ |
HannesTschofenig | 0:796d0f61a05b | 166 | #endif /* i386 */ |
HannesTschofenig | 0:796d0f61a05b | 167 | |
HannesTschofenig | 0:796d0f61a05b | 168 | #if defined(__amd64__) || defined (__x86_64__) |
HannesTschofenig | 0:796d0f61a05b | 169 | |
HannesTschofenig | 0:796d0f61a05b | 170 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 171 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 172 | " \ |
HannesTschofenig | 0:796d0f61a05b | 173 | movq %3, %%rsi; \ |
HannesTschofenig | 0:796d0f61a05b | 174 | movq %4, %%rdi; \ |
HannesTschofenig | 0:796d0f61a05b | 175 | movq %5, %%rcx; \ |
HannesTschofenig | 0:796d0f61a05b | 176 | movq %6, %%rbx; \ |
HannesTschofenig | 0:796d0f61a05b | 177 | xorq %%r8, %%r8; \ |
HannesTschofenig | 0:796d0f61a05b | 178 | " |
HannesTschofenig | 0:796d0f61a05b | 179 | |
HannesTschofenig | 0:796d0f61a05b | 180 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 181 | " \ |
HannesTschofenig | 0:796d0f61a05b | 182 | movq (%%rsi), %%rax; \ |
HannesTschofenig | 0:796d0f61a05b | 183 | mulq %%rbx; \ |
HannesTschofenig | 0:796d0f61a05b | 184 | addq $8, %%rsi; \ |
HannesTschofenig | 0:796d0f61a05b | 185 | addq %%rcx, %%rax; \ |
HannesTschofenig | 0:796d0f61a05b | 186 | movq %%r8, %%rcx; \ |
HannesTschofenig | 0:796d0f61a05b | 187 | adcq $0, %%rdx; \ |
HannesTschofenig | 0:796d0f61a05b | 188 | nop; \ |
HannesTschofenig | 0:796d0f61a05b | 189 | addq %%rax, (%%rdi); \ |
HannesTschofenig | 0:796d0f61a05b | 190 | adcq %%rdx, %%rcx; \ |
HannesTschofenig | 0:796d0f61a05b | 191 | addq $8, %%rdi; \ |
HannesTschofenig | 0:796d0f61a05b | 192 | " |
HannesTschofenig | 0:796d0f61a05b | 193 | |
HannesTschofenig | 0:796d0f61a05b | 194 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 195 | " \ |
HannesTschofenig | 0:796d0f61a05b | 196 | movq %%rcx, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 197 | movq %%rdi, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 198 | movq %%rsi, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 199 | " \ |
HannesTschofenig | 0:796d0f61a05b | 200 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 201 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 202 | : "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" \ |
HannesTschofenig | 0:796d0f61a05b | 203 | ); |
HannesTschofenig | 0:796d0f61a05b | 204 | |
HannesTschofenig | 0:796d0f61a05b | 205 | #endif /* AMD64 */ |
HannesTschofenig | 0:796d0f61a05b | 206 | |
HannesTschofenig | 0:796d0f61a05b | 207 | #if defined(__mc68020__) || defined(__mcpu32__) |
HannesTschofenig | 0:796d0f61a05b | 208 | |
HannesTschofenig | 0:796d0f61a05b | 209 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 210 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 211 | " \ |
HannesTschofenig | 0:796d0f61a05b | 212 | movl %3, %%a2; \ |
HannesTschofenig | 0:796d0f61a05b | 213 | movl %4, %%a3; \ |
HannesTschofenig | 0:796d0f61a05b | 214 | movl %5, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 215 | movl %6, %%d2; \ |
HannesTschofenig | 0:796d0f61a05b | 216 | moveq #0, %%d0; \ |
HannesTschofenig | 0:796d0f61a05b | 217 | " |
HannesTschofenig | 0:796d0f61a05b | 218 | |
HannesTschofenig | 0:796d0f61a05b | 219 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 220 | " \ |
HannesTschofenig | 0:796d0f61a05b | 221 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 222 | mulul %%d2, %%d4:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 223 | addl %%d3, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 224 | addxl %%d0, %%d4; \ |
HannesTschofenig | 0:796d0f61a05b | 225 | moveq #0, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 226 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 227 | addxl %%d4, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 228 | " |
HannesTschofenig | 0:796d0f61a05b | 229 | |
HannesTschofenig | 0:796d0f61a05b | 230 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 231 | " \ |
HannesTschofenig | 0:796d0f61a05b | 232 | movl %%d3, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 233 | movl %%a3, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 234 | movl %%a2, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 235 | " \ |
HannesTschofenig | 0:796d0f61a05b | 236 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 237 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 238 | : "d0", "d1", "d2", "d3", "d4", "a2", "a3" \ |
HannesTschofenig | 0:796d0f61a05b | 239 | ); |
HannesTschofenig | 0:796d0f61a05b | 240 | |
HannesTschofenig | 0:796d0f61a05b | 241 | #define MULADDC_HUIT \ |
HannesTschofenig | 0:796d0f61a05b | 242 | " \ |
HannesTschofenig | 0:796d0f61a05b | 243 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 244 | mulul %%d2, %%d4:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 245 | addxl %%d3, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 246 | addxl %%d0, %%d4; \ |
HannesTschofenig | 0:796d0f61a05b | 247 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 248 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 249 | mulul %%d2, %%d3:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 250 | addxl %%d4, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 251 | addxl %%d0, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 252 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 253 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 254 | mulul %%d2, %%d4:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 255 | addxl %%d3, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 256 | addxl %%d0, %%d4; \ |
HannesTschofenig | 0:796d0f61a05b | 257 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 258 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 259 | mulul %%d2, %%d3:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 260 | addxl %%d4, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 261 | addxl %%d0, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 262 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 263 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 264 | mulul %%d2, %%d4:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 265 | addxl %%d3, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 266 | addxl %%d0, %%d4; \ |
HannesTschofenig | 0:796d0f61a05b | 267 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 268 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 269 | mulul %%d2, %%d3:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 270 | addxl %%d4, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 271 | addxl %%d0, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 272 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 273 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 274 | mulul %%d2, %%d4:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 275 | addxl %%d3, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 276 | addxl %%d0, %%d4; \ |
HannesTschofenig | 0:796d0f61a05b | 277 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 278 | movel %%a2@+, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 279 | mulul %%d2, %%d3:%%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 280 | addxl %%d4, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 281 | addxl %%d0, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 282 | addl %%d1, %%a3@+; \ |
HannesTschofenig | 0:796d0f61a05b | 283 | addxl %%d0, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 284 | " |
HannesTschofenig | 0:796d0f61a05b | 285 | |
HannesTschofenig | 0:796d0f61a05b | 286 | #endif /* MC68000 */ |
HannesTschofenig | 0:796d0f61a05b | 287 | |
HannesTschofenig | 0:796d0f61a05b | 288 | #if defined(__powerpc__) || defined(__ppc__) |
HannesTschofenig | 0:796d0f61a05b | 289 | #if defined(__powerpc64__) || defined(__ppc64__) |
HannesTschofenig | 0:796d0f61a05b | 290 | |
HannesTschofenig | 0:796d0f61a05b | 291 | #if defined(__MACH__) && defined(__APPLE__) |
HannesTschofenig | 0:796d0f61a05b | 292 | |
HannesTschofenig | 0:796d0f61a05b | 293 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 294 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 295 | " \ |
HannesTschofenig | 0:796d0f61a05b | 296 | ld r3, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 297 | ld r4, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 298 | ld r5, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 299 | ld r6, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 300 | addi r3, r3, -8; \ |
HannesTschofenig | 0:796d0f61a05b | 301 | addi r4, r4, -8; \ |
HannesTschofenig | 0:796d0f61a05b | 302 | addic r5, r5, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 303 | " |
HannesTschofenig | 0:796d0f61a05b | 304 | |
HannesTschofenig | 0:796d0f61a05b | 305 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 306 | " \ |
HannesTschofenig | 0:796d0f61a05b | 307 | ldu r7, 8(r3); \ |
HannesTschofenig | 0:796d0f61a05b | 308 | mulld r8, r7, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 309 | mulhdu r9, r7, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 310 | adde r8, r8, r5; \ |
HannesTschofenig | 0:796d0f61a05b | 311 | ld r7, 8(r4); \ |
HannesTschofenig | 0:796d0f61a05b | 312 | addze r5, r9; \ |
HannesTschofenig | 0:796d0f61a05b | 313 | addc r8, r8, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 314 | stdu r8, 8(r4); \ |
HannesTschofenig | 0:796d0f61a05b | 315 | " |
HannesTschofenig | 0:796d0f61a05b | 316 | |
HannesTschofenig | 0:796d0f61a05b | 317 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 318 | " \ |
HannesTschofenig | 0:796d0f61a05b | 319 | addze r5, r5; \ |
HannesTschofenig | 0:796d0f61a05b | 320 | addi r4, r4, 8; \ |
HannesTschofenig | 0:796d0f61a05b | 321 | addi r3, r3, 8; \ |
HannesTschofenig | 0:796d0f61a05b | 322 | std r5, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 323 | std r4, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 324 | std r3, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 325 | " \ |
HannesTschofenig | 0:796d0f61a05b | 326 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 327 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 328 | : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ |
HannesTschofenig | 0:796d0f61a05b | 329 | ); |
HannesTschofenig | 0:796d0f61a05b | 330 | |
HannesTschofenig | 0:796d0f61a05b | 331 | |
HannesTschofenig | 0:796d0f61a05b | 332 | #else /* __MACH__ && __APPLE__ */ |
HannesTschofenig | 0:796d0f61a05b | 333 | |
HannesTschofenig | 0:796d0f61a05b | 334 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 335 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 336 | " \ |
HannesTschofenig | 0:796d0f61a05b | 337 | ld %%r3, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 338 | ld %%r4, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 339 | ld %%r5, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 340 | ld %%r6, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 341 | addi %%r3, %%r3, -8; \ |
HannesTschofenig | 0:796d0f61a05b | 342 | addi %%r4, %%r4, -8; \ |
HannesTschofenig | 0:796d0f61a05b | 343 | addic %%r5, %%r5, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 344 | " |
HannesTschofenig | 0:796d0f61a05b | 345 | |
HannesTschofenig | 0:796d0f61a05b | 346 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 347 | " \ |
HannesTschofenig | 0:796d0f61a05b | 348 | ldu %%r7, 8(%%r3); \ |
HannesTschofenig | 0:796d0f61a05b | 349 | mulld %%r8, %%r7, %%r6; \ |
HannesTschofenig | 0:796d0f61a05b | 350 | mulhdu %%r9, %%r7, %%r6; \ |
HannesTschofenig | 0:796d0f61a05b | 351 | adde %%r8, %%r8, %%r5; \ |
HannesTschofenig | 0:796d0f61a05b | 352 | ld %%r7, 8(%%r4); \ |
HannesTschofenig | 0:796d0f61a05b | 353 | addze %%r5, %%r9; \ |
HannesTschofenig | 0:796d0f61a05b | 354 | addc %%r8, %%r8, %%r7; \ |
HannesTschofenig | 0:796d0f61a05b | 355 | stdu %%r8, 8(%%r4); \ |
HannesTschofenig | 0:796d0f61a05b | 356 | " |
HannesTschofenig | 0:796d0f61a05b | 357 | |
HannesTschofenig | 0:796d0f61a05b | 358 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 359 | " \ |
HannesTschofenig | 0:796d0f61a05b | 360 | addze %%r5, %%r5; \ |
HannesTschofenig | 0:796d0f61a05b | 361 | addi %%r4, %%r4, 8; \ |
HannesTschofenig | 0:796d0f61a05b | 362 | addi %%r3, %%r3, 8; \ |
HannesTschofenig | 0:796d0f61a05b | 363 | std %%r5, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 364 | std %%r4, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 365 | std %%r3, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 366 | " \ |
HannesTschofenig | 0:796d0f61a05b | 367 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 368 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 369 | : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ |
HannesTschofenig | 0:796d0f61a05b | 370 | ); |
HannesTschofenig | 0:796d0f61a05b | 371 | |
HannesTschofenig | 0:796d0f61a05b | 372 | #endif /* __MACH__ && __APPLE__ */ |
HannesTschofenig | 0:796d0f61a05b | 373 | |
HannesTschofenig | 0:796d0f61a05b | 374 | #else /* PPC32 */ |
HannesTschofenig | 0:796d0f61a05b | 375 | |
HannesTschofenig | 0:796d0f61a05b | 376 | #if defined(__MACH__) && defined(__APPLE__) |
HannesTschofenig | 0:796d0f61a05b | 377 | |
HannesTschofenig | 0:796d0f61a05b | 378 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 379 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 380 | " \ |
HannesTschofenig | 0:796d0f61a05b | 381 | lwz r3, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 382 | lwz r4, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 383 | lwz r5, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 384 | lwz r6, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 385 | addi r3, r3, -4; \ |
HannesTschofenig | 0:796d0f61a05b | 386 | addi r4, r4, -4; \ |
HannesTschofenig | 0:796d0f61a05b | 387 | addic r5, r5, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 388 | " |
HannesTschofenig | 0:796d0f61a05b | 389 | |
HannesTschofenig | 0:796d0f61a05b | 390 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 391 | " \ |
HannesTschofenig | 0:796d0f61a05b | 392 | lwzu r7, 4(r3); \ |
HannesTschofenig | 0:796d0f61a05b | 393 | mullw r8, r7, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 394 | mulhwu r9, r7, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 395 | adde r8, r8, r5; \ |
HannesTschofenig | 0:796d0f61a05b | 396 | lwz r7, 4(r4); \ |
HannesTschofenig | 0:796d0f61a05b | 397 | addze r5, r9; \ |
HannesTschofenig | 0:796d0f61a05b | 398 | addc r8, r8, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 399 | stwu r8, 4(r4); \ |
HannesTschofenig | 0:796d0f61a05b | 400 | " |
HannesTschofenig | 0:796d0f61a05b | 401 | |
HannesTschofenig | 0:796d0f61a05b | 402 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 403 | " \ |
HannesTschofenig | 0:796d0f61a05b | 404 | addze r5, r5; \ |
HannesTschofenig | 0:796d0f61a05b | 405 | addi r4, r4, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 406 | addi r3, r3, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 407 | stw r5, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 408 | stw r4, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 409 | stw r3, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 410 | " \ |
HannesTschofenig | 0:796d0f61a05b | 411 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 412 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 413 | : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ |
HannesTschofenig | 0:796d0f61a05b | 414 | ); |
HannesTschofenig | 0:796d0f61a05b | 415 | |
HannesTschofenig | 0:796d0f61a05b | 416 | #else /* __MACH__ && __APPLE__ */ |
HannesTschofenig | 0:796d0f61a05b | 417 | |
HannesTschofenig | 0:796d0f61a05b | 418 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 419 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 420 | " \ |
HannesTschofenig | 0:796d0f61a05b | 421 | lwz %%r3, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 422 | lwz %%r4, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 423 | lwz %%r5, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 424 | lwz %%r6, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 425 | addi %%r3, %%r3, -4; \ |
HannesTschofenig | 0:796d0f61a05b | 426 | addi %%r4, %%r4, -4; \ |
HannesTschofenig | 0:796d0f61a05b | 427 | addic %%r5, %%r5, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 428 | " |
HannesTschofenig | 0:796d0f61a05b | 429 | |
HannesTschofenig | 0:796d0f61a05b | 430 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 431 | " \ |
HannesTschofenig | 0:796d0f61a05b | 432 | lwzu %%r7, 4(%%r3); \ |
HannesTschofenig | 0:796d0f61a05b | 433 | mullw %%r8, %%r7, %%r6; \ |
HannesTschofenig | 0:796d0f61a05b | 434 | mulhwu %%r9, %%r7, %%r6; \ |
HannesTschofenig | 0:796d0f61a05b | 435 | adde %%r8, %%r8, %%r5; \ |
HannesTschofenig | 0:796d0f61a05b | 436 | lwz %%r7, 4(%%r4); \ |
HannesTschofenig | 0:796d0f61a05b | 437 | addze %%r5, %%r9; \ |
HannesTschofenig | 0:796d0f61a05b | 438 | addc %%r8, %%r8, %%r7; \ |
HannesTschofenig | 0:796d0f61a05b | 439 | stwu %%r8, 4(%%r4); \ |
HannesTschofenig | 0:796d0f61a05b | 440 | " |
HannesTschofenig | 0:796d0f61a05b | 441 | |
HannesTschofenig | 0:796d0f61a05b | 442 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 443 | " \ |
HannesTschofenig | 0:796d0f61a05b | 444 | addze %%r5, %%r5; \ |
HannesTschofenig | 0:796d0f61a05b | 445 | addi %%r4, %%r4, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 446 | addi %%r3, %%r3, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 447 | stw %%r5, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 448 | stw %%r4, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 449 | stw %%r3, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 450 | " \ |
HannesTschofenig | 0:796d0f61a05b | 451 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 452 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 453 | : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \ |
HannesTschofenig | 0:796d0f61a05b | 454 | ); |
HannesTschofenig | 0:796d0f61a05b | 455 | |
HannesTschofenig | 0:796d0f61a05b | 456 | #endif /* __MACH__ && __APPLE__ */ |
HannesTschofenig | 0:796d0f61a05b | 457 | |
HannesTschofenig | 0:796d0f61a05b | 458 | #endif /* PPC32 */ |
HannesTschofenig | 0:796d0f61a05b | 459 | #endif /* PPC64 */ |
HannesTschofenig | 0:796d0f61a05b | 460 | |
HannesTschofenig | 0:796d0f61a05b | 461 | #if defined(__sparc__) && defined(__sparc64__) |
HannesTschofenig | 0:796d0f61a05b | 462 | |
HannesTschofenig | 0:796d0f61a05b | 463 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 464 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 465 | " \ |
HannesTschofenig | 0:796d0f61a05b | 466 | ldx %3, %%o0; \ |
HannesTschofenig | 0:796d0f61a05b | 467 | ldx %4, %%o1; \ |
HannesTschofenig | 0:796d0f61a05b | 468 | ld %5, %%o2; \ |
HannesTschofenig | 0:796d0f61a05b | 469 | ld %6, %%o3; \ |
HannesTschofenig | 0:796d0f61a05b | 470 | " |
HannesTschofenig | 0:796d0f61a05b | 471 | |
HannesTschofenig | 0:796d0f61a05b | 472 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 473 | " \ |
HannesTschofenig | 0:796d0f61a05b | 474 | ld [%%o0], %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 475 | inc 4, %%o0; \ |
HannesTschofenig | 0:796d0f61a05b | 476 | ld [%%o1], %%o5; \ |
HannesTschofenig | 0:796d0f61a05b | 477 | umul %%o3, %%o4, %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 478 | addcc %%o4, %%o2, %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 479 | rd %%y, %%g1; \ |
HannesTschofenig | 0:796d0f61a05b | 480 | addx %%g1, 0, %%g1; \ |
HannesTschofenig | 0:796d0f61a05b | 481 | addcc %%o4, %%o5, %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 482 | st %%o4, [%%o1]; \ |
HannesTschofenig | 0:796d0f61a05b | 483 | addx %%g1, 0, %%o2; \ |
HannesTschofenig | 0:796d0f61a05b | 484 | inc 4, %%o1; \ |
HannesTschofenig | 0:796d0f61a05b | 485 | " |
HannesTschofenig | 0:796d0f61a05b | 486 | |
HannesTschofenig | 0:796d0f61a05b | 487 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 488 | " \ |
HannesTschofenig | 0:796d0f61a05b | 489 | st %%o2, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 490 | stx %%o1, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 491 | stx %%o0, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 492 | " \ |
HannesTschofenig | 0:796d0f61a05b | 493 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 494 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 495 | : "g1", "o0", "o1", "o2", "o3", "o4", \ |
HannesTschofenig | 0:796d0f61a05b | 496 | "o5" \ |
HannesTschofenig | 0:796d0f61a05b | 497 | ); |
HannesTschofenig | 0:796d0f61a05b | 498 | #endif /* SPARCv9 */ |
HannesTschofenig | 0:796d0f61a05b | 499 | |
HannesTschofenig | 0:796d0f61a05b | 500 | #if defined(__sparc__) && !defined(__sparc64__) |
HannesTschofenig | 0:796d0f61a05b | 501 | |
HannesTschofenig | 0:796d0f61a05b | 502 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 503 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 504 | " \ |
HannesTschofenig | 0:796d0f61a05b | 505 | ld %3, %%o0; \ |
HannesTschofenig | 0:796d0f61a05b | 506 | ld %4, %%o1; \ |
HannesTschofenig | 0:796d0f61a05b | 507 | ld %5, %%o2; \ |
HannesTschofenig | 0:796d0f61a05b | 508 | ld %6, %%o3; \ |
HannesTschofenig | 0:796d0f61a05b | 509 | " |
HannesTschofenig | 0:796d0f61a05b | 510 | |
HannesTschofenig | 0:796d0f61a05b | 511 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 512 | " \ |
HannesTschofenig | 0:796d0f61a05b | 513 | ld [%%o0], %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 514 | inc 4, %%o0; \ |
HannesTschofenig | 0:796d0f61a05b | 515 | ld [%%o1], %%o5; \ |
HannesTschofenig | 0:796d0f61a05b | 516 | umul %%o3, %%o4, %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 517 | addcc %%o4, %%o2, %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 518 | rd %%y, %%g1; \ |
HannesTschofenig | 0:796d0f61a05b | 519 | addx %%g1, 0, %%g1; \ |
HannesTschofenig | 0:796d0f61a05b | 520 | addcc %%o4, %%o5, %%o4; \ |
HannesTschofenig | 0:796d0f61a05b | 521 | st %%o4, [%%o1]; \ |
HannesTschofenig | 0:796d0f61a05b | 522 | addx %%g1, 0, %%o2; \ |
HannesTschofenig | 0:796d0f61a05b | 523 | inc 4, %%o1; \ |
HannesTschofenig | 0:796d0f61a05b | 524 | " |
HannesTschofenig | 0:796d0f61a05b | 525 | |
HannesTschofenig | 0:796d0f61a05b | 526 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 527 | " \ |
HannesTschofenig | 0:796d0f61a05b | 528 | st %%o2, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 529 | st %%o1, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 530 | st %%o0, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 531 | " \ |
HannesTschofenig | 0:796d0f61a05b | 532 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 533 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 534 | : "g1", "o0", "o1", "o2", "o3", "o4", \ |
HannesTschofenig | 0:796d0f61a05b | 535 | "o5" \ |
HannesTschofenig | 0:796d0f61a05b | 536 | ); |
HannesTschofenig | 0:796d0f61a05b | 537 | |
HannesTschofenig | 0:796d0f61a05b | 538 | #endif /* SPARCv8 */ |
HannesTschofenig | 0:796d0f61a05b | 539 | |
HannesTschofenig | 0:796d0f61a05b | 540 | #if defined(__microblaze__) || defined(microblaze) |
HannesTschofenig | 0:796d0f61a05b | 541 | |
HannesTschofenig | 0:796d0f61a05b | 542 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 543 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 544 | " \ |
HannesTschofenig | 0:796d0f61a05b | 545 | lwi r3, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 546 | lwi r4, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 547 | lwi r5, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 548 | lwi r6, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 549 | andi r7, r6, 0xffff; \ |
HannesTschofenig | 0:796d0f61a05b | 550 | bsrli r6, r6, 16; \ |
HannesTschofenig | 0:796d0f61a05b | 551 | " |
HannesTschofenig | 0:796d0f61a05b | 552 | |
HannesTschofenig | 0:796d0f61a05b | 553 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 554 | " \ |
HannesTschofenig | 0:796d0f61a05b | 555 | lhui r8, r3, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 556 | addi r3, r3, 2; \ |
HannesTschofenig | 0:796d0f61a05b | 557 | lhui r9, r3, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 558 | addi r3, r3, 2; \ |
HannesTschofenig | 0:796d0f61a05b | 559 | mul r10, r9, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 560 | mul r11, r8, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 561 | mul r12, r9, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 562 | mul r13, r8, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 563 | bsrli r8, r10, 16; \ |
HannesTschofenig | 0:796d0f61a05b | 564 | bsrli r9, r11, 16; \ |
HannesTschofenig | 0:796d0f61a05b | 565 | add r13, r13, r8; \ |
HannesTschofenig | 0:796d0f61a05b | 566 | add r13, r13, r9; \ |
HannesTschofenig | 0:796d0f61a05b | 567 | bslli r10, r10, 16; \ |
HannesTschofenig | 0:796d0f61a05b | 568 | bslli r11, r11, 16; \ |
HannesTschofenig | 0:796d0f61a05b | 569 | add r12, r12, r10; \ |
HannesTschofenig | 0:796d0f61a05b | 570 | addc r13, r13, r0; \ |
HannesTschofenig | 0:796d0f61a05b | 571 | add r12, r12, r11; \ |
HannesTschofenig | 0:796d0f61a05b | 572 | addc r13, r13, r0; \ |
HannesTschofenig | 0:796d0f61a05b | 573 | lwi r10, r4, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 574 | add r12, r12, r10; \ |
HannesTschofenig | 0:796d0f61a05b | 575 | addc r13, r13, r0; \ |
HannesTschofenig | 0:796d0f61a05b | 576 | add r12, r12, r5; \ |
HannesTschofenig | 0:796d0f61a05b | 577 | addc r5, r13, r0; \ |
HannesTschofenig | 0:796d0f61a05b | 578 | swi r12, r4, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 579 | addi r4, r4, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 580 | " |
HannesTschofenig | 0:796d0f61a05b | 581 | |
HannesTschofenig | 0:796d0f61a05b | 582 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 583 | " \ |
HannesTschofenig | 0:796d0f61a05b | 584 | swi r5, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 585 | swi r4, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 586 | swi r3, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 587 | " \ |
HannesTschofenig | 0:796d0f61a05b | 588 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 589 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 590 | : "r3", "r4" "r5", "r6", "r7", "r8", \ |
HannesTschofenig | 0:796d0f61a05b | 591 | "r9", "r10", "r11", "r12", "r13" \ |
HannesTschofenig | 0:796d0f61a05b | 592 | ); |
HannesTschofenig | 0:796d0f61a05b | 593 | |
HannesTschofenig | 0:796d0f61a05b | 594 | #endif /* MicroBlaze */ |
HannesTschofenig | 0:796d0f61a05b | 595 | |
HannesTschofenig | 0:796d0f61a05b | 596 | #if defined(__tricore__) |
HannesTschofenig | 0:796d0f61a05b | 597 | |
HannesTschofenig | 0:796d0f61a05b | 598 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 599 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 600 | " \ |
HannesTschofenig | 0:796d0f61a05b | 601 | ld.a %%a2, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 602 | ld.a %%a3, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 603 | ld.w %%d4, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 604 | ld.w %%d1, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 605 | xor %%d5, %%d5; \ |
HannesTschofenig | 0:796d0f61a05b | 606 | " |
HannesTschofenig | 0:796d0f61a05b | 607 | |
HannesTschofenig | 0:796d0f61a05b | 608 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 609 | " \ |
HannesTschofenig | 0:796d0f61a05b | 610 | ld.w %%d0, [%%a2+]; \ |
HannesTschofenig | 0:796d0f61a05b | 611 | madd.u %%e2, %%e4, %%d0, %%d1; \ |
HannesTschofenig | 0:796d0f61a05b | 612 | ld.w %%d0, [%%a3]; \ |
HannesTschofenig | 0:796d0f61a05b | 613 | addx %%d2, %%d2, %%d0; \ |
HannesTschofenig | 0:796d0f61a05b | 614 | addc %%d3, %%d3, 0; \ |
HannesTschofenig | 0:796d0f61a05b | 615 | mov %%d4, %%d3; \ |
HannesTschofenig | 0:796d0f61a05b | 616 | st.w [%%a3+], %%d2; \ |
HannesTschofenig | 0:796d0f61a05b | 617 | " |
HannesTschofenig | 0:796d0f61a05b | 618 | |
HannesTschofenig | 0:796d0f61a05b | 619 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 620 | " \ |
HannesTschofenig | 0:796d0f61a05b | 621 | st.w %0, %%d4; \ |
HannesTschofenig | 0:796d0f61a05b | 622 | st.a %1, %%a3; \ |
HannesTschofenig | 0:796d0f61a05b | 623 | st.a %2, %%a2; \ |
HannesTschofenig | 0:796d0f61a05b | 624 | " \ |
HannesTschofenig | 0:796d0f61a05b | 625 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 626 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 627 | : "d0", "d1", "e2", "d4", "a2", "a3" \ |
HannesTschofenig | 0:796d0f61a05b | 628 | ); |
HannesTschofenig | 0:796d0f61a05b | 629 | |
HannesTschofenig | 0:796d0f61a05b | 630 | #endif /* TriCore */ |
HannesTschofenig | 0:796d0f61a05b | 631 | |
HannesTschofenig | 0:796d0f61a05b | 632 | #if defined(__arm__) |
HannesTschofenig | 0:796d0f61a05b | 633 | |
HannesTschofenig | 0:796d0f61a05b | 634 | #if defined(__thumb__) && !defined(__thumb2__) |
HannesTschofenig | 0:796d0f61a05b | 635 | |
HannesTschofenig | 0:796d0f61a05b | 636 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 637 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 638 | " \ |
HannesTschofenig | 0:796d0f61a05b | 639 | ldr r0, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 640 | ldr r1, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 641 | ldr r2, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 642 | ldr r3, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 643 | lsr r7, r3, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 644 | mov r9, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 645 | lsl r7, r3, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 646 | lsr r7, r7, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 647 | mov r8, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 648 | " |
HannesTschofenig | 0:796d0f61a05b | 649 | |
HannesTschofenig | 0:796d0f61a05b | 650 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 651 | " \ |
HannesTschofenig | 0:796d0f61a05b | 652 | ldmia r0!, {r6}; \ |
HannesTschofenig | 0:796d0f61a05b | 653 | lsr r7, r6, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 654 | lsl r6, r6, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 655 | lsr r6, r6, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 656 | mov r4, r8; \ |
HannesTschofenig | 0:796d0f61a05b | 657 | mul r4, r6; \ |
HannesTschofenig | 0:796d0f61a05b | 658 | mov r3, r9; \ |
HannesTschofenig | 0:796d0f61a05b | 659 | mul r6, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 660 | mov r5, r9; \ |
HannesTschofenig | 0:796d0f61a05b | 661 | mul r5, r7; \ |
HannesTschofenig | 0:796d0f61a05b | 662 | mov r3, r8; \ |
HannesTschofenig | 0:796d0f61a05b | 663 | mul r7, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 664 | lsr r3, r6, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 665 | add r5, r5, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 666 | lsr r3, r7, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 667 | add r5, r5, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 668 | add r4, r4, r2; \ |
HannesTschofenig | 0:796d0f61a05b | 669 | mov r2, #0; \ |
HannesTschofenig | 0:796d0f61a05b | 670 | adc r5, r2; \ |
HannesTschofenig | 0:796d0f61a05b | 671 | lsl r3, r6, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 672 | add r4, r4, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 673 | adc r5, r2; \ |
HannesTschofenig | 0:796d0f61a05b | 674 | lsl r3, r7, #16; \ |
HannesTschofenig | 0:796d0f61a05b | 675 | add r4, r4, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 676 | adc r5, r2; \ |
HannesTschofenig | 0:796d0f61a05b | 677 | ldr r3, [r1]; \ |
HannesTschofenig | 0:796d0f61a05b | 678 | add r4, r4, r3; \ |
HannesTschofenig | 0:796d0f61a05b | 679 | adc r2, r5; \ |
HannesTschofenig | 0:796d0f61a05b | 680 | stmia r1!, {r4}; \ |
HannesTschofenig | 0:796d0f61a05b | 681 | " |
HannesTschofenig | 0:796d0f61a05b | 682 | |
HannesTschofenig | 0:796d0f61a05b | 683 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 684 | " \ |
HannesTschofenig | 0:796d0f61a05b | 685 | str r2, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 686 | str r1, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 687 | str r0, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 688 | " \ |
HannesTschofenig | 0:796d0f61a05b | 689 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 690 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 691 | : "r0", "r1", "r2", "r3", "r4", "r5", \ |
HannesTschofenig | 0:796d0f61a05b | 692 | "r6", "r7", "r8", "r9", "cc" \ |
HannesTschofenig | 0:796d0f61a05b | 693 | ); |
HannesTschofenig | 0:796d0f61a05b | 694 | |
HannesTschofenig | 0:796d0f61a05b | 695 | #else |
HannesTschofenig | 0:796d0f61a05b | 696 | |
HannesTschofenig | 0:796d0f61a05b | 697 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 698 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 699 | " \ |
HannesTschofenig | 0:796d0f61a05b | 700 | ldr r0, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 701 | ldr r1, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 702 | ldr r2, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 703 | ldr r3, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 704 | " |
HannesTschofenig | 0:796d0f61a05b | 705 | |
HannesTschofenig | 0:796d0f61a05b | 706 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 707 | " \ |
HannesTschofenig | 0:796d0f61a05b | 708 | ldr r4, [r0], #4; \ |
HannesTschofenig | 0:796d0f61a05b | 709 | mov r5, #0; \ |
HannesTschofenig | 0:796d0f61a05b | 710 | ldr r6, [r1]; \ |
HannesTschofenig | 0:796d0f61a05b | 711 | umlal r2, r5, r3, r4; \ |
HannesTschofenig | 0:796d0f61a05b | 712 | adds r7, r6, r2; \ |
HannesTschofenig | 0:796d0f61a05b | 713 | adc r2, r5, #0; \ |
HannesTschofenig | 0:796d0f61a05b | 714 | str r7, [r1], #4; \ |
HannesTschofenig | 0:796d0f61a05b | 715 | " |
HannesTschofenig | 0:796d0f61a05b | 716 | |
HannesTschofenig | 0:796d0f61a05b | 717 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 718 | " \ |
HannesTschofenig | 0:796d0f61a05b | 719 | str r2, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 720 | str r1, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 721 | str r0, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 722 | " \ |
HannesTschofenig | 0:796d0f61a05b | 723 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 724 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 725 | : "r0", "r1", "r2", "r3", "r4", "r5", \ |
HannesTschofenig | 0:796d0f61a05b | 726 | "r6", "r7", "cc" \ |
HannesTschofenig | 0:796d0f61a05b | 727 | ); |
HannesTschofenig | 0:796d0f61a05b | 728 | |
HannesTschofenig | 0:796d0f61a05b | 729 | #endif /* Thumb */ |
HannesTschofenig | 0:796d0f61a05b | 730 | |
HannesTschofenig | 0:796d0f61a05b | 731 | #endif /* ARMv3 */ |
HannesTschofenig | 0:796d0f61a05b | 732 | |
HannesTschofenig | 0:796d0f61a05b | 733 | #if defined(__alpha__) |
HannesTschofenig | 0:796d0f61a05b | 734 | |
HannesTschofenig | 0:796d0f61a05b | 735 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 736 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 737 | " \ |
HannesTschofenig | 0:796d0f61a05b | 738 | ldq $1, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 739 | ldq $2, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 740 | ldq $3, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 741 | ldq $4, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 742 | " |
HannesTschofenig | 0:796d0f61a05b | 743 | |
HannesTschofenig | 0:796d0f61a05b | 744 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 745 | " \ |
HannesTschofenig | 0:796d0f61a05b | 746 | ldq $6, 0($1); \ |
HannesTschofenig | 0:796d0f61a05b | 747 | addq $1, 8, $1; \ |
HannesTschofenig | 0:796d0f61a05b | 748 | mulq $6, $4, $7; \ |
HannesTschofenig | 0:796d0f61a05b | 749 | umulh $6, $4, $6; \ |
HannesTschofenig | 0:796d0f61a05b | 750 | addq $7, $3, $7; \ |
HannesTschofenig | 0:796d0f61a05b | 751 | cmpult $7, $3, $3; \ |
HannesTschofenig | 0:796d0f61a05b | 752 | ldq $5, 0($2); \ |
HannesTschofenig | 0:796d0f61a05b | 753 | addq $7, $5, $7; \ |
HannesTschofenig | 0:796d0f61a05b | 754 | cmpult $7, $5, $5; \ |
HannesTschofenig | 0:796d0f61a05b | 755 | stq $7, 0($2); \ |
HannesTschofenig | 0:796d0f61a05b | 756 | addq $2, 8, $2; \ |
HannesTschofenig | 0:796d0f61a05b | 757 | addq $6, $3, $3; \ |
HannesTschofenig | 0:796d0f61a05b | 758 | addq $5, $3, $3; \ |
HannesTschofenig | 0:796d0f61a05b | 759 | " |
HannesTschofenig | 0:796d0f61a05b | 760 | |
HannesTschofenig | 0:796d0f61a05b | 761 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 762 | " \ |
HannesTschofenig | 0:796d0f61a05b | 763 | stq $3, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 764 | stq $2, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 765 | stq $1, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 766 | " \ |
HannesTschofenig | 0:796d0f61a05b | 767 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 768 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 769 | : "$1", "$2", "$3", "$4", "$5", "$6", "$7" \ |
HannesTschofenig | 0:796d0f61a05b | 770 | ); |
HannesTschofenig | 0:796d0f61a05b | 771 | #endif /* Alpha */ |
HannesTschofenig | 0:796d0f61a05b | 772 | |
HannesTschofenig | 0:796d0f61a05b | 773 | #if defined(__mips__) && !defined(__mips64__) |
HannesTschofenig | 0:796d0f61a05b | 774 | |
HannesTschofenig | 0:796d0f61a05b | 775 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 776 | asm( \ |
HannesTschofenig | 0:796d0f61a05b | 777 | " \ |
HannesTschofenig | 0:796d0f61a05b | 778 | lw $10, %3; \ |
HannesTschofenig | 0:796d0f61a05b | 779 | lw $11, %4; \ |
HannesTschofenig | 0:796d0f61a05b | 780 | lw $12, %5; \ |
HannesTschofenig | 0:796d0f61a05b | 781 | lw $13, %6; \ |
HannesTschofenig | 0:796d0f61a05b | 782 | " |
HannesTschofenig | 0:796d0f61a05b | 783 | |
HannesTschofenig | 0:796d0f61a05b | 784 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 785 | " \ |
HannesTschofenig | 0:796d0f61a05b | 786 | lw $14, 0($10); \ |
HannesTschofenig | 0:796d0f61a05b | 787 | multu $13, $14; \ |
HannesTschofenig | 0:796d0f61a05b | 788 | addi $10, $10, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 789 | mflo $14; \ |
HannesTschofenig | 0:796d0f61a05b | 790 | mfhi $9; \ |
HannesTschofenig | 0:796d0f61a05b | 791 | addu $14, $12, $14; \ |
HannesTschofenig | 0:796d0f61a05b | 792 | lw $15, 0($11); \ |
HannesTschofenig | 0:796d0f61a05b | 793 | sltu $12, $14, $12; \ |
HannesTschofenig | 0:796d0f61a05b | 794 | addu $15, $14, $15; \ |
HannesTschofenig | 0:796d0f61a05b | 795 | sltu $14, $15, $14; \ |
HannesTschofenig | 0:796d0f61a05b | 796 | addu $12, $12, $9; \ |
HannesTschofenig | 0:796d0f61a05b | 797 | sw $15, 0($11); \ |
HannesTschofenig | 0:796d0f61a05b | 798 | addu $12, $12, $14; \ |
HannesTschofenig | 0:796d0f61a05b | 799 | addi $11, $11, 4; \ |
HannesTschofenig | 0:796d0f61a05b | 800 | " |
HannesTschofenig | 0:796d0f61a05b | 801 | |
HannesTschofenig | 0:796d0f61a05b | 802 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 803 | " \ |
HannesTschofenig | 0:796d0f61a05b | 804 | sw $12, %0; \ |
HannesTschofenig | 0:796d0f61a05b | 805 | sw $11, %1; \ |
HannesTschofenig | 0:796d0f61a05b | 806 | sw $10, %2; \ |
HannesTschofenig | 0:796d0f61a05b | 807 | " \ |
HannesTschofenig | 0:796d0f61a05b | 808 | : "=m" (c), "=m" (d), "=m" (s) \ |
HannesTschofenig | 0:796d0f61a05b | 809 | : "m" (s), "m" (d), "m" (c), "m" (b) \ |
HannesTschofenig | 0:796d0f61a05b | 810 | : "$9", "$10", "$11", "$12", "$13", "$14", "$15" \ |
HannesTschofenig | 0:796d0f61a05b | 811 | ); |
HannesTschofenig | 0:796d0f61a05b | 812 | |
HannesTschofenig | 0:796d0f61a05b | 813 | #endif /* MIPS */ |
HannesTschofenig | 0:796d0f61a05b | 814 | #endif /* GNUC */ |
HannesTschofenig | 0:796d0f61a05b | 815 | |
HannesTschofenig | 0:796d0f61a05b | 816 | #if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) |
HannesTschofenig | 0:796d0f61a05b | 817 | |
HannesTschofenig | 0:796d0f61a05b | 818 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 819 | __asm mov esi, s \ |
HannesTschofenig | 0:796d0f61a05b | 820 | __asm mov edi, d \ |
HannesTschofenig | 0:796d0f61a05b | 821 | __asm mov ecx, c \ |
HannesTschofenig | 0:796d0f61a05b | 822 | __asm mov ebx, b |
HannesTschofenig | 0:796d0f61a05b | 823 | |
HannesTschofenig | 0:796d0f61a05b | 824 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 825 | __asm lodsd \ |
HannesTschofenig | 0:796d0f61a05b | 826 | __asm mul ebx \ |
HannesTschofenig | 0:796d0f61a05b | 827 | __asm add eax, ecx \ |
HannesTschofenig | 0:796d0f61a05b | 828 | __asm adc edx, 0 \ |
HannesTschofenig | 0:796d0f61a05b | 829 | __asm add eax, [edi] \ |
HannesTschofenig | 0:796d0f61a05b | 830 | __asm adc edx, 0 \ |
HannesTschofenig | 0:796d0f61a05b | 831 | __asm mov ecx, edx \ |
HannesTschofenig | 0:796d0f61a05b | 832 | __asm stosd |
HannesTschofenig | 0:796d0f61a05b | 833 | |
HannesTschofenig | 0:796d0f61a05b | 834 | #if defined(POLARSSL_HAVE_SSE2) |
HannesTschofenig | 0:796d0f61a05b | 835 | |
HannesTschofenig | 0:796d0f61a05b | 836 | #define EMIT __asm _emit |
HannesTschofenig | 0:796d0f61a05b | 837 | |
HannesTschofenig | 0:796d0f61a05b | 838 | #define MULADDC_HUIT \ |
HannesTschofenig | 0:796d0f61a05b | 839 | EMIT 0x0F EMIT 0x6E EMIT 0xC9 \ |
HannesTschofenig | 0:796d0f61a05b | 840 | EMIT 0x0F EMIT 0x6E EMIT 0xC3 \ |
HannesTschofenig | 0:796d0f61a05b | 841 | EMIT 0x0F EMIT 0x6E EMIT 0x1F \ |
HannesTschofenig | 0:796d0f61a05b | 842 | EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ |
HannesTschofenig | 0:796d0f61a05b | 843 | EMIT 0x0F EMIT 0x6E EMIT 0x16 \ |
HannesTschofenig | 0:796d0f61a05b | 844 | EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ |
HannesTschofenig | 0:796d0f61a05b | 845 | EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \ |
HannesTschofenig | 0:796d0f61a05b | 846 | EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ |
HannesTschofenig | 0:796d0f61a05b | 847 | EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \ |
HannesTschofenig | 0:796d0f61a05b | 848 | EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ |
HannesTschofenig | 0:796d0f61a05b | 849 | EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \ |
HannesTschofenig | 0:796d0f61a05b | 850 | EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \ |
HannesTschofenig | 0:796d0f61a05b | 851 | EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ |
HannesTschofenig | 0:796d0f61a05b | 852 | EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \ |
HannesTschofenig | 0:796d0f61a05b | 853 | EMIT 0x0F EMIT 0xD4 EMIT 0xDC \ |
HannesTschofenig | 0:796d0f61a05b | 854 | EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \ |
HannesTschofenig | 0:796d0f61a05b | 855 | EMIT 0x0F EMIT 0xD4 EMIT 0xEE \ |
HannesTschofenig | 0:796d0f61a05b | 856 | EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \ |
HannesTschofenig | 0:796d0f61a05b | 857 | EMIT 0x0F EMIT 0xD4 EMIT 0xFC \ |
HannesTschofenig | 0:796d0f61a05b | 858 | EMIT 0x0F EMIT 0x7E EMIT 0x0F \ |
HannesTschofenig | 0:796d0f61a05b | 859 | EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \ |
HannesTschofenig | 0:796d0f61a05b | 860 | EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \ |
HannesTschofenig | 0:796d0f61a05b | 861 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 862 | EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \ |
HannesTschofenig | 0:796d0f61a05b | 863 | EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \ |
HannesTschofenig | 0:796d0f61a05b | 864 | EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ |
HannesTschofenig | 0:796d0f61a05b | 865 | EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \ |
HannesTschofenig | 0:796d0f61a05b | 866 | EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \ |
HannesTschofenig | 0:796d0f61a05b | 867 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \ |
HannesTschofenig | 0:796d0f61a05b | 868 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 869 | EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \ |
HannesTschofenig | 0:796d0f61a05b | 870 | EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \ |
HannesTschofenig | 0:796d0f61a05b | 871 | EMIT 0x0F EMIT 0xD4 EMIT 0xCD \ |
HannesTschofenig | 0:796d0f61a05b | 872 | EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \ |
HannesTschofenig | 0:796d0f61a05b | 873 | EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \ |
HannesTschofenig | 0:796d0f61a05b | 874 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \ |
HannesTschofenig | 0:796d0f61a05b | 875 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 876 | EMIT 0x0F EMIT 0xD4 EMIT 0xCF \ |
HannesTschofenig | 0:796d0f61a05b | 877 | EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \ |
HannesTschofenig | 0:796d0f61a05b | 878 | EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \ |
HannesTschofenig | 0:796d0f61a05b | 879 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \ |
HannesTschofenig | 0:796d0f61a05b | 880 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 881 | EMIT 0x0F EMIT 0xD4 EMIT 0xCA \ |
HannesTschofenig | 0:796d0f61a05b | 882 | EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \ |
HannesTschofenig | 0:796d0f61a05b | 883 | EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \ |
HannesTschofenig | 0:796d0f61a05b | 884 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \ |
HannesTschofenig | 0:796d0f61a05b | 885 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 886 | EMIT 0x0F EMIT 0xD4 EMIT 0xCC \ |
HannesTschofenig | 0:796d0f61a05b | 887 | EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \ |
HannesTschofenig | 0:796d0f61a05b | 888 | EMIT 0x0F EMIT 0xD4 EMIT 0xDD \ |
HannesTschofenig | 0:796d0f61a05b | 889 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \ |
HannesTschofenig | 0:796d0f61a05b | 890 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 891 | EMIT 0x0F EMIT 0xD4 EMIT 0xCE \ |
HannesTschofenig | 0:796d0f61a05b | 892 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \ |
HannesTschofenig | 0:796d0f61a05b | 893 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 894 | EMIT 0x0F EMIT 0xD4 EMIT 0xCB \ |
HannesTschofenig | 0:796d0f61a05b | 895 | EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \ |
HannesTschofenig | 0:796d0f61a05b | 896 | EMIT 0x83 EMIT 0xC7 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 897 | EMIT 0x83 EMIT 0xC6 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 898 | EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \ |
HannesTschofenig | 0:796d0f61a05b | 899 | EMIT 0x0F EMIT 0x7E EMIT 0xC9 |
HannesTschofenig | 0:796d0f61a05b | 900 | |
HannesTschofenig | 0:796d0f61a05b | 901 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 902 | EMIT 0x0F EMIT 0x77 \ |
HannesTschofenig | 0:796d0f61a05b | 903 | __asm mov c, ecx \ |
HannesTschofenig | 0:796d0f61a05b | 904 | __asm mov d, edi \ |
HannesTschofenig | 0:796d0f61a05b | 905 | __asm mov s, esi \ |
HannesTschofenig | 0:796d0f61a05b | 906 | |
HannesTschofenig | 0:796d0f61a05b | 907 | #else |
HannesTschofenig | 0:796d0f61a05b | 908 | |
HannesTschofenig | 0:796d0f61a05b | 909 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 910 | __asm mov c, ecx \ |
HannesTschofenig | 0:796d0f61a05b | 911 | __asm mov d, edi \ |
HannesTschofenig | 0:796d0f61a05b | 912 | __asm mov s, esi \ |
HannesTschofenig | 0:796d0f61a05b | 913 | |
HannesTschofenig | 0:796d0f61a05b | 914 | #endif /* SSE2 */ |
HannesTschofenig | 0:796d0f61a05b | 915 | #endif /* MSVC */ |
HannesTschofenig | 0:796d0f61a05b | 916 | |
HannesTschofenig | 0:796d0f61a05b | 917 | #endif /* POLARSSL_HAVE_ASM */ |
HannesTschofenig | 0:796d0f61a05b | 918 | |
HannesTschofenig | 0:796d0f61a05b | 919 | #if !defined(MULADDC_CORE) |
HannesTschofenig | 0:796d0f61a05b | 920 | #if defined(POLARSSL_HAVE_UDBL) |
HannesTschofenig | 0:796d0f61a05b | 921 | |
HannesTschofenig | 0:796d0f61a05b | 922 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 923 | { \ |
HannesTschofenig | 0:796d0f61a05b | 924 | t_udbl r; \ |
HannesTschofenig | 0:796d0f61a05b | 925 | t_uint r0, r1; |
HannesTschofenig | 0:796d0f61a05b | 926 | |
HannesTschofenig | 0:796d0f61a05b | 927 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 928 | r = *(s++) * (t_udbl) b; \ |
HannesTschofenig | 0:796d0f61a05b | 929 | r0 = r; \ |
HannesTschofenig | 0:796d0f61a05b | 930 | r1 = r >> biL; \ |
HannesTschofenig | 0:796d0f61a05b | 931 | r0 += c; r1 += (r0 < c); \ |
HannesTschofenig | 0:796d0f61a05b | 932 | r0 += *d; r1 += (r0 < *d); \ |
HannesTschofenig | 0:796d0f61a05b | 933 | c = r1; *(d++) = r0; |
HannesTschofenig | 0:796d0f61a05b | 934 | |
HannesTschofenig | 0:796d0f61a05b | 935 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 936 | } |
HannesTschofenig | 0:796d0f61a05b | 937 | |
HannesTschofenig | 0:796d0f61a05b | 938 | #else |
HannesTschofenig | 0:796d0f61a05b | 939 | #define MULADDC_INIT \ |
HannesTschofenig | 0:796d0f61a05b | 940 | { \ |
HannesTschofenig | 0:796d0f61a05b | 941 | t_uint s0, s1, b0, b1; \ |
HannesTschofenig | 0:796d0f61a05b | 942 | t_uint r0, r1, rx, ry; \ |
HannesTschofenig | 0:796d0f61a05b | 943 | b0 = ( b << biH ) >> biH; \ |
HannesTschofenig | 0:796d0f61a05b | 944 | b1 = ( b >> biH ); |
HannesTschofenig | 0:796d0f61a05b | 945 | |
HannesTschofenig | 0:796d0f61a05b | 946 | #define MULADDC_CORE \ |
HannesTschofenig | 0:796d0f61a05b | 947 | s0 = ( *s << biH ) >> biH; \ |
HannesTschofenig | 0:796d0f61a05b | 948 | s1 = ( *s >> biH ); s++; \ |
HannesTschofenig | 0:796d0f61a05b | 949 | rx = s0 * b1; r0 = s0 * b0; \ |
HannesTschofenig | 0:796d0f61a05b | 950 | ry = s1 * b0; r1 = s1 * b1; \ |
HannesTschofenig | 0:796d0f61a05b | 951 | r1 += ( rx >> biH ); \ |
HannesTschofenig | 0:796d0f61a05b | 952 | r1 += ( ry >> biH ); \ |
HannesTschofenig | 0:796d0f61a05b | 953 | rx <<= biH; ry <<= biH; \ |
HannesTschofenig | 0:796d0f61a05b | 954 | r0 += rx; r1 += (r0 < rx); \ |
HannesTschofenig | 0:796d0f61a05b | 955 | r0 += ry; r1 += (r0 < ry); \ |
HannesTschofenig | 0:796d0f61a05b | 956 | r0 += c; r1 += (r0 < c); \ |
HannesTschofenig | 0:796d0f61a05b | 957 | r0 += *d; r1 += (r0 < *d); \ |
HannesTschofenig | 0:796d0f61a05b | 958 | c = r1; *(d++) = r0; |
HannesTschofenig | 0:796d0f61a05b | 959 | |
HannesTschofenig | 0:796d0f61a05b | 960 | #define MULADDC_STOP \ |
HannesTschofenig | 0:796d0f61a05b | 961 | } |
HannesTschofenig | 0:796d0f61a05b | 962 | |
HannesTschofenig | 0:796d0f61a05b | 963 | #endif /* C (generic) */ |
HannesTschofenig | 0:796d0f61a05b | 964 | #endif /* C (longlong) */ |
HannesTschofenig | 0:796d0f61a05b | 965 | |
HannesTschofenig | 0:796d0f61a05b | 966 | #endif /* bn_mul.h */ |
HannesTschofenig | 0:796d0f61a05b | 967 | |
HannesTschofenig | 0:796d0f61a05b | 968 |