1b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic#!/usr/bin/env perl 2b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 3b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ==================================================================== 4b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL 5b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# project. The module is, however, dual licensed under OpenSSL and 6b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# CRYPTOGAMS licenses depending on where you obtain it. For further 7b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# details see http://www.openssl.org/~appro/cryptogams/. 8b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ==================================================================== 9b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 10b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# This module doesn't present direct interest for OpenSSL, because it 11b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# doesn't provide better performance for longer keys, at least not on 12b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# in-order-execution cores. While 512-bit RSA sign operations can be 13b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 65% faster in 64-bit mode, 1024-bit ones are only 15% faster, and 14b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 4096-bit ones are up to 15% slower. In 32-bit mode it varies from 15b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 16% improvement for 512-bit RSA sign to -33% for 4096-bit RSA 16b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# verify:-( All comparisons are against bn_mul_mont-free assembler. 17b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# The module might be of interest to embedded system developers, as 18b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# the code is smaller than 1KB, yet offers >3x improvement on MIPS64 19b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# and 75-30% [less for longer keys] on MIPS32 over compiler-generated 20b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# code. 21b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 22b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic###################################################################### 23b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# There is a number of MIPS ABI in use, O32 and N32/64 are most 24b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# widely used. Then there is a new contender: NUBI. It appears that if 25b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# one picks the latter, it's possible to arrange code in ABI neutral 26b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# manner. Therefore let's stick to NUBI register layout: 27b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 28b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic($zero,$at,$t0,$t1,$t2)=map("\$$_",(0..2,24,25)); 29b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("\$$_",(4..11)); 30b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10,$s11)=map("\$$_",(12..23)); 31b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic($gp,$tp,$sp,$fp,$ra)=map("\$$_",(3,28..31)); 32b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 33b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# The return value is placed in $a0. Following coding rules facilitate 34b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# interoperability: 35b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 36b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# - never ever touch $tp, "thread pointer", former $gp; 37b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# - copy return value to $t0, former $v0 [or to $a0 if you're adapting 38b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# old code]; 39b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# - on O32 populate $a4-$a7 with 'lw $aN,4*N($sp)' if necessary; 40b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 41b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# For reference here is register layout for N32/64 MIPS ABIs: 42b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 43b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ($zero,$at,$v0,$v1)=map("\$$_",(0..3)); 44b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("\$$_",(4..11)); 45b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ($t0,$t1,$t2,$t3,$t8,$t9)=map("\$$_",(12..15,24,25)); 46b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$$_",(16..23)); 47b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# ($gp,$sp,$fp,$ra)=map("\$$_",(28..31)); 48b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 49b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$flavour = shift; # supported flavours are o32,n32,64,nubi32,nubi64 50b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 51b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicif ($flavour =~ /64|n32/i) { 52b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD="dadd"; # incidentally works even on n32 53b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_SUB="dsub"; # incidentally works even on n32 54b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S="sd"; 55b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L="ld"; 56b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SZREG=8; 57b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic} else { 58b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD="add"; 59b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_SUB="sub"; 60b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S="sw"; 61b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L="lw"; 62b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SZREG=4; 63b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic} 64b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? 0x00fff000 : 0x00ff0000; 65b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 66b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# <appro@openssl.org> 67b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# 68b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic###################################################################### 69b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 70b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicwhile (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} 71b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicopen STDOUT,">$output"; 72b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 73b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicif ($flavour =~ /64|n32/i) { 74b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD="ld"; 75b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST="sd"; 76b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU="dmultu"; 77b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU="daddu"; 78b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SUBU="dsubu"; 79b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $BNSZ=8; 80b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic} else { 81b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD="lw"; 82b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST="sw"; 83b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU="multu"; 84b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU="addu"; 85b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SUBU="subu"; 86b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $BNSZ=4; 87b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic} 88b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 89b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic# int bn_mul_mont( 90b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$rp=$a0; # BN_ULONG *rp, 91b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$ap=$a1; # const BN_ULONG *ap, 92b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$bp=$a2; # const BN_ULONG *bp, 93b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$np=$a3; # const BN_ULONG *np, 94b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$n0=$a4; # const BN_ULONG *n0, 95b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$num=$a5; # int num); 96b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 97b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$lo0=$a6; 98b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$hi0=$a7; 99b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$lo1=$t1; 100b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$hi1=$t2; 101b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$aj=$s0; 102b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$bi=$s1; 103b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$nj=$s2; 104b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$tp=$s3; 105b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$alo=$s4; 106b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$ahi=$s5; 107b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$nlo=$s6; 108b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$nhi=$s7; 109b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$tj=$s8; 110b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$i=$s9; 111b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$j=$s10; 112b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$m1=$s11; 113b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 114b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$FRAMESIZE=14; 115b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 116b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code=<<___; 117b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.text 118b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 119b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.set noat 120b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.set noreorder 121b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 122b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 5 123b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.globl bn_mul_mont 124b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.ent bn_mul_mont 125b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicbn_mul_mont: 126b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 127b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code.=<<___ if ($flavour =~ /o32/i); 128b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic lw $n0,16($sp) 129b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic lw $num,20($sp) 130b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 131b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code.=<<___; 132b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic slt $at,$num,4 133b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnez $at,1f 134b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $t0,0 135b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic slt $at,$num,17 # on in-order CPU 136b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnezl $at,bn_mul_mont_internal 137b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic nop 138b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic1: jr $ra 139b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $a0,0 140b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.end bn_mul_mont 141b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 142b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 5 143b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.ent bn_mul_mont_internal 144b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicbn_mul_mont_internal: 145b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .frame $fp,$FRAMESIZE*$SZREG,$ra 146b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .mask 0x40000000|$SAVED_REGS_MASK,-$SZREG 147b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_SUB $sp,$FRAMESIZE*$SZREG 148b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $fp,($FRAMESIZE-1)*$SZREG($sp) 149b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s11,($FRAMESIZE-2)*$SZREG($sp) 150b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s10,($FRAMESIZE-3)*$SZREG($sp) 151b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s9,($FRAMESIZE-4)*$SZREG($sp) 152b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s8,($FRAMESIZE-5)*$SZREG($sp) 153b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s7,($FRAMESIZE-6)*$SZREG($sp) 154b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s6,($FRAMESIZE-7)*$SZREG($sp) 155b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s5,($FRAMESIZE-8)*$SZREG($sp) 156b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s4,($FRAMESIZE-9)*$SZREG($sp) 157b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 158b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code.=<<___ if ($flavour =~ /nubi/i); 159b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s3,($FRAMESIZE-10)*$SZREG($sp) 160b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s2,($FRAMESIZE-11)*$SZREG($sp) 161b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s1,($FRAMESIZE-12)*$SZREG($sp) 162b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_S $s0,($FRAMESIZE-13)*$SZREG($sp) 163b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 164b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code.=<<___; 165b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $fp,$sp 166b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 167b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set reorder 168b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $n0,0($n0) 169b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $bi,0($bp) # bp[0] 170b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $aj,0($ap) # ap[0] 171b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $nj,0($np) # np[0] 172b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 173b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_SUB $sp,2*$BNSZ # place for two extra words 174b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sll $num,`log($BNSZ)/log(2)` 175b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $at,-4096 176b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_SUB $sp,$num 177b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic and $sp,$at 178b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 179b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $aj,$bi 180b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $alo,$BNSZ($ap) 181b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $nlo,$BNSZ($np) 182b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $lo0 183b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $hi0 184b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $lo0,$n0 185b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $m1 186b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 187b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $alo,$bi 188b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $alo 189b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $ahi 190b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 191b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $nj,$m1 192b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $lo1 193b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $hi1 194b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $nlo,$m1 195b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$lo0 196b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo1,$lo0 197b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$at 198b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $nlo 199b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $nhi 200b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 201b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $tp,$sp 202b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $j,2*$BNSZ 203b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 4 204b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.L1st: 205b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set noreorder 206b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $aj,$ap,$j 207b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $nj,$np,$j 208b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $aj,($aj) 209b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $nj,($nj) 210b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 211b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $aj,$bi 212b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$alo,$hi0 213b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$nlo,$hi1 214b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo0,$hi0 215b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$lo1,$hi1 216b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$ahi,$at 217b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$nhi,$t0 218b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $alo 219b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $ahi 220b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 221b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$lo0 222b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo1,$lo0 223b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $nj,$m1 224b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$at 225b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic addu $j,$BNSZ 226b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $lo1,($tp) 227b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$j,$num 228b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $nlo 229b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $nhi 230b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 231b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnez $t0,.L1st 232b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $tp,$BNSZ 233b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set reorder 234b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 235b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$alo,$hi0 236b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo0,$hi0 237b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$ahi,$at 238b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 239b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$nlo,$hi1 240b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$lo1,$hi1 241b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$nhi,$t0 242b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$lo0 243b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo1,$lo0 244b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$at 245b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 246b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $lo1,($tp) 247b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 248b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$hi0 249b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$hi1,$hi0 250b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $hi1,$BNSZ($tp) 251b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $at,2*$BNSZ($tp) 252b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 253b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $i,$BNSZ 254b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 4 255b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.Louter: 256b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $bi,$bp,$i 257b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $bi,($bi) 258b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $aj,($ap) 259b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $alo,$BNSZ($ap) 260b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $tj,($sp) 261b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 262b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $aj,$bi 263b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $nj,($np) 264b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $nlo,$BNSZ($np) 265b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $lo0 266b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $hi0 267b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$tj 268b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $lo0,$n0 269b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo0,$tj 270b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$at 271b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $m1 272b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 273b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $alo,$bi 274b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $alo 275b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $ahi 276b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 277b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $nj,$m1 278b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $lo1 279b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $hi1 280b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 281b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $nlo,$m1 282b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$lo0 283b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo1,$lo0 284b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$at 285b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $nlo 286b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $nhi 287b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 288b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $tp,$sp 289b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $j,2*$BNSZ 290b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $tj,$BNSZ($tp) 291b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 4 292b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.Linner: 293b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set noreorder 294b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $aj,$ap,$j 295b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $nj,$np,$j 296b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $aj,($aj) 297b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $nj,($nj) 298b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 299b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $aj,$bi 300b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$alo,$hi0 301b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$nlo,$hi1 302b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo0,$hi0 303b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$lo1,$hi1 304b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$ahi,$at 305b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$nhi,$t0 306b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $alo 307b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $ahi 308b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 309b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$tj 310b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic addu $j,$BNSZ 311b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $MULTU $nj,$m1 312b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo0,$tj 313b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$lo0 314b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$at 315b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$lo1,$lo0 316b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $tj,2*$BNSZ($tp) 317b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$t0 318b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$j,$num 319b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mflo $nlo 320b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic mfhi $nhi 321b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $lo1,($tp) 322b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnez $at,.Linner 323b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $tp,$BNSZ 324b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set reorder 325b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 326b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$alo,$hi0 327b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo0,$hi0 328b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$ahi,$at 329b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo0,$tj 330b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$lo0,$tj 331b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi0,$t0 332b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 333b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $tj,2*$BNSZ($tp) 334b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$nlo,$hi1 335b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo1,$hi1 336b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$nhi,$at 337b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$lo0 338b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$lo1,$lo0 339b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$t0 340b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $lo1,($tp) 341b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 342b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$hi1,$hi0 343b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $hi1,$lo1,$hi0 344b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $lo1,$tj 345b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$lo1,$tj 346b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ADDU $hi1,$at 347b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $lo1,$BNSZ($tp) 348b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $hi1,2*$BNSZ($tp) 349b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 350b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic addu $i,$BNSZ 351b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $t0,$i,$num 352b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnez $t0,.Louter 353b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 354b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set noreorder 355b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $tj,$sp,$num # &tp[num] 356b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $tp,$sp 357b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $ap,$sp 358b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $hi0,0 # clear borrow bit 359b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 360b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 4 361b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.Lsub: $LD $lo0,($tp) 362b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $LD $lo1,($np) 363b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $tp,$BNSZ 364b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $np,$BNSZ 365b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SUBU $lo1,$lo0,$lo1 # tp[i]-np[i] 366b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sgtu $at,$lo1,$lo0 367b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SUBU $lo0,$lo1,$hi0 368b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sgtu $hi0,$lo0,$lo1 369b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $lo0,($rp) 370b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic or $hi0,$at 371b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$tp,$tj 372b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnez $at,.Lsub 373b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $rp,$BNSZ 374b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 375b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $SUBU $hi0,$hi1,$hi0 # handle upmost overflow bit 376b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $tp,$sp 377b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_SUB $rp,$num # restore rp 378b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic not $hi1,$hi0 379b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 380b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic and $ap,$hi0,$sp 381b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic and $bp,$hi1,$rp 382b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic or $ap,$ap,$bp # ap=borrow?tp:rp 383b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 384b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.align 4 385b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.Lcopy: $LD $aj,($ap) 386b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $ap,$BNSZ 387b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $zero,($tp) 388b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $tp,$BNSZ 389b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic sltu $at,$tp,$tj 390b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $ST $aj,($rp) 391b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic bnez $at,.Lcopy 392b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $rp,$BNSZ 393b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 394b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $a0,1 395b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic li $t0,1 396b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 397b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic .set noreorder 398b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic move $sp,$fp 399b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $fp,($FRAMESIZE-1)*$SZREG($sp) 400b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s11,($FRAMESIZE-2)*$SZREG($sp) 401b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s10,($FRAMESIZE-3)*$SZREG($sp) 402b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s9,($FRAMESIZE-4)*$SZREG($sp) 403b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s8,($FRAMESIZE-5)*$SZREG($sp) 404b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s7,($FRAMESIZE-6)*$SZREG($sp) 405b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s6,($FRAMESIZE-7)*$SZREG($sp) 406b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s5,($FRAMESIZE-8)*$SZREG($sp) 407b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s4,($FRAMESIZE-9)*$SZREG($sp) 408b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 409b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code.=<<___ if ($flavour =~ /nubi/i); 410b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s3,($FRAMESIZE-10)*$SZREG($sp) 411b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s2,($FRAMESIZE-11)*$SZREG($sp) 412b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s1,($FRAMESIZE-12)*$SZREG($sp) 413b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $REG_L $s0,($FRAMESIZE-13)*$SZREG($sp) 414b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 415b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code.=<<___; 416b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic jr $ra 417b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic $PTR_ADD $sp,$FRAMESIZE*$SZREG 418b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.end bn_mul_mont_internal 419b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.rdata 420b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic.asciiz "Montgomery Multiplication for MIPS, CRYPTOGAMS by <appro\@openssl.org>" 421b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic___ 422b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 423b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic$code =~ s/\`([^\`]*)\`/eval $1/gem; 424b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovic 425b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicprint $code; 426b83a02d94f9ba66fc5da46c2e27572674ea17931Petar Jovanovicclose STDOUT; 427