summaryrefslogtreecommitdiffstats
path: root/crypto/bn/asm/r3000.s
blob: 5be2a0d0e6bf2a02857499ebfaadbc2b1fb4c3a4 (plain)
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
	.file	1 "../bn_mulw.c"
	.set	nobopt
	.option pic2

 # GNU C 2.6.3 [AL 1.1, MM 40] SGI running IRIX 5.0 compiled by GNU C

 # Cc1 defaults:
 # -mabicalls

 # Cc1 arguments (-G value = 0, Cpu = 3000, ISA = 1):
 # -quiet -dumpbase -O2 -o

gcc2_compiled.:
__gnu_compiled_c:
	.rdata

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x34,0x39,0x20
	.byte	0x24,0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x33,0x34,0x20
	.byte	0x24,0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x35,0x20,0x24
	.byte	0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
	.byte	0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x32,0x33,0x20
	.byte	0x24,0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x37,0x38,0x20
	.byte	0x24,0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x33,0x2e,0x37,0x30,0x20
	.byte	0x24,0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x32,0x20,0x24
	.byte	0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x34,0x20,0x24
	.byte	0x0

	.byte	0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
	.byte	0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
	.byte	0x0
	.text
	.align	2
	.globl	bn_mul_add_word
	.ent	bn_mul_add_word
bn_mul_add_word:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, extra= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	.set	noreorder
	.cpload	$25
	.set	reorder
	move	$12,$4
	move	$14,$5
	move	$9,$6
	move	$13,$7
	move	$8,$0
	addu	$10,$12,12
	addu	$11,$14,12
$L2:
	lw	$6,0($14)
	#nop
	multu	$13,$6
	mfhi	$6
	mflo	$7
	#nop
	move	$5,$8
	move	$4,$0
	lw	$3,0($12)
	addu	$9,$9,-1
	move	$2,$0
	addu	$7,$7,$3
	sltu	$8,$7,$3
	addu	$6,$6,$2
	addu	$6,$6,$8
	addu	$7,$7,$5
	sltu	$2,$7,$5
	addu	$6,$6,$4
	addu	$6,$6,$2
	srl	$3,$6,0
	move	$2,$0
	move	$8,$3
	.set	noreorder
	.set	nomacro
	beq	$9,$0,$L3
	sw	$7,0($12)
	.set	macro
	.set	reorder

	lw	$6,-8($11)
	#nop
	multu	$13,$6
	mfhi	$6
	mflo	$7
	#nop
	move	$5,$8
	move	$4,$0
	lw	$3,-8($10)
	addu	$9,$9,-1
	move	$2,$0
	addu	$7,$7,$3
	sltu	$8,$7,$3
	addu	$6,$6,$2
	addu	$6,$6,$8
	addu	$7,$7,$5
	sltu	$2,$7,$5
	addu	$6,$6,$4
	addu	$6,$6,$2
	srl	$3,$6,0
	move	$2,$0
	move	$8,$3
	.set	noreorder
	.set	nomacro
	beq	$9,$0,$L3
	sw	$7,-8($10)
	.set	macro
	.set	reorder

	lw	$6,-4($11)
	#nop
	multu	$13,$6
	mfhi	$6
	mflo	$7
	#nop
	move	$5,$8
	move	$4,$0
	lw	$3,-4($10)
	addu	$9,$9,-1
	move	$2,$0
	addu	$7,$7,$3
	sltu	$8,$7,$3
	addu	$6,$6,$2
	addu	$6,$6,$8
	addu	$7,$7,$5
	sltu	$2,$7,$5
	addu	$6,$6,$4
	addu	$6,$6,$2
	srl	$3,$6,0
	move	$2,$0
	move	$8,$3
	.set	noreorder
	.set	nomacro
	beq	$9,$0,$L3
	sw	$7,-4($10)
	.set	macro
	.set	reorder

	lw	$6,0($11)
	#nop
	multu	$13,$6
	mfhi	$6
	mflo	$7
	#nop
	move	$5,$8
	move	$4,$0
	lw	$3,0($10)
	addu	$9,$9,-1
	move	$2,$0
	addu	$7,$7,$3
	sltu	$8,$7,$3
	addu	$6,$6,$2
	addu	$6,$6,$8
	addu	$7,$7,$5
	sltu	$2,$7,$5
	addu	$6,$6,$4
	addu	$6,$6,$2
	srl	$3,$6,0
	move	$2,$0
	move	$8,$3
	.set	noreorder
	.set	nomacro
	beq	$9,$0,$L3
	sw	$7,0($10)
	.set	macro
	.set	reorder

	addu	$11,$11,16
	addu	$14,$14,16
	addu	$10,$10,16
	.set	noreorder
	.set	nomacro
	j	$L2
	addu	$12,$12,16
	.set	macro
	.set	reorder

$L3:
	.set	noreorder
	.set	nomacro
	j	$31
	move	$2,$8
	.set	macro
	.set	reorder

	.end	bn_mul_add_word
	.align	2
	.globl	bn_mul_word
	.ent	bn_mul_word
