internal-tinyjambu-armv7m.S 8.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
#if defined(__ARM_ARCH_ISA_THUMB) && __ARM_ARCH == 7
/*
 * Copyright (C) 2021 Southern Storm Software, Pty Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

	.syntax unified
	.thumb
	.text

	.align	2
	.global	tiny_jambu_permutation_128
	.thumb
	.thumb_func
	.type	tiny_jambu_permutation_128, %function
tiny_jambu_permutation_128:
	push	{r4, r5, r6, r7, r8, r9, r10}
	ldr	r3, [r0, #0]
	ldr	r4, [r0, #4]
	ldr	r5, [r0, #8]
	ldr	r6, [r0, #12]
	ldr	r7, [r1, #0]
	ldr	r8, [r1, #4]
	ldr	r9, [r1, #8]
	ldr	r10, [r1, #12]
.L128:
	eor	r3, r3, r4, lsr #15
	eor	r3, r3, r5, lsl #17
	eor	r3, r3, r5, lsr #27
	eor	r3, r3, r6, lsl #5
	lsr	r1, r5, #6
	lsr	ip, r5, #21
	eor	r1, r1, r6, lsl #26
	eor	ip, ip, r6, lsl #11
	and	r1, ip
	eors	r3, r1
	eors	r3, r7
	eor	r4, r4, r5, lsr #15
	eor	r4, r4, r6, lsl #17
	eor	r4, r4, r6, lsr #27
	eor	r4, r4, r3, lsl #5
	lsr	r1, r6, #6
	lsr	ip, r6, #21
	eor	r1, r1, r3, lsl #26
	eor	ip, ip, r3, lsl #11
	and	r1, ip
	eors	r4, r1
	eor	r4, r8
	eor	r5, r5, r6, lsr #15
	eor	r5, r5, r3, lsl #17
	eor	r5, r5, r3, lsr #27
	eor	r5, r5, r4, lsl #5
	lsr	r1, r3, #6
	lsr	ip, r3, #21
	eor	r1, r1, r4, lsl #26
	eor	ip, ip, r4, lsl #11
	and	r1, ip
	eors	r5, r1
	eor	r5, r9
	eor	r6, r6, r3, lsr #15
	eor	r6, r6, r4, lsl #17
	eor	r6, r6, r4, lsr #27
	eor	r6, r6, r5, lsl #5
	lsr	r1, r4, #6
	lsr	ip, r4, #21
	eor	r1, r1, r5, lsl #26
	eor	ip, ip, r5, lsl #11
	and	r1, ip
	eors	r6, r1
	eor	r6, r10
	subs	r2, r2, #1
	bne	.L128
	str	r3, [r0, #0]
	str	r4, [r0, #4]
	str	r5, [r0, #8]
	str	r6, [r0, #12]
	pop	{r4, r5, r6, r7, r8, r9, r10}
	bx	lr
	.size	tiny_jambu_permutation_128, .-tiny_jambu_permutation_128

	.align	2
	.global	tiny_jambu_permutation_192
	.thumb
	.thumb_func
	.type	tiny_jambu_permutation_192, %function
tiny_jambu_permutation_192:
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	ldr	r3, [r0, #0]
	ldr	r4, [r0, #4]
	ldr	r5, [r0, #8]
	ldr	r6, [r0, #12]
	ldr	r7, [r1, #0]
	ldr	r8, [r1, #4]
	ldr	r9, [r1, #8]
	ldr	r10, [r1, #12]
	ldr	fp, [r1, #16]
	ldr	lr, [r1, #20]
.L1921:
	eor	r3, r3, r4, lsr #15
	eor	r3, r3, r5, lsl #17
	eor	r3, r3, r5, lsr #27
	eor	r3, r3, r6, lsl #5
	lsr	r1, r5, #6
	lsr	ip, r5, #21
	eor	r1, r1, r6, lsl #26
	eor	ip, ip, r6, lsl #11
	and	r1, ip
	eors	r3, r1
	eors	r3, r7
	eor	r4, r4, r5, lsr #15
	eor	r4, r4, r6, lsl #17
	eor	r4, r4, r6, lsr #27
	eor	r4, r4, r3, lsl #5
	lsr	r1, r6, #6
	lsr	ip, r6, #21
	eor	r1, r1, r3, lsl #26
	eor	ip, ip, r3, lsl #11
	and	r1, ip
	eors	r4, r1
	eor	r4, r8
	eor	r5, r5, r6, lsr #15
	eor	r5, r5, r3, lsl #17
	eor	r5, r5, r3, lsr #27
	eor	r5, r5, r4, lsl #5
	lsr	r1, r3, #6
	lsr	ip, r3, #21
	eor	r1, r1, r4, lsl #26
	eor	ip, ip, r4, lsl #11
	and	r1, ip
	eors	r5, r1
	eor	r5, r9
	eor	r6, r6, r3, lsr #15
	eor	r6, r6, r4, lsl #17
	eor	r6, r6, r4, lsr #27
	eor	r6, r6, r5, lsl #5
	lsr	r1, r4, #6
	lsr	ip, r4, #21
	eor	r1, r1, r5, lsl #26
	eor	ip, ip, r5, lsl #11
	and	r1, ip
	eors	r6, r1
	eor	r6, r10
	subs	r2, r2, #1
	beq	.L1922
	eor	r3, r3, r4, lsr #15
	eor	r3, r3, r5, lsl #17
	eor	r3, r3, r5, lsr #27
	eor	r3, r3, r6, lsl #5
	lsr	r1, r5, #6
	lsr	ip, r5, #21
	eor	r1, r1, r6, lsl #26
	eor	ip, ip, r6, lsl #11
	and	r1, ip
	eors	r3, r1
	eor	r3, fp
	eor	r4, r4, r5, lsr #15
	eor	r4, r4, r6, lsl #17
	eor	r4, r4, r6, lsr #27
	eor	r4, r4, r3, lsl #5
	lsr	r1, r6, #6
	lsr	ip, r6, #21
	eor	r1, r1, r3, lsl #26
	eor	ip, ip, r3, lsl #11
	and	r1, ip
	eors	r4, r1
	eor	r4, lr
	eor	r5, r5, r6, lsr #15
	eor	r5, r5, r3, lsl #17
	eor	r5, r5, r3, lsr #27
	eor	r5, r5, r4, lsl #5
	lsr	r1, r3, #6
	lsr	ip, r3, #21
	eor	r1, r1, r4, lsl #26
	eor	ip, ip, r4, lsl #11
	and	r1, ip
	eors	r5, r1
	eors	r5, r7
	eor	r6, r6, r3, lsr #15
	eor	r6, r6, r4, lsl #17
	eor	r6, r6, r4, lsr #27
	eor	r6, r6, r5, lsl #5
	lsr	r1, r4, #6
	lsr	ip, r4, #21
	eor	r1, r1, r5, lsl #26
	eor	ip, ip, r5, lsl #11
	and	r1, ip
	eors	r6, r1
	eor	r6, r8
	subs	r2, r2, #1
	beq	.L1922
	eor	r3, r3, r4, lsr #15
	eor	r3, r3, r5, lsl #17
	eor	r3, r3, r5, lsr #27
	eor	r3, r3, r6, lsl #5
	lsr	r1, r5, #6
	lsr	ip, r5, #21
	eor	r1, r1, r6, lsl #26
	eor	ip, ip, r6, lsl #11
	and	r1, ip
	eors	r3, r1
	eor	r3, r9
	eor	r4, r4, r5, lsr #15
	eor	r4, r4, r6, lsl #17
	eor	r4, r4, r6, lsr #27
	eor	r4, r4, r3, lsl #5
	lsr	r1, r6, #6
	lsr	ip, r6, #21
	eor	r1, r1, r3, lsl #26
	eor	ip, ip, r3, lsl #11
	and	r1, ip
	eors	r4, r1
	eor	r4, r10
	eor	r5, r5, r6, lsr #15
	eor	r5, r5, r3, lsl #17
	eor	r5, r5, r3, lsr #27
	eor	r5, r5, r4, lsl #5
	lsr	r1, r3, #6
	lsr	ip, r3, #21
	eor	r1, r1, r4, lsl #26
	eor	ip, ip, r4, lsl #11
	and	r1, ip
	eors	r5, r1
	eor	r5, fp
	eor	r6, r6, r3, lsr #15
	eor	r6, r6, r4, lsl #17
	eor	r6, r6, r4, lsr #27
	eor	r6, r6, r5, lsl #5
	lsr	r1, r4, #6
	lsr	ip, r4, #21
	eor	r1, r1, r5, lsl #26
	eor	ip, ip, r5, lsl #11
	and	r1, ip
	eors	r6, r1
	eor	r6, lr
	subs	r2, r2, #1
	bne	.L1921
.L1922:
	str	r3, [r0, #0]
	str	r4, [r0, #4]
	str	r5, [r0, #8]
	str	r6, [r0, #12]
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
	.size	tiny_jambu_permutation_192, .-tiny_jambu_permutation_192

	.align	2
	.global	tiny_jambu_permutation_256
	.thumb
	.thumb_func
	.type	tiny_jambu_permutation_256, %function
tiny_jambu_permutation_256:
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	ldr	r3, [r0, #0]
	ldr	r4, [r0, #4]
	ldr	r5, [r0, #8]
	ldr	r6, [r0, #12]
	ldr	r8, [r1, #0]
	ldr	r9, [r1, #4]
	ldr	r10, [r1, #8]
	ldr	fp, [r1, #12]
	ldr	lr, [r1, #16]
.L2561:
	eor	r3, r3, r4, lsr #15
	eor	r3, r3, r5, lsl #17
	eor	r3, r3, r5, lsr #27
	eor	r3, r3, r6, lsl #5
	lsr	r7, r5, #6
	lsr	ip, r5, #21
	eor	r7, r7, r6, lsl #26
	eor	ip, ip, r6, lsl #11
	and	r7, ip
	eors	r3, r7
	eor	r3, r8
	eor	r4, r4, r5, lsr #15
	eor	r4, r4, r6, lsl #17
	eor	r4, r4, r6, lsr #27
	eor	r4, r4, r3, lsl #5
	lsr	r7, r6, #6
	lsr	ip, r6, #21
	eor	r7, r7, r3, lsl #26
	eor	ip, ip, r3, lsl #11
	and	r7, ip
	eors	r4, r7
	eor	r4, r9
	eor	r5, r5, r6, lsr #15
	eor	r5, r5, r3, lsl #17
	eor	r5, r5, r3, lsr #27
	eor	r5, r5, r4, lsl #5
	lsr	r7, r3, #6
	lsr	ip, r3, #21
	eor	r7, r7, r4, lsl #26
	eor	ip, ip, r4, lsl #11
	and	r7, ip
	eors	r5, r7
	eor	r5, r10
	eor	r6, r6, r3, lsr #15
	eor	r6, r6, r4, lsl #17
	eor	r6, r6, r4, lsr #27
	eor	r6, r6, r5, lsl #5
	lsr	r7, r4, #6
	lsr	ip, r4, #21
	eor	r7, r7, r5, lsl #26
	eor	ip, ip, r5, lsl #11
	and	r7, ip
	eors	r6, r7
	eor	r6, fp
	subs	r2, r2, #1
	beq	.L2562
	eor	r3, r3, r4, lsr #15
	eor	r3, r3, r5, lsl #17
	eor	r3, r3, r5, lsr #27
	eor	r3, r3, r6, lsl #5
	lsr	r7, r5, #6
	lsr	ip, r5, #21
	eor	r7, r7, r6, lsl #26
	eor	ip, ip, r6, lsl #11
	and	r7, ip
	eors	r3, r7
	eor	r3, lr
	eor	r4, r4, r5, lsr #15
	eor	r4, r4, r6, lsl #17
	eor	r4, r4, r6, lsr #27
	eor	r4, r4, r3, lsl #5
	lsr	r7, r6, #6
	lsr	ip, r6, #21
	eor	r7, r7, r3, lsl #26
	eor	ip, ip, r3, lsl #11
	and	r7, ip
	eors	r4, r7
	ldr	r7, [r1, #20]
	eors	r4, r7
	eor	r5, r5, r6, lsr #15
	eor	r5, r5, r3, lsl #17
	eor	r5, r5, r3, lsr #27
	eor	r5, r5, r4, lsl #5
	lsr	r7, r3, #6
	lsr	ip, r3, #21
	eor	r7, r7, r4, lsl #26
	eor	ip, ip, r4, lsl #11
	and	r7, ip
	eors	r5, r7
	ldr	r7, [r1, #24]
	eors	r5, r7
	eor	r6, r6, r3, lsr #15
	eor	r6, r6, r4, lsl #17
	eor	r6, r6, r4, lsr #27
	eor	r6, r6, r5, lsl #5
	lsr	r7, r4, #6
	lsr	ip, r4, #21
	eor	r7, r7, r5, lsl #26
	eor	ip, ip, r5, lsl #11
	and	r7, ip
	eors	r6, r7
	ldr	r7, [r1, #28]
	eors	r6, r7
	subs	r2, r2, #1
	bne	.L2561
.L2562:
	str	r3, [r0, #0]
	str	r4, [r0, #4]
	str	r5, [r0, #8]
	str	r6, [r0, #12]
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
	.size	tiny_jambu_permutation_256, .-tiny_jambu_permutation_256

#endif