2 # Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
10 # ====================================================================
11 # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
12 # project. The module is, however, dual licensed under OpenSSL and
13 # CRYPTOGAMS licenses depending on where you obtain it. For further
14 # details see http://www.openssl.org/~appro/cryptogams/.
15 # ====================================================================
17 # I let hardware handle unaligned input, except on page boundaries
18 # (see below for details). Otherwise straightforward implementation
19 # with X vector in register bank.
22 # -m64 -m32 | -m64 -m32
23 # --------------------------------------+-----------------------
24 # PPC970,gcc-4.0.0 +50% +38% | +40% +410%(*)
25 # Power6,xlc-7 +150% +90% | +100% +430%(*)
27 # (*) 64-bit code in 32-bit application context, which actually is
28 # on TODO list. It should be noted that for safe deployment in
29 # 32-bit *multi-threaded* context asynchronous signals should be
30 # blocked upon entry to SHA512 block routine. This is because
31 # 32-bit signaling procedure invalidates upper halves of GPRs.
32 # Context switch procedure preserves them, but not signaling:-(
34 # Second version is true multi-thread safe. Trouble with the original
35 # version was that it was using thread local storage pointer register.
36 # Well, it scrupulously preserved it, but the problem would arise the
37 # moment asynchronous signal was delivered and signal handler would
38 # dereference the TLS pointer. While it's never the case in openssl
39 # application or test suite, we have to respect this scenario and not
40 # use TLS pointer register. Alternative would be to require caller to
41 # block signals prior calling this routine. For the record, in 32-bit
42 # context R2 serves as TLS pointer, while in 64-bit context - R13.
47 if ($flavour =~ /64/) {
55 } elsif ($flavour =~ /32/) {
63 } else { die "nonsense $flavour"; }
65 $LITTLE_ENDIAN = ($flavour=~/le$/) ? $SIZE_T : 0;
67 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
68 ( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
69 ( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
70 die "can't locate ppc-xlate.pl";
72 open STDOUT,"| $^X $xlate $flavour $output" || die "can't call $xlate: $!";
74 if ($output =~ /512/) {
75 $func="sha512_block_ppc";
87 $func="sha256_block_ppc";
100 $FRAME=32*$SIZE_T+16*$SZ;
105 $ctx="r3"; # zapped by $a0
106 $inp="r4"; # zapped by $a1
107 $num="r5"; # zapped by $t0
121 $F =$t1; $t1 = "r0"; # stay away from "r13";
125 @V=($A,$B,$C,$D,$E,$F,$G,$H);
126 @X=("r16","r17","r18","r19","r20","r21","r22","r23",
127 "r24","r25","r26","r27","r28","r29","r30","r31");
129 $inp="r31" if($SZ==4 || $SIZE_T==8); # reassigned $inp! aliases with @X[15]
132 my ($i,$a,$b,$c,$d,$e,$f,$g,$h)=@_;
134 $ROR $a0,$e,$Sigma1[0]
135 $ROR $a1,$e,$Sigma1[1]
140 $ROR $a1,$a1,`$Sigma1[2]-$Sigma1[1]`
141 or $t0,$t0,$t1 ; Ch(e,f,g)
143 xor $a0,$a0,$a1 ; Sigma1(e)
147 $ROR $a0,$a,$Sigma0[0]
148 $ROR $a1,$a,$Sigma0[1]
152 $ROR $a1,$a1,`$Sigma0[2]-$Sigma0[1]`
155 xor $a0,$a0,$a1 ; Sigma0(a)
157 xor $t0,$t0,$t1 ; Maj(a,b,c)
159 $code.=<<___ if ($i<15);
160 $LD $t1,`($i+1)*$SZ`($Tbl)
170 my ($i,$a,$b,$c,$d,$e,$f,$g,$h)=@_;
173 $ROR $a0,@X[($i+1)%16],$sigma0[0]
174 $ROR $a1,@X[($i+1)%16],$sigma0[1]
175 $ROR $t0,@X[($i+14)%16],$sigma1[0]
176 $ROR $t1,@X[($i+14)%16],$sigma1[1]
178 $SHR $a1,@X[($i+1)%16],$sigma0[2]
180 $SHR $t1,@X[($i+14)%16],$sigma1[2]
181 add @X[$i],@X[$i],@X[($i+9)%16]
182 xor $a0,$a0,$a1 ; sigma0(X[(i+1)&0x0f])
183 xor $t0,$t0,$t1 ; sigma1(X[(i+14)&0x0f])
184 $LD $t1,`$i*$SZ`($Tbl)
185 add @X[$i],@X[$i],$a0
186 add @X[$i],@X[$i],$t0
188 &ROUND_00_15($i+16,$a,$b,$c,$d,$e,$f,$g,$h);
198 $STU $sp,-$FRAME($sp)
200 $SHL $num,$num,`log(16*$SZ)/log(2)`
202 $PUSH $ctx,`$FRAME-$SIZE_T*22`($sp)
204 $PUSH r14,`$FRAME-$SIZE_T*18`($sp)
205 $PUSH r15,`$FRAME-$SIZE_T*17`($sp)
206 $PUSH r16,`$FRAME-$SIZE_T*16`($sp)
207 $PUSH r17,`$FRAME-$SIZE_T*15`($sp)
208 $PUSH r18,`$FRAME-$SIZE_T*14`($sp)
209 $PUSH r19,`$FRAME-$SIZE_T*13`($sp)
210 $PUSH r20,`$FRAME-$SIZE_T*12`($sp)
211 $PUSH r21,`$FRAME-$SIZE_T*11`($sp)
212 $PUSH r22,`$FRAME-$SIZE_T*10`($sp)
213 $PUSH r23,`$FRAME-$SIZE_T*9`($sp)
214 $PUSH r24,`$FRAME-$SIZE_T*8`($sp)
215 $PUSH r25,`$FRAME-$SIZE_T*7`($sp)
216 $PUSH r26,`$FRAME-$SIZE_T*6`($sp)
217 $PUSH r27,`$FRAME-$SIZE_T*5`($sp)
218 $PUSH r28,`$FRAME-$SIZE_T*4`($sp)
219 $PUSH r29,`$FRAME-$SIZE_T*3`($sp)
220 $PUSH r30,`$FRAME-$SIZE_T*2`($sp)
221 $PUSH r31,`$FRAME-$SIZE_T*1`($sp)
222 $PUSH r0,`$FRAME+$LRSAVE`($sp)
225 if ($SZ==4 || $SIZE_T==8) {
228 mr $inp,r4 ; incarnate $inp
238 for ($i=16;$i<32;$i++) {
240 lwz r$i,`$LITTLE_ENDIAN^(4*($i-16))`($ctx)
252 $PUSH $num,`$FRAME-$SIZE_T*24`($sp) ; end pointer
253 $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer
254 bl Lsha2_block_private
257 ; PowerPC specification allows an implementation to be ill-behaved
258 ; upon unaligned access which crosses page boundary. "Better safe
259 ; than sorry" principle makes me treat it specially. But I don't
260 ; look for particular offending word, but rather for the input
261 ; block which crosses the boundary. Once found that block is aligned
262 ; and hashed separately...
266 andi. $t1,$t1,`4096-16*$SZ` ; distance to closest page boundary
269 ble Laligned ; didn't cross the page boundary
272 $PUSH $num,`$FRAME-$SIZE_T*25`($sp) ; save real remaining num
273 $PUSH $t1,`$FRAME-$SIZE_T*24`($sp) ; intermediate end pointer
274 $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer
275 bl Lsha2_block_private
276 ; $inp equals to the intermediate end pointer here
277 $POP $num,`$FRAME-$SIZE_T*25`($sp) ; restore real remaining num
282 if ($SZ==4 || $SIZE_T==8) {
284 addi r20,$sp,$LOCALS ; aligned spot below the frame
300 addi r12,$sp,$LOCALS ; aligned spot below the frame
317 $PUSH $inp,`$FRAME-$SIZE_T*26`($sp) ; save real inp
318 addi $t1,$sp,`$LOCALS+16*$SZ` ; fictitious end pointer
319 addi $inp,$sp,$LOCALS ; fictitious inp pointer
320 $PUSH $num,`$FRAME-$SIZE_T*25`($sp) ; save real num
321 $PUSH $t1,`$FRAME-$SIZE_T*24`($sp) ; end pointer
322 $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer
323 bl Lsha2_block_private
324 $POP $inp,`$FRAME-$SIZE_T*26`($sp) ; restore real inp
325 $POP $num,`$FRAME-$SIZE_T*25`($sp) ; restore real num
326 addic. $num,$num,`-16*$SZ` ; num--
330 $POP r0,`$FRAME+$LRSAVE`($sp)
331 $POP r14,`$FRAME-$SIZE_T*18`($sp)
332 $POP r15,`$FRAME-$SIZE_T*17`($sp)
333 $POP r16,`$FRAME-$SIZE_T*16`($sp)
334 $POP r17,`$FRAME-$SIZE_T*15`($sp)
335 $POP r18,`$FRAME-$SIZE_T*14`($sp)
336 $POP r19,`$FRAME-$SIZE_T*13`($sp)
337 $POP r20,`$FRAME-$SIZE_T*12`($sp)
338 $POP r21,`$FRAME-$SIZE_T*11`($sp)
339 $POP r22,`$FRAME-$SIZE_T*10`($sp)
340 $POP r23,`$FRAME-$SIZE_T*9`($sp)
341 $POP r24,`$FRAME-$SIZE_T*8`($sp)
342 $POP r25,`$FRAME-$SIZE_T*7`($sp)
343 $POP r26,`$FRAME-$SIZE_T*6`($sp)
344 $POP r27,`$FRAME-$SIZE_T*5`($sp)
345 $POP r28,`$FRAME-$SIZE_T*4`($sp)
346 $POP r29,`$FRAME-$SIZE_T*3`($sp)
347 $POP r30,`$FRAME-$SIZE_T*2`($sp)
348 $POP r31,`$FRAME-$SIZE_T*1`($sp)
353 .byte 0,12,4,1,0x80,18,3,0
357 if ($SZ==4 || $SIZE_T==8) {
363 for($i=0;$i<16;$i++) {
364 $code.=<<___ if ($SZ==4 && !$LITTLE_ENDIAN);
365 lwz @X[$i],`$i*$SZ`($inp)
367 $code.=<<___ if ($SZ==4 && $LITTLE_ENDIAN);
368 lwz $a0,`$i*$SZ`($inp)
370 rlwimi @X[$i],$a0,24,0,7
371 rlwimi @X[$i],$a0,24,16,23
373 # 64-bit loads are split to 2x32-bit ones, as CPU can't handle
374 # unaligned 64-bit loads, only 32-bit ones...
375 $code.=<<___ if ($SZ==8 && !$LITTLE_ENDIAN);
376 lwz $t0,`$i*$SZ`($inp)
377 lwz @X[$i],`$i*$SZ+4`($inp)
378 insrdi @X[$i],$t0,32,0
380 $code.=<<___ if ($SZ==8 && $LITTLE_ENDIAN);
381 lwz $a0,`$i*$SZ`($inp)
382 lwz $a1,`$i*$SZ+4`($inp)
385 rlwimi $t0,$a0,24,0,7
386 rlwimi @X[$i],$a1,24,0,7
387 rlwimi $t0,$a0,24,16,23
388 rlwimi @X[$i],$a1,24,16,23
389 insrdi @X[$i],$t0,32,0
395 li $t0,`$rounds/16-1`
399 addi $Tbl,$Tbl,`16*$SZ`
408 $POP $ctx,`$FRAME-$SIZE_T*22`($sp)
409 $POP $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer
410 $POP $num,`$FRAME-$SIZE_T*24`($sp) ; end pointer
411 subi $Tbl,$Tbl,`($rounds-16)*$SZ` ; rewind Tbl
413 $LD r16,`0*$SZ`($ctx)
414 $LD r17,`1*$SZ`($ctx)
415 $LD r18,`2*$SZ`($ctx)
416 $LD r19,`3*$SZ`($ctx)
417 $LD r20,`4*$SZ`($ctx)
418 $LD r21,`5*$SZ`($ctx)
419 $LD r22,`6*$SZ`($ctx)
420 addi $inp,$inp,`16*$SZ` ; advance inp
421 $LD r23,`7*$SZ`($ctx)
424 $PUSH $inp,`$FRAME-$SIZE_T*23`($sp)
440 bne Lsha2_block_private
443 .byte 0,12,0x14,0,0,0,0,0
447 ########################################################################
448 # SHA512 for PPC32, X vector is off-loaded to stack...
452 # ----------------------+-----------------------
453 # PPC74x0,gcc-4.0.1 | +48%
454 # POWER6,gcc-4.4.6 | +124%(*)
455 # POWER7,gcc-4.4.6 | +79%(*)
456 # e300,gcc-4.1.0 | +167%
458 # (*) ~1/3 of -m64 result [and ~20% better than -m32 code generated
463 my @V=map("r$_",(16..31)); # A..H
465 my ($s0,$s1,$t0,$t1,$t2,$t3,$a0,$a1,$a2,$a3)=map("r$_",(0,5,6,8..12,14,15));
466 my ($x0,$x1)=("r3","r4"); # zaps $ctx and $inp
468 sub ROUND_00_15_ppc32 {
469 my ($i, $ahi,$alo,$bhi,$blo,$chi,$clo,$dhi,$dlo,
470 $ehi,$elo,$fhi,$flo,$ghi,$glo,$hhi,$hlo)=@_;
473 lwz $t2,`$SZ*($i%16)+($LITTLE_ENDIAN^4)`($Tbl)
475 lwz $t3,`$SZ*($i%16)+($LITTLE_ENDIAN^0)`($Tbl)
477 addc $hlo,$hlo,$t0 ; h+=x[i]
478 stw $t0,`$XOFF+0+$SZ*($i%16)`($sp) ; save x[i]
480 srwi $s0,$elo,$Sigma1[0]
481 srwi $s1,$ehi,$Sigma1[0]
485 stw $t1,`$XOFF+4+$SZ*($i%16)`($sp)
486 srwi $t0,$elo,$Sigma1[1]
487 srwi $t1,$ehi,$Sigma1[1]
488 addc $hlo,$hlo,$t2 ; h+=K512[i]
489 insrwi $s0,$ehi,$Sigma1[0],0
490 insrwi $s1,$elo,$Sigma1[0],0
491 xor $a0,$a0,$glo ; Ch(e,f,g)
494 insrwi $t0,$ehi,$Sigma1[1],0
495 insrwi $t1,$elo,$Sigma1[1],0
496 addc $hlo,$hlo,$a0 ; h+=Ch(e,f,g)
497 srwi $t2,$ehi,$Sigma1[2]-32
498 srwi $t3,$elo,$Sigma1[2]-32
501 insrwi $t2,$elo,$Sigma1[2]-32,0
502 insrwi $t3,$ehi,$Sigma1[2]-32,0
503 xor $a0,$alo,$blo ; a^b, b^c in next round
506 xor $s0,$s0,$t2 ; Sigma1(e)
509 srwi $t0,$alo,$Sigma0[0]
511 addc $hlo,$hlo,$s0 ; h+=Sigma1(e)
513 srwi $t1,$ahi,$Sigma0[0]
514 srwi $s0,$ahi,$Sigma0[1]-32
516 srwi $s1,$alo,$Sigma0[1]-32
517 insrwi $t0,$ahi,$Sigma0[0],0
518 insrwi $t1,$alo,$Sigma0[0],0
519 xor $a2,$a2,$blo ; Maj(a,b,c)
520 addc $dlo,$dlo,$hlo ; d+=h
522 insrwi $s0,$alo,$Sigma0[1]-32,0
523 insrwi $s1,$ahi,$Sigma0[1]-32,0
525 srwi $t2,$ahi,$Sigma0[2]-32
526 srwi $t3,$alo,$Sigma0[2]-32
528 addc $hlo,$hlo,$a2 ; h+=Maj(a,b,c)
530 insrwi $t2,$alo,$Sigma0[2]-32,0
531 insrwi $t3,$ahi,$Sigma0[2]-32,0
534 $code.=<<___ if ($i>=15);
535 lwz $t0,`$XOFF+0+$SZ*(($i+2)%16)`($sp)
536 lwz $t1,`$XOFF+4+$SZ*(($i+2)%16)`($sp)
538 $code.=<<___ if ($i<15 && !$LITTLE_ENDIAN);
539 lwz $t1,`$SZ*($i+1)+0`($inp)
540 lwz $t0,`$SZ*($i+1)+4`($inp)
542 $code.=<<___ if ($i<15 && $LITTLE_ENDIAN);
543 lwz $a2,`$SZ*($i+1)+0`($inp)
544 lwz $a3,`$SZ*($i+1)+4`($inp)
547 rlwimi $t1,$a2,24,0,7
548 rlwimi $t0,$a3,24,0,7
549 rlwimi $t1,$a2,24,16,23
550 rlwimi $t0,$a3,24,16,23
553 xor $s0,$s0,$t2 ; Sigma0(a)
555 addc $hlo,$hlo,$s0 ; h+=Sigma0(a)
558 $code.=<<___ if ($i==15);
559 lwz $x0,`$XOFF+0+$SZ*(($i+1)%16)`($sp)
560 lwz $x1,`$XOFF+4+$SZ*(($i+1)%16)`($sp)
563 sub ROUND_16_xx_ppc32 {
564 my ($i, $ahi,$alo,$bhi,$blo,$chi,$clo,$dhi,$dlo,
565 $ehi,$elo,$fhi,$flo,$ghi,$glo,$hhi,$hlo)=@_;
568 srwi $s0,$t0,$sigma0[0]
569 srwi $s1,$t1,$sigma0[0]
570 srwi $t2,$t0,$sigma0[1]
571 srwi $t3,$t1,$sigma0[1]
572 insrwi $s0,$t1,$sigma0[0],0
573 insrwi $s1,$t0,$sigma0[0],0
574 srwi $a0,$t0,$sigma0[2]
575 insrwi $t2,$t1,$sigma0[1],0
576 insrwi $t3,$t0,$sigma0[1],0
577 insrwi $a0,$t1,$sigma0[2],0
579 lwz $t2,`$XOFF+0+$SZ*(($i+14)%16)`($sp)
580 srwi $a1,$t1,$sigma0[2]
582 lwz $t3,`$XOFF+4+$SZ*(($i+14)%16)`($sp)
584 srwi $s0,$t2,$sigma1[0]
586 srwi $s1,$t3,$sigma1[0]
587 addc $x0,$x0,$a0 ; x[i]+=sigma0(x[i+1])
588 srwi $a0,$t3,$sigma1[1]-32
589 insrwi $s0,$t3,$sigma1[0],0
590 insrwi $s1,$t2,$sigma1[0],0
592 srwi $a1,$t2,$sigma1[1]-32
594 insrwi $a0,$t2,$sigma1[1]-32,0
595 srwi $t2,$t2,$sigma1[2]
596 insrwi $a1,$t3,$sigma1[1]-32,0
597 insrwi $t2,$t3,$sigma1[2],0
599 lwz $a0,`$XOFF+0+$SZ*(($i+9)%16)`($sp)
600 srwi $t3,$t3,$sigma1[2]
602 lwz $a1,`$XOFF+4+$SZ*(($i+9)%16)`($sp)
604 addc $x0,$x0,$a0 ; x[i]+=x[i+9]
607 addc $x0,$x0,$s0 ; x[i]+=sigma1(x[i+14])
610 ($t0,$t1,$x0,$x1) = ($x0,$x1,$t0,$t1);
611 &ROUND_00_15_ppc32(@_);
618 $code.=<<___ if (!$LITTLE_ENDIAN);
620 xor $a2,@V[3],@V[5] ; B^C, magic seed
624 $code.=<<___ if ($LITTLE_ENDIAN);
626 xor $a2,@V[3],@V[5] ; B^C, magic seed
631 rlwimi $t1,$a1,24,0,7
632 rlwimi $t0,$a0,24,0,7
633 rlwimi $t1,$a1,24,16,23
634 rlwimi $t0,$a0,24,16,23
636 for($i=0;$i<16;$i++) {
637 &ROUND_00_15_ppc32($i,@V);
638 unshift(@V,pop(@V)); unshift(@V,pop(@V));
639 ($a0,$a1,$a2,$a3) = ($a2,$a3,$a0,$a1);
642 li $a0,`$rounds/16-1`
646 addi $Tbl,$Tbl,`16*$SZ`
649 &ROUND_16_xx_ppc32($i,@V);
650 unshift(@V,pop(@V)); unshift(@V,pop(@V));
651 ($a0,$a1,$a2,$a3) = ($a2,$a3,$a0,$a1);
656 $POP $ctx,`$FRAME-$SIZE_T*22`($sp)
657 $POP $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer
658 $POP $num,`$FRAME-$SIZE_T*24`($sp) ; end pointer
659 subi $Tbl,$Tbl,`($rounds-16)*$SZ` ; rewind Tbl
661 lwz $t0,`$LITTLE_ENDIAN^0`($ctx)
662 lwz $t1,`$LITTLE_ENDIAN^4`($ctx)
663 lwz $t2,`$LITTLE_ENDIAN^8`($ctx)
664 lwz $t3,`$LITTLE_ENDIAN^12`($ctx)
665 lwz $a0,`$LITTLE_ENDIAN^16`($ctx)
666 lwz $a1,`$LITTLE_ENDIAN^20`($ctx)
667 lwz $a2,`$LITTLE_ENDIAN^24`($ctx)
669 lwz $a3,`$LITTLE_ENDIAN^28`($ctx)
671 lwz $t0,`$LITTLE_ENDIAN^32`($ctx)
673 lwz $t1,`$LITTLE_ENDIAN^36`($ctx)
675 lwz $t2,`$LITTLE_ENDIAN^40`($ctx)
677 lwz $t3,`$LITTLE_ENDIAN^44`($ctx)
679 lwz $a0,`$LITTLE_ENDIAN^48`($ctx)
681 lwz $a1,`$LITTLE_ENDIAN^52`($ctx)
683 lwz $a2,`$LITTLE_ENDIAN^56`($ctx)
685 lwz $a3,`$LITTLE_ENDIAN^60`($ctx)
687 stw @V[0],`$LITTLE_ENDIAN^0`($ctx)
688 stw @V[1],`$LITTLE_ENDIAN^4`($ctx)
689 addc @V[11],@V[11],$t3
690 stw @V[2],`$LITTLE_ENDIAN^8`($ctx)
691 stw @V[3],`$LITTLE_ENDIAN^12`($ctx)
692 adde @V[10],@V[10],$t2
693 stw @V[4],`$LITTLE_ENDIAN^16`($ctx)
694 stw @V[5],`$LITTLE_ENDIAN^20`($ctx)
695 addc @V[13],@V[13],$a1
696 stw @V[6],`$LITTLE_ENDIAN^24`($ctx)
697 stw @V[7],`$LITTLE_ENDIAN^28`($ctx)
698 adde @V[12],@V[12],$a0
699 stw @V[8],`$LITTLE_ENDIAN^32`($ctx)
700 stw @V[9],`$LITTLE_ENDIAN^36`($ctx)
701 addc @V[15],@V[15],$a3
702 stw @V[10],`$LITTLE_ENDIAN^40`($ctx)
703 stw @V[11],`$LITTLE_ENDIAN^44`($ctx)
704 adde @V[14],@V[14],$a2
705 stw @V[12],`$LITTLE_ENDIAN^48`($ctx)
706 stw @V[13],`$LITTLE_ENDIAN^52`($ctx)
707 stw @V[14],`$LITTLE_ENDIAN^56`($ctx)
708 stw @V[15],`$LITTLE_ENDIAN^60`($ctx)
710 addi $inp,$inp,`16*$SZ` ; advance inp
711 $PUSH $inp,`$FRAME-$SIZE_T*23`($sp)
713 bne Lsha2_block_private
716 .byte 0,12,0x14,0,0,0,0,0
721 # Ugly hack here, because PPC assembler syntax seem to vary too
722 # much from platforms to platform...
728 mflr $Tbl ; vvvvvv "distance" between . and 1st data entry
729 addi $Tbl,$Tbl,`64-8`
733 .byte 0,12,0x14,0,0,0,0,0
736 $code.=<<___ if ($SZ==8);
737 .quad 0x428a2f98d728ae22,0x7137449123ef65cd
738 .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc
739 .quad 0x3956c25bf348b538,0x59f111f1b605d019
740 .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118
741 .quad 0xd807aa98a3030242,0x12835b0145706fbe
742 .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2
743 .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1
744 .quad 0x9bdc06a725c71235,0xc19bf174cf692694
745 .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3
746 .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65
747 .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483
748 .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5
749 .quad 0x983e5152ee66dfab,0xa831c66d2db43210
750 .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4
751 .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725
752 .quad 0x06ca6351e003826f,0x142929670a0e6e70
753 .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926
754 .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df
755 .quad 0x650a73548baf63de,0x766a0abb3c77b2a8
756 .quad 0x81c2c92e47edaee6,0x92722c851482353b
757 .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001
758 .quad 0xc24b8b70d0f89791,0xc76c51a30654be30
759 .quad 0xd192e819d6ef5218,0xd69906245565a910
760 .quad 0xf40e35855771202a,0x106aa07032bbd1b8
761 .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53
762 .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8
763 .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb
764 .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3
765 .quad 0x748f82ee5defb2fc,0x78a5636f43172f60
766 .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec
767 .quad 0x90befffa23631e28,0xa4506cebde82bde9
768 .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b
769 .quad 0xca273eceea26619c,0xd186b8c721c0c207
770 .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178
771 .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6
772 .quad 0x113f9804bef90dae,0x1b710b35131c471b
773 .quad 0x28db77f523047d84,0x32caab7b40c72493
774 .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c
775 .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a
776 .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817
778 $code.=<<___ if ($SZ==4);
779 .long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5
780 .long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5
781 .long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3
782 .long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174
783 .long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc
784 .long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da
785 .long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7
786 .long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967
787 .long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13
788 .long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85
789 .long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3
790 .long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070
791 .long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5
792 .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3
793 .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208
794 .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
797 $code =~ s/\`([^\`]*)\`/eval $1/gem;