bn_mul_word:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, extra= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	.set	noreorder
	.cpload	$25
	.set	reorder
	move	$11,$4
	move	$12,$5
	move	$8,$6
	move	$6,$0
	addu	$10,$11,12
	addu	$9,$12,12
$L10:
	lw	$4,0($12)
	#nop
	multu	$7,$4
	mfhi	$4
	mflo	$5
	#nop
	move	$3,$6
	move	$2,$0
	addu	$8,$8,-1
	addu	$5,$5,$3
	sltu	$6,$5,$3
	addu	$4,$4,$2
	addu	$4,$4,$6
	srl	$3,$4,0
	move	$2,$0
	move	$6,$3
	.set	noreorder
	.set	nomacro
	beq	$8,$0,$L11
	sw	$5,0($11)
	.set	macro
	.set	reorder

	lw	$4,-8($9)
	#nop
	multu	$7,$4
	mfhi	$4
	mflo	$5
	#nop
	move	$3,$6
	move	$2,$0
	addu	$8,$8,-1
	addu	$5,$5,$3
	sltu	$6,$5,$3
	addu	$4,$4,$2
	addu	$4,$4,$6
	srl	$3,$4,0
	move	$2,$0
	move	$6,$3
	.set	noreorder
	.set	nomacro
	beq	$8,$0,$L11
	sw	$5,-8($10)
	.set	macro
	.set	reorder

	lw	$4,-4($9)
	#nop
	multu	$7,$4
	mfhi	$4
	mflo	$5
	#nop
	move	$3,$6
	move	$2,$0
	addu	$8,$8,-1
	addu	$5,$5,$3
	sltu	$6,$5,$3
	addu	$4,$4,$2
	addu	$4,$4,$6
	srl	$3,$4,0
	move	$2,$0
	move	$6,$3
	.set	noreorder
	.set	nomacro
	beq	$8,$0,$L11
	sw	$5,-4($10)
	.set	macro
	.set	reorder

	lw	$4,0($9)
	#nop
	multu	$7,$4
	mfhi	$4
	mflo	$5
	#nop
	move	$3,$6
	move	$2,$0
	addu	$8,$8,-1
	addu	$5,$5,$3
	sltu	$6,$5,$3
	addu	$4,$4,$2
	addu	$4,$4,$6
	srl	$3,$4,0
	move	$2,$0
	move	$6,$3
	.set	noreorder
	.set	nomacro
	beq	$8,$0,$L11
	sw	$5,0($10)
	.set	macro
	.set	reorder

	addu	$9,$9,16
	addu	$12,$12,16
	addu	$10,$10,16
	.set	noreorder
	.set	nomacro
	j	$L10
	addu	$11,$11,16
	.set	macro
	.set	reorder

$L11:
	.set	noreorder
	.set	nomacro
	j	$31
	move	$2,$6
	.set	macro
	.set	reorder

	.end	bn_mul_word
	.align	2
	.globl	bn_sqr_words
	.ent	bn_sqr_words
bn_sqr_words:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, extra= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	.set	noreorder
	.cpload	$25
	.set	reorder
	move	$9,$4
	addu	$7,$9,28
	addu	$8,$5,12
$L18:
	lw	$2,0($5)
	#nop
	multu	$2,$2
	mfhi	$2
	mflo	$3
	#nop
	addu	$6,$6,-1
	sw	$3,0($9)
	srl	$3,$2,0
	move	$2,$0
	.set	noreorder
	.set	nomacro
	beq	$6,$0,$L19
	sw	$3,-24($7)
	.set	macro
	.set	reorder

	lw	$2,-8($8)
	#nop
	multu	$2,$2
	mfhi	$2
	mflo	$3
	#nop
	addu	$6,$6,-1
	sw	$3,-20($7)
	srl	$3,$2,0
	move	$2,$0
	.set	noreorder
	.set	nomacro
	beq	$6,$0,$L19
	sw	$3,-16($7)
	.set	macro
	.set	reorder

	lw	$2,-4($8)
	#nop
	multu	$2,$2
	mfhi	$2
	mflo	$3
	#nop
	addu	$6,$6,-1
	sw	$3,-12($7)
	srl	$3,$2,0
	move	$2,$0
	.set	noreorder
	.set	nomacro
	beq	$6,$0,$L19
	sw	$3,-8($7)
	.set	macro
	.set	reorder

	lw	$2,0($8)
	#nop
	multu	$2,$2
	mfhi	$2
	mflo	$3
	#nop
	addu	$6,$6,-1
	sw	$3,-4($7)
	srl	$3,$2,0
	move	$2,$0
	.set	noreorder
	.set	nomacro
	beq	$6,$0,$L19
	sw	$3,0($7)
	.set	macro
	.set	reorder

	addu	$8,$8,16
	addu	$5,$5,16
	addu	$7,$7,32
	.set	noreorder
	.set	nomacro
	j	$L18
	addu	$9,$9,32
	.set	macro
	.set	reorder

$L19:
	j	$31
	.end	bn_sqr_words
	.rdata
	.align	2
