summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2013-07-05 21:10:50 +0000
committermiod <>2013-07-05 21:10:50 +0000
commit17bc5bda644bdaaa03d4132e0df2fdb3c496050a (patch)
tree361df516c6b074d62efda905d32c5d368de76b7b
parent120d51ade73f4026bf4990061484c8c3dd3cc29d (diff)
downloadopenbsd-17bc5bda644bdaaa03d4132e0df2fdb3c496050a.tar.gz
openbsd-17bc5bda644bdaaa03d4132e0df2fdb3c496050a.tar.bz2
openbsd-17bc5bda644bdaaa03d4132e0df2fdb3c496050a.zip
VAX ELF userland bits. Consists mostly of register prefix additions.
-rw-r--r--src/lib/libssl/crypto/arch/vax/bn_asm_vax.S302
1 files changed, 151 insertions, 151 deletions
diff --git a/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S b/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S
index f1e46b2010..efa9b6ebd6 100644
--- a/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S
+++ b/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S
@@ -1,4 +1,4 @@
1# $OpenBSD: bn_asm_vax.S,v 1.2 2012/10/13 21:31:56 djm Exp $ 1# $OpenBSD: bn_asm_vax.S,v 1.3 2013/07/05 21:10:50 miod Exp $
2# $NetBSD: bn_asm_vax.S,v 1.1 2003/11/03 10:22:28 ragge Exp $ 2# $NetBSD: bn_asm_vax.S,v 1.1 2003/11/03 10:22:28 ragge Exp $
3 3
4#include <machine/asm.h> 4#include <machine/asm.h>
@@ -15,38 +15,38 @@
15# } 15# }
16 16
17ENTRY(bn_mul_add_words,R6) 17ENTRY(bn_mul_add_words,R6)
18 movl 4(ap),r2 # *r 18 movl 4(%ap),%r2 # *r
19 movl 8(ap),r3 # *a 19 movl 8(%ap),%r3 # *a
20 movl 12(ap),r4 # n 20 movl 12(%ap),%r4 # n
21 movl 16(ap),r5 # w 21 movl 16(%ap),%r5 # w
22 clrl r6 # return value ("carry") 22 clrl %r6 # return value ("carry")
23 23
240: emul r5,(r3),(r2),r0 # w * a[0] + r[0] -> r0 240: emul %r5,(%r3),(%r2),%r0 # w * a[0] + r[0] -> r0
25 25
26 # fixup for "negative" r[] 26 # fixup for "negative" r[]
27 tstl (r2) 27 tstl (%r2)
28 bgeq 1f 28 bgeq 1f
29 incl r1 # add 1 to highword 29 incl %r1 # add 1 to highword
30 30
311: # add saved carry to result 311: # add saved carry to result
32 addl2 r6,r0 32 addl2 %r6,%r0
33 adwc $0,r1 33 adwc $0,%r1
34 34
35 # combined fixup for "negative" w, a[] 35 # combined fixup for "negative" w, a[]
36 tstl r5 # if w is negative... 36 tstl %r5 # if w is negative...
37 bgeq 1f 37 bgeq 1f
38 addl2 (r3),r1 # ...add a[0] again to highword 38 addl2 (%r3),%r1 # ...add a[0] again to highword
391: tstl (r3) # if a[0] is negative... 391: tstl (%r3) # if a[0] is negative...
40 bgeq 1f 40 bgeq 1f
41 addl2 r5,r1 # ...add w again to highword 41 addl2 %r5,%r1 # ...add w again to highword
421: 421:
43 movl r0,(r2)+ # save low word in dest & advance *r 43 movl %r0,(%r2)+ # save low word in dest & advance *r
44 addl2 $4,r3 # advance *a 44 addl2 $4,%r3 # advance *a
45 movl r1,r6 # high word in r6 for return value 45 movl %r1,%r6 # high word in r6 for return value
46 46
47 sobgtr r4,0b # loop? 47 sobgtr %r4,0b # loop?
48 48
49 movl r6,r0 49 movl %r6,%r0
50 ret 50 ret
51 51
52# .title vax_bn_mul_words unsigned multiply & add, 32*32+32=>64 52# .title vax_bn_mul_words unsigned multiply & add, 32*32+32=>64
@@ -64,34 +64,34 @@ ENTRY(bn_mul_add_words,R6)
64# 64#
65 65
66ENTRY(bn_mul_words,R6) 66ENTRY(bn_mul_words,R6)
67 movl 4(ap),r2 # *r 67 movl 4(%ap),%r2 # *r
68 movl 8(ap),r3 # *a 68 movl 8(%ap),%r3 # *a
69 movl 12(ap),r4 # n 69 movl 12(%ap),%r4 # n
70 movl 16(ap),r5 # w 70 movl 16(%ap),%r5 # w
71 clrl r6 # carry 71 clrl %r6 # carry
72 72
730: emul r5,(r3),r6,r0 # w * a[0] + carry -> r0 730: emul %r5,(%r3),%r6,%r0 # w * a[0] + carry -> r0
74 74
75 # fixup for "negative" carry 75 # fixup for "negative" carry
76 tstl r6 76 tstl %r6
77 bgeq 1f 77 bgeq 1f
78 incl r1 78 incl %r1
79 79
801: # combined fixup for "negative" w, a[] 801: # combined fixup for "negative" w, a[]
81 tstl r5 81 tstl %r5
82 bgeq 1f 82 bgeq 1f
83 addl2 (r3),r1 83 addl2 (%r3),%r1
841: tstl (r3) 841: tstl (%r3)
85 bgeq 1f 85 bgeq 1f
86 addl2 r5,r1 86 addl2 %r5,%r1
87 87
881: movl r0,(r2)+ 881: movl %r0,(%r2)+
89 addl2 $4,r3 89 addl2 $4,%r3
90 movl r1,r6 90 movl %r1,%r6
91 91
92 sobgtr r4,0b 92 sobgtr %r4,0b
93 93
94 movl r6,r0 94 movl %r6,%r0
95 ret 95 ret
96 96
97 97
@@ -109,23 +109,23 @@ ENTRY(bn_mul_words,R6)
109# 109#
110 110
111ENTRY(bn_sqr_words,0) 111ENTRY(bn_sqr_words,0)
112 movl 4(ap),r2 # r 112 movl 4(%ap),%r2 # r
113 movl 8(ap),r3 # a 113 movl 8(%ap),%r3 # a
114 movl 12(ap),r4 # n 114 movl 12(%ap),%r4 # n
115 115
1160: movl (r3)+,r5 # r5 = a[] & advance 1160: movl (%r3)+,%r5 # r5 = a[] & advance
117 117
118 emul r5,r5,$0,r0 # a[0] * a[0] + 0 -> r0 118 emul %r5,%r5,$0,%r0 # a[0] * a[0] + 0 -> r0
119 119
120 # fixup for "negative" a[] 120 # fixup for "negative" a[]
121 tstl r5 121 tstl %r5
122 bgeq 1f 122 bgeq 1f
123 addl2 r5,r1 123 addl2 %r5,%r1
124 addl2 r5,r1 124 addl2 %r5,%r1
125 125
1261: movq r0,(r2)+ # store 64-bit result 1261: movq %r0,(%r2)+ # store 64-bit result
127 127
128 sobgtr r4,0b # loop 128 sobgtr %r4,0b # loop
129 129
130 ret 130 ret
131 131
@@ -219,90 +219,90 @@ ENTRY(bn_sqr_words,0)
219# 219#
220 220
221ENTRY(bn_div_words,R6|R7|R8) 221ENTRY(bn_div_words,R6|R7|R8)
222 movl 4(ap),r3 # h 222 movl 4(%ap),%r3 # h
223 movl 8(ap),r2 # l 223 movl 8(%ap),%r2 # l
224 movl 12(ap),r4 # d 224 movl 12(%ap),%r4 # d
225 225
226 bicl3 $-8,r2,r5 # l' = l & 7 226 bicl3 $-8,%r2,%r5 # l' = l & 7
227 bicl3 $7,r2,r2 227 bicl3 $7,%r2,%r2
228 228
229 bicl3 $-8,r3,r6 229 bicl3 $-8,%r3,%r6
230 bicl3 $7,r3,r3 230 bicl3 $7,%r3,%r3
231 231
232 addl2 r6,r2 232 addl2 %r6,%r2
233 233
234 rotl $-3,r2,r2 # l = l >> 3 234 rotl $-3,%r2,%r2 # l = l >> 3
235 rotl $-3,r3,r3 # h = h >> 3 235 rotl $-3,%r3,%r3 # h = h >> 3
236 236
237 movl r4,r7 # d' = d 237 movl %r4,%r7 # d' = d
238 238
239 clrl r6 # r' = 0 239 clrl %r6 # r' = 0
240 clrl r8 # q' = 0 240 clrl %r8 # q' = 0
241 241
242 tstl r4 242 tstl %r4
243 beql 0f # Uh-oh, the divisor is 0... 243 beql 0f # Uh-oh, the divisor is 0...
244 bgtr 1f 244 bgtr 1f
245 rotl $-1,r4,r4 # If d is negative, shift it right. 245 rotl $-1,%r4,%r4 # If d is negative, shift it right.
246 bicl2 $0x80000000,r4 # Since d is then a large number, the 246 bicl2 $0x80000000,%r4 # Since d is then a large number, the
247 # lowest bit is insignificant 247 # lowest bit is insignificant
248 # (contradict that, and I'll fix the problem!) 248 # (contradict that, and I'll fix the problem!)
2491: 2491:
250 ediv r4,r2,r2,r3 # Do the actual division 250 ediv %r4,%r2,%r2,%r3 # Do the actual division
251 251
252 tstl r2 252 tstl %r2
253 bgeq 1f 253 bgeq 1f
254 mnegl r2,r2 # if q < 0, negate it 254 mnegl %r2,%r2 # if q < 0, negate it
2551: 2551:
256 tstl r7 256 tstl %r7
257 blss 1f 257 blss 1f
258 rotl $3,r2,r2 # q = q << 3 258 rotl $3,%r2,%r2 # q = q << 3
259 bicl3 $-8,r2,r8 # q' gets the high bits from q 259 bicl3 $-8,%r2,%r8 # q' gets the high bits from q
260 bicl3 $7,r2,r2 260 bicl3 $7,%r2,%r2
261 brb 2f 261 brb 2f
262 262
2631: # else 2631: # else
264 rotl $2,r2,r2 # q = q << 2 264 rotl $2,%r2,%r2 # q = q << 2
265 bicl3 $-4,r2,r8 # q' gets the high bits from q 265 bicl3 $-4,%r2,%r8 # q' gets the high bits from q
266 bicl3 $3,r2,r2 266 bicl3 $3,%r2,%r2
2672: 2672:
268 rotl $3,r3,r3 # r = r << 3 268 rotl $3,%r3,%r3 # r = r << 3
269 bicl3 $-8,r3,r6 # r' gets the high bits from r 269 bicl3 $-8,%r3,%r6 # r' gets the high bits from r
270 bicl3 $7,r3,r3 270 bicl3 $7,%r3,%r3
271 addl2 r5,r3 # r = r + l' 271 addl2 %r5,%r3 # r = r + l'
272 272
273 tstl r7 273 tstl %r7
274 bgeq 5f 274 bgeq 5f
275 bitl $1,r7 275 bitl $1,%r7
276 beql 5f # if d' < 0 && d' & 1 276 beql 5f # if d' < 0 && d' & 1
277 subl2 r2,r3 # [r',r] = [r',r] - [q',q] 277 subl2 %r2,%r3 # [r',r] = [r',r] - [q',q]
278 sbwc r8,r6 278 sbwc %r8,%r6
2793: 2793:
280 bgeq 5f # while r < 0 280 bgeq 5f # while r < 0
281 decl r2 # [q',q] = [q',q] - 1 281 decl %r2 # [q',q] = [q',q] - 1
282 sbwc $0,r8 282 sbwc $0,%r8
283 addl2 r7,r3 # [r',r] = [r',r] + d' 283 addl2 %r7,%r3 # [r',r] = [r',r] + d'
284 adwc $0,r6 284 adwc $0,%r6
285 brb 3b 285 brb 3b
286 286
287# The return points are placed in the middle to keep a short distance from 287# The return points are placed in the middle to keep a short distance from
288# all the branch points 288# all the branch points
2891: 2891:
290# movl r3,r1 290# movl %r3,%r1
291 movl r2,r0 291 movl %r2,%r0
292 ret 292 ret
2930: 2930:
294 movl $-1,r0 294 movl $-1,%r0
295 ret 295 ret
2965: 2965:
297 tstl r6 297 tstl %r6
298 bneq 6f 298 bneq 6f
299 cmpl r3,r7 299 cmpl %r3,%r7
300 blssu 1b # while [r',r] >= d' 300 blssu 1b # while [r',r] >= d'
3016: 3016:
302 subl2 r7,r3 # [r',r] = [r',r] - d' 302 subl2 %r7,%r3 # [r',r] = [r',r] - d'
303 sbwc $0,r6 303 sbwc $0,%r6
304 incl r2 # [q',q] = [q',q] + 1 304 incl %r2 # [q',q] = [q',q] + 1
305 adwc $0,r8 305 adwc $0,%r8
306 brb 5b 306 brb 5b
307 307
308 308
@@ -320,21 +320,21 @@ ENTRY(bn_div_words,R6|R7|R8)
320# 320#
321 321
322ENTRY(bn_add_words,0) 322ENTRY(bn_add_words,0)
323 movl 4(ap),r2 # r 323 movl 4(%ap),%r2 # r
324 movl 8(ap),r3 # a 324 movl 8(%ap),%r3 # a
325 movl 12(ap),r4 # b 325 movl 12(%ap),%r4 # b
326 movl 16(ap),r5 # n 326 movl 16(%ap),%r5 # n
327 clrl r0 327 clrl %r0
328 328
329 tstl r5 329 tstl %r5
330 bleq 1f 330 bleq 1f
331 331
3320: movl (r3)+,r1 # carry untouched 3320: movl (%r3)+,%r1 # carry untouched
333 adwc (r4)+,r1 # carry used and touched 333 adwc (%r4)+,%r1 # carry used and touched
334 movl r1,(r2)+ # carry untouched 334 movl %r1,(%r2)+ # carry untouched
335 sobgtr r5,0b # carry untouched 335 sobgtr %r5,0b # carry untouched
336 336
337 adwc $0,r0 337 adwc $0,%r0
3381: ret 3381: ret
339 339
340#; 340#;
@@ -349,21 +349,21 @@ ENTRY(bn_add_words,0)
349# 349#
350 350
351ENTRY(bn_sub_words,R6) 351ENTRY(bn_sub_words,R6)
352 movl 4(ap),r2 # r 352 movl 4(%ap),%r2 # r
353 movl 8(ap),r3 # a 353 movl 8(%ap),%r3 # a
354 movl 12(ap),r4 # b 354 movl 12(%ap),%r4 # b
355 movl 16(ap),r5 # n 355 movl 16(%ap),%r5 # n
356 clrl r0 356 clrl %r0
357 357
358 tstl r5 358 tstl %r5
359 bleq 1f 359 bleq 1f
360 360
3610: movl (r3)+,r6 # carry untouched 3610: movl (%r3)+,%r6 # carry untouched
362 sbwc (r4)+,r6 # carry used and touched 362 sbwc (%r4)+,%r6 # carry used and touched
363 movl r6,(r2)+ # carry untouched 363 movl %r6,(%r2)+ # carry untouched
364 sobgtr r5,0b # carry untouched 364 sobgtr %r5,0b # carry untouched
365 365
3661: adwc $0,r0 3661: adwc $0,%r0
367 ret 367 ret
368 368
369# 369#
@@ -374,63 +374,63 @@ ENTRY(bn_sub_words,R6)
374# 374#
375 375
376ENTRY(bn_mul_comba4,R6|R7|R8|R9) 376ENTRY(bn_mul_comba4,R6|R7|R8|R9)
377 movl $4,r9 # 4*4 377 movl $4,%r9 # 4*4
378 brb 6f 378 brb 6f
379 379
380ENTRY(bn_mul_comba8,R6|R7|R8|R9) 380ENTRY(bn_mul_comba8,R6|R7|R8|R9)
381 movl $8,r9 # 8*8 381 movl $8,%r9 # 8*8
382 382
3836: movl 8(ap),r3 # a[] 3836: movl 8(%ap),%r3 # a[]
384 movl 12(ap),r7 # b[] 384 movl 12(%ap),%r7 # b[]
385 brb 5f 385 brb 5f
386 386
387ENTRY(bn_sqr_comba4,R6|R7|R8|R9) 387ENTRY(bn_sqr_comba4,R6|R7|R8|R9)
388 movl $4,r9 # 4*4 388 movl $4,%r9 # 4*4
389 brb 0f 389 brb 0f
390 390
391ENTRY(bn_sqr_comba8,R6|R7|R8|R9) 391ENTRY(bn_sqr_comba8,R6|R7|R8|R9)
392 movl $8,r9 # 8*8 392 movl $8,%r9 # 8*8
393 393
3940: 3940:
395 movl 8(ap),r3 # a[] 395 movl 8(%ap),%r3 # a[]
396 movl r3,r7 # a[] 396 movl %r3,%r7 # a[]
397 397
3985: movl 4(ap),r5 # r[] 3985: movl 4(%ap),%r5 # r[]
399 movl r9,r8 399 movl %r9,%r8
400 400
401 clrq (r5) # clear destinatino, for add. 401 clrq (%r5) # clear destinatino, for add.
402 clrq 8(r5) 402 clrq 8(%r5)
403 clrq 16(r5) # these only needed for comba8 403 clrq 16(%r5) # these only needed for comba8
404 clrq 24(r5) 404 clrq 24(%r5)
405 405
4062: clrl r4 # carry 4062: clrl %r4 # carry
407 movl r9,r6 # inner loop count 407 movl %r9,%r6 # inner loop count
408 movl (r7)+,r2 # value to multiply with 408 movl (%r7)+,%r2 # value to multiply with
409 409
4101: emul r2,(r3),r4,r0 4101: emul %r2,(%r3),%r4,%r0
411 tstl r4 411 tstl %r4
412 bgeq 3f 412 bgeq 3f
413 incl r1 413 incl %r1
4143: tstl r2 4143: tstl %r2
415 bgeq 3f 415 bgeq 3f
416 addl2 (r3),r1 416 addl2 (%r3),%r1
4173: tstl (r3) 4173: tstl (%r3)
418 bgeq 3f 418 bgeq 3f
419 addl2 r2,r1 419 addl2 %r2,%r1
420 420
4213: addl2 r0,(r5)+ # add to destination 4213: addl2 %r0,(%r5)+ # add to destination
422 adwc $0,r1 # remember carry 422 adwc $0,%r1 # remember carry
423 movl r1,r4 # add carry in next emul 423 movl %r1,%r4 # add carry in next emul
424 addl2 $4,r3 424 addl2 $4,%r3
425 sobgtr r6,1b 425 sobgtr %r6,1b
426 426
427 movl r4,(r5) # save highest add result 427 movl %r4,(%r5) # save highest add result
428 428
429 ashl $2,r9,r4 429 ashl $2,%r9,%r4
430 subl2 r4,r3 430 subl2 %r4,%r3
431 subl2 $4,r4 431 subl2 $4,%r4
432 subl2 r4,r5 432 subl2 %r4,%r5
433 433
434 sobgtr r8,2b 434 sobgtr %r8,2b
435 435
436 ret 436 ret