$LC0:

	.byte	0x44,0x69,0x76,0x69,0x73,0x69,0x6f,0x6e
	.byte	0x20,0x77,0x6f,0x75,0x6c,0x64,0x20,0x6f
	.byte	0x76,0x65,0x72,0x66,0x6c,0x6f,0x77,0xa
	.byte	0x0
	.text
	.align	2
	.globl	bn_div64
	.ent	bn_div64
bn_div64:
	.frame	$sp,56,$31		# vars= 0, regs= 7/0, args= 16, extra= 8
	.mask	0x901f0000,-8
	.fmask	0x00000000,0
	.set	noreorder
	.cpload	$25
	.set	reorder
	subu	$sp,$sp,56
	.cprestore 16
	sw	$16,24($sp)
	move	$16,$4
	sw	$17,28($sp)
	move	$17,$5
	sw	$18,32($sp)
	move	$18,$6
	sw	$20,40($sp)
	move	$20,$0
	sw	$19,36($sp)
	li	$19,0x00000002		# 2
	sw	$31,48($sp)
	.set	noreorder
	.set	nomacro
	bne	$18,$0,$L26
	sw	$28,44($sp)
	.set	macro
	.set	reorder

	.set	noreorder
	.set	nomacro
	j	$L43
	li	$2,-1			# 0xffffffff
	.set	macro
	.set	reorder

$L26:
	move	$4,$18
	jal	BN_num_bits_word
	move	$4,$2
	li	$2,0x00000020		# 32
	.set	noreorder
	.set	nomacro
	beq	$4,$2,$L27
	li	$2,0x00000001		# 1
	.set	macro
	.set	reorder

	sll	$2,$2,$4
	sltu	$2,$2,$16
	.set	noreorder
	.set	nomacro
	beq	$2,$0,$L44
	li	$5,0x00000020		# 32
	.set	macro
	.set	reorder

	la	$4,__iob+32
	la	$5,$LC0
	jal	fprintf
	jal	abort
$L27:
	li	$5,0x00000020		# 32
$L44:
	sltu	$2,$16,$18
	.set	noreorder
	.set	nomacro
	bne	$2,$0,$L28
	subu	$4,$5,$4
	.set	macro
	.set	reorder

	subu	$16,$16,$18
$L28:
	.set	noreorder
	.set	nomacro
	beq	$4,$0,$L29
	li	$10,-65536			# 0xffff0000
	.set	macro
	.set	reorder

	sll	$18,$18,$4
	sll	$3,$16,$4
	subu	$2,$5,$4
	srl	$2,$17,$2
	or	$16,$3,$2
	sll	$17,$17,$4
$L29:
	srl	$7,$18,16
	andi	$9,$18,0xffff
$L30:
	srl	$2,$16,16
	.set	noreorder
	.set	nomacro
	beq	$2,$7,$L34
	li	$6,0x0000ffff		# 65535
	.set	macro
	.set	reorder

	divu	$6,$16,$7
$L34:
	mult	$6,$9
	mflo	$5
	#nop
	#nop
	mult	$6,$7
	and	$2,$17,$10
	srl	$8,$2,16
	mflo	$4
$L35:
	subu	$3,$16,$4
	and	$2,$3,$10
	.set	noreorder
	.set	nomacro
	bne	$2,$0,$L36
	sll	$2,$3,16
	.set	macro
	.set	reorder

	addu	$2,$2,$8
	sltu	$2,$2,$5
	.set	noreorder
	.set	nomacro
	beq	$2,$0,$L36
	subu	$5,$5,$9
	.set	macro
	.set	reorder

	subu	$4,$4,$7
	.set	noreorder
	.set	nomacro
	j	$L35
	addu	$6,$6,-1
	.set	macro
	.set	reorder

$L36:
	mult	$6,$7
	mflo	$5
	#nop
	#nop
	mult	$6,$9
	mflo	$4
	#nop
	#nop
	srl	$3,$4,16
	sll	$2,$4,16
	and	$4,$2,$10
	sltu	$2,$17,$4
	.set	noreorder
	.set	nomacro
	beq	$2,$0,$L40
	addu	$5,$5,$3
	.set	macro
	.set	reorder

	addu	$5,$5,1
$L40:
	sltu	$2,$16,$5
	.set	noreorder
	.set	nomacro
	beq	$2,$0,$L41
	subu	$17,$17,$4
	.set	macro
	.set	reorder

	addu	$16,$16,$18
	addu	$6,$6,-1
$L41:
	addu	$19,$19,-1
	.set	noreorder
	.set	nomacro
	beq	$19,$0,$L31
	subu	$16,$16,$5
	.set	macro
	.set	reorder

	sll	$20,$6,16
	sll	$3,$16,16
	srl	$2,$17,16
	or	$16,$3,$2
	.set	noreorder
	.set	nomacro
	j	$L30
	sll	$17,$17,16
	.set	macro
	.set	reorder

$L31:
	or	$2,$20,$6
$L43:
	lw	$31,48($sp)
	lw	$20,40($sp)
	lw	$19,36($sp)
	lw	$18,32($sp)
	lw	$17,28($sp)
	lw	$16,24($sp)
	addu	$sp,$sp,56
	j	$31
	.end	bn_div64

	.globl abort .text
	.globl fprintf .text
	.globl BN_num_bits_word .text