1#!/usr/bin/env perl 2# 3# ==================================================================== 4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL 5# project. The module is, however, dual licensed under OpenSSL and 6# CRYPTOGAMS licenses depending on where you obtain it. For further 7# details see http://www.openssl.org/~appro/cryptogams/. 8# ==================================================================== 9# 10# SHA512 block transform for x86. September 2007. 11# 12# Performance in clock cycles per processed byte (less is better): 13# 14# Pentium PIII P4 AMD K8 Core2 15# gcc 100 75 116 54 66 16# icc 97 77 95 55 57 17# x86 asm 61 56 82 36 40 18# SSE2 asm - - 38 24 20 19# x86_64 asm(*) - - 30 10.0 10.5 20# 21# (*) x86_64 assembler performance is presented for reference 22# purposes. 23# 24# IALU code-path is optimized for elder Pentiums. On vanilla Pentium 25# performance improvement over compiler generated code reaches ~60%, 26# while on PIII - ~35%. On newer �-archs improvement varies from 15% 27# to 50%, but it's less important as they are expected to execute SSE2 28# code-path, which is commonly ~2-3x faster [than compiler generated 29# code]. SSE2 code-path is as fast as original sha512-sse2.pl, even 30# though it does not use 128-bit operations. The latter means that 31# SSE2-aware kernel is no longer required to execute the code. Another 32# difference is that new code optimizes amount of writes, but at the 33# cost of increased data cache "footprint" by 1/2KB. 34 35$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; 36push(@INC,"${dir}","${dir}../../perlasm"); 37require "x86asm.pl"; 38 39&asm_init($ARGV[0],"sha512-586.pl",$ARGV[$#ARGV] eq "386"); 40 41$sse2=0; 42for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } 43 44&external_label("OPENSSL_ia32cap_P") if ($sse2); 45 46$Tlo=&DWP(0,"esp"); $Thi=&DWP(4,"esp"); 47$Alo=&DWP(8,"esp"); $Ahi=&DWP(8+4,"esp"); 48$Blo=&DWP(16,"esp"); $Bhi=&DWP(16+4,"esp"); 49$Clo=&DWP(24,"esp"); $Chi=&DWP(24+4,"esp"); 50$Dlo=&DWP(32,"esp"); $Dhi=&DWP(32+4,"esp"); 51$Elo=&DWP(40,"esp"); $Ehi=&DWP(40+4,"esp"); 52$Flo=&DWP(48,"esp"); $Fhi=&DWP(48+4,"esp"); 53$Glo=&DWP(56,"esp"); $Ghi=&DWP(56+4,"esp"); 54$Hlo=&DWP(64,"esp"); $Hhi=&DWP(64+4,"esp"); 55$K512="ebp"; 56 57$Asse2=&QWP(0,"esp"); 58$Bsse2=&QWP(8,"esp"); 59$Csse2=&QWP(16,"esp"); 60$Dsse2=&QWP(24,"esp"); 61$Esse2=&QWP(32,"esp"); 62$Fsse2=&QWP(40,"esp"); 63$Gsse2=&QWP(48,"esp"); 64$Hsse2=&QWP(56,"esp"); 65 66$A="mm0"; # B-D and 67$E="mm4"; # F-H are commonly loaded to respectively mm1-mm3 and 68 # mm5-mm7, but it's done on on-demand basis... 69 70sub BODY_00_15_sse2 { 71 my $prefetch=shift; 72 73 &movq ("mm5",$Fsse2); # load f 74 &movq ("mm6",$Gsse2); # load g 75 &movq ("mm7",$Hsse2); # load h 76 77 &movq ("mm1",$E); # %mm1 is sliding right 78 &movq ("mm2",$E); # %mm2 is sliding left 79 &psrlq ("mm1",14); 80 &movq ($Esse2,$E); # modulo-scheduled save e 81 &psllq ("mm2",23); 82 &movq ("mm3","mm1"); # %mm3 is T1 83 &psrlq ("mm1",4); 84 &pxor ("mm3","mm2"); 85 &psllq ("mm2",23); 86 &pxor ("mm3","mm1"); 87 &psrlq ("mm1",23); 88 &pxor ("mm3","mm2"); 89 &psllq ("mm2",4); 90 &pxor ("mm3","mm1"); 91 &paddq ("mm7",QWP(0,$K512)); # h+=K512[i] 92 &pxor ("mm3","mm2"); # T1=Sigma1_512(e) 93 94 &pxor ("mm5","mm6"); # f^=g 95 &movq ("mm1",$Bsse2); # load b 96 &pand ("mm5",$E); # f&=e 97 &movq ("mm2",$Csse2); # load c 98 &pxor ("mm5","mm6"); # f^=g 99 &movq ($E,$Dsse2); # e = load d 100 &paddq ("mm3","mm5"); # T1+=Ch(e,f,g) 101 &movq (&QWP(0,"esp"),$A); # modulo-scheduled save a 102 &paddq ("mm3","mm7"); # T1+=h 103 104 &movq ("mm5",$A); # %mm5 is sliding right 105 &movq ("mm6",$A); # %mm6 is sliding left 106 &paddq ("mm3",&QWP(8*9,"esp")); # T1+=X[0] 107 &psrlq ("mm5",28); 108 &paddq ($E,"mm3"); # e += T1 109 &psllq ("mm6",25); 110 &movq ("mm7","mm5"); # %mm7 is T2 111 &psrlq ("mm5",6); 112 &pxor ("mm7","mm6"); 113 &psllq ("mm6",5); 114 &pxor ("mm7","mm5"); 115 &psrlq ("mm5",5); 116 &pxor ("mm7","mm6"); 117 &psllq ("mm6",6); 118 &pxor ("mm7","mm5"); 119 &sub ("esp",8); 120 &pxor ("mm7","mm6"); # T2=Sigma0_512(a) 121 122 &movq ("mm5",$A); # %mm5=a 123 &por ($A,"mm2"); # a=a|c 124 &movq ("mm6",&QWP(8*(9+16-14),"esp")) if ($prefetch); 125 &pand ("mm5","mm2"); # %mm5=a&c 126 &pand ($A,"mm1"); # a=(a|c)&b 127 &movq ("mm2",&QWP(8*(9+16-1),"esp")) if ($prefetch); 128 &por ("mm5",$A); # %mm5=(a&c)|((a|c)&b) 129 &paddq ("mm7","mm5"); # T2+=Maj(a,b,c) 130 &movq ($A,"mm3"); # a=T1 131 132 &mov (&LB("edx"),&BP(0,$K512)); 133 &paddq ($A,"mm7"); # a+=T2 134 &add ($K512,8); 135} 136 137sub BODY_00_15_x86 { 138 #define Sigma1(x) (ROTR((x),14) ^ ROTR((x),18) ^ ROTR((x),41)) 139 # LO lo>>14^hi<<18 ^ lo>>18^hi<<14 ^ hi>>9^lo<<23 140 # HI hi>>14^lo<<18 ^ hi>>18^lo<<14 ^ lo>>9^hi<<23 141 &mov ("ecx",$Elo); 142 &mov ("edx",$Ehi); 143 &mov ("esi","ecx"); 144 145 &shr ("ecx",9); # lo>>9 146 &mov ("edi","edx"); 147 &shr ("edx",9); # hi>>9 148 &mov ("ebx","ecx"); 149 &shl ("esi",14); # lo<<14 150 &mov ("eax","edx"); 151 &shl ("edi",14); # hi<<14 152 &xor ("ebx","esi"); 153 154 &shr ("ecx",14-9); # lo>>14 155 &xor ("eax","edi"); 156 &shr ("edx",14-9); # hi>>14 157 &xor ("eax","ecx"); 158 &shl ("esi",18-14); # lo<<18 159 &xor ("ebx","edx"); 160 &shl ("edi",18-14); # hi<<18 161 &xor ("ebx","esi"); 162 163 &shr ("ecx",18-14); # lo>>18 164 &xor ("eax","edi"); 165 &shr ("edx",18-14); # hi>>18 166 &xor ("eax","ecx"); 167 &shl ("esi",23-18); # lo<<23 168 &xor ("ebx","edx"); 169 &shl ("edi",23-18); # hi<<23 170 &xor ("eax","esi"); 171 &xor ("ebx","edi"); # T1 = Sigma1(e) 172 173 &mov ("ecx",$Flo); 174 &mov ("edx",$Fhi); 175 &mov ("esi",$Glo); 176 &mov ("edi",$Ghi); 177 &add ("eax",$Hlo); 178 &adc ("ebx",$Hhi); # T1 += h 179 &xor ("ecx","esi"); 180 &xor ("edx","edi"); 181 &and ("ecx",$Elo); 182 &and ("edx",$Ehi); 183 &add ("eax",&DWP(8*(9+15)+0,"esp")); 184 &adc ("ebx",&DWP(8*(9+15)+4,"esp")); # T1 += X[0] 185 &xor ("ecx","esi"); 186 &xor ("edx","edi"); # Ch(e,f,g) = (f^g)&e)^g 187 188 &mov ("esi",&DWP(0,$K512)); 189 &mov ("edi",&DWP(4,$K512)); # K[i] 190 &add ("eax","ecx"); 191 &adc ("ebx","edx"); # T1 += Ch(e,f,g) 192 &mov ("ecx",$Dlo); 193 &mov ("edx",$Dhi); 194 &add ("eax","esi"); 195 &adc ("ebx","edi"); # T1 += K[i] 196 &mov ($Tlo,"eax"); 197 &mov ($Thi,"ebx"); # put T1 away 198 &add ("eax","ecx"); 199 &adc ("ebx","edx"); # d += T1 200 201 #define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) 202 # LO lo>>28^hi<<4 ^ hi>>2^lo<<30 ^ hi>>7^lo<<25 203 # HI hi>>28^lo<<4 ^ lo>>2^hi<<30 ^ lo>>7^hi<<25 204 &mov ("ecx",$Alo); 205 &mov ("edx",$Ahi); 206 &mov ($Dlo,"eax"); 207 &mov ($Dhi,"ebx"); 208 &mov ("esi","ecx"); 209 210 &shr ("ecx",2); # lo>>2 211 &mov ("edi","edx"); 212 &shr ("edx",2); # hi>>2 213 &mov ("ebx","ecx"); 214 &shl ("esi",4); # lo<<4 215 &mov ("eax","edx"); 216 &shl ("edi",4); # hi<<4 217 &xor ("ebx","esi"); 218 219 &shr ("ecx",7-2); # lo>>7 220 &xor ("eax","edi"); 221 &shr ("edx",7-2); # hi>>7 222 &xor ("ebx","ecx"); 223 &shl ("esi",25-4); # lo<<25 224 &xor ("eax","edx"); 225 &shl ("edi",25-4); # hi<<25 226 &xor ("eax","esi"); 227 228 &shr ("ecx",28-7); # lo>>28 229 &xor ("ebx","edi"); 230 &shr ("edx",28-7); # hi>>28 231 &xor ("eax","ecx"); 232 &shl ("esi",30-25); # lo<<30 233 &xor ("ebx","edx"); 234 &shl ("edi",30-25); # hi<<30 235 &xor ("eax","esi"); 236 &xor ("ebx","edi"); # Sigma0(a) 237 238 &mov ("ecx",$Alo); 239 &mov ("edx",$Ahi); 240 &mov ("esi",$Blo); 241 &mov ("edi",$Bhi); 242 &add ("eax",$Tlo); 243 &adc ("ebx",$Thi); # T1 = Sigma0(a)+T1 244 &or ("ecx","esi"); 245 &or ("edx","edi"); 246 &and ("ecx",$Clo); 247 &and ("edx",$Chi); 248 &and ("esi",$Alo); 249 &and ("edi",$Ahi); 250 &or ("ecx","esi"); 251 &or ("edx","edi"); # Maj(a,b,c) = ((a|b)&c)|(a&b) 252 253 &add ("eax","ecx"); 254 &adc ("ebx","edx"); # T1 += Maj(a,b,c) 255 &mov ($Tlo,"eax"); 256 &mov ($Thi,"ebx"); 257 258 &mov (&LB("edx"),&BP(0,$K512)); # pre-fetch LSB of *K 259 &sub ("esp",8); 260 &lea ($K512,&DWP(8,$K512)); # K++ 261} 262 263 264&static_label("K512"); 265&function_begin("sha512_block_data_order"); 266 &mov ("esi",wparam(0)); # ctx 267 &mov ("edi",wparam(1)); # inp 268 &mov ("eax",wparam(2)); # num 269 &mov ("ebx","esp"); # saved sp 270 271 &picsetup($K512); 272if ($sse2) { 273 &picsymbol("edx", "OPENSSL_ia32cap_P", $K512); 274} 275 &picsymbol($K512, &label("K512"), $K512); 276 277 &sub ("esp",16); 278 &and ("esp",-64); 279 280 &shl ("eax",7); 281 &add ("eax","edi"); 282 &mov (&DWP(0,"esp"),"esi"); # ctx 283 &mov (&DWP(4,"esp"),"edi"); # inp 284 &mov (&DWP(8,"esp"),"eax"); # inp+num*128 285 &mov (&DWP(12,"esp"),"ebx"); # saved sp 286 287if ($sse2) { 288 &bt (&DWP(0,"edx"),"\$IA32CAP_BIT0_SSE2"); 289 &jnc (&label("loop_x86")); 290 291 # load ctx->h[0-7] 292 &movq ($A,&QWP(0,"esi")); 293 &movq ("mm1",&QWP(8,"esi")); 294 &movq ("mm2",&QWP(16,"esi")); 295 &movq ("mm3",&QWP(24,"esi")); 296 &movq ($E,&QWP(32,"esi")); 297 &movq ("mm5",&QWP(40,"esi")); 298 &movq ("mm6",&QWP(48,"esi")); 299 &movq ("mm7",&QWP(56,"esi")); 300 &sub ("esp",8*10); 301 302&set_label("loop_sse2",16); 303 # &movq ($Asse2,$A); 304 &movq ($Bsse2,"mm1"); 305 &movq ($Csse2,"mm2"); 306 &movq ($Dsse2,"mm3"); 307 # &movq ($Esse2,$E); 308 &movq ($Fsse2,"mm5"); 309 &movq ($Gsse2,"mm6"); 310 &movq ($Hsse2,"mm7"); 311 312 &mov ("ecx",&DWP(0,"edi")); 313 &mov ("edx",&DWP(4,"edi")); 314 &add ("edi",8); 315 &bswap ("ecx"); 316 &bswap ("edx"); 317 &mov (&DWP(8*9+4,"esp"),"ecx"); 318 &mov (&DWP(8*9+0,"esp"),"edx"); 319 320&set_label("00_14_sse2",16); 321 &mov ("eax",&DWP(0,"edi")); 322 &mov ("ebx",&DWP(4,"edi")); 323 &add ("edi",8); 324 &bswap ("eax"); 325 &bswap ("ebx"); 326 &mov (&DWP(8*8+4,"esp"),"eax"); 327 &mov (&DWP(8*8+0,"esp"),"ebx"); 328 329 &BODY_00_15_sse2(); 330 331 &cmp (&LB("edx"),0x35); 332 &jne (&label("00_14_sse2")); 333 334 &BODY_00_15_sse2(1); 335 336&set_label("16_79_sse2",16); 337 #&movq ("mm2",&QWP(8*(9+16-1),"esp")); #prefetched in BODY_00_15 338 #&movq ("mm6",&QWP(8*(9+16-14),"esp")); 339 &movq ("mm1","mm2"); 340 341 &psrlq ("mm2",1); 342 &movq ("mm7","mm6"); 343 &psrlq ("mm6",6); 344 &movq ("mm3","mm2"); 345 346 &psrlq ("mm2",7-1); 347 &movq ("mm5","mm6"); 348 &psrlq ("mm6",19-6); 349 &pxor ("mm3","mm2"); 350 351 &psrlq ("mm2",8-7); 352 &pxor ("mm5","mm6"); 353 &psrlq ("mm6",61-19); 354 &pxor ("mm3","mm2"); 355 356 &movq ("mm2",&QWP(8*(9+16),"esp")); 357 358 &psllq ("mm1",56); 359 &pxor ("mm5","mm6"); 360 &psllq ("mm7",3); 361 &pxor ("mm3","mm1"); 362 363 &paddq ("mm2",&QWP(8*(9+16-9),"esp")); 364 365 &psllq ("mm1",63-56); 366 &pxor ("mm5","mm7"); 367 &psllq ("mm7",45-3); 368 &pxor ("mm3","mm1"); 369 &pxor ("mm5","mm7"); 370 371 &paddq ("mm3","mm5"); 372 &paddq ("mm3","mm2"); 373 &movq (&QWP(8*9,"esp"),"mm3"); 374 375 &BODY_00_15_sse2(1); 376 377 &cmp (&LB("edx"),0x17); 378 &jne (&label("16_79_sse2")); 379 380 # &movq ($A,$Asse2); 381 &movq ("mm1",$Bsse2); 382 &movq ("mm2",$Csse2); 383 &movq ("mm3",$Dsse2); 384 # &movq ($E,$Esse2); 385 &movq ("mm5",$Fsse2); 386 &movq ("mm6",$Gsse2); 387 &movq ("mm7",$Hsse2); 388 389 &paddq ($A,&QWP(0,"esi")); 390 &paddq ("mm1",&QWP(8,"esi")); 391 &paddq ("mm2",&QWP(16,"esi")); 392 &paddq ("mm3",&QWP(24,"esi")); 393 &paddq ($E,&QWP(32,"esi")); 394 &paddq ("mm5",&QWP(40,"esi")); 395 &paddq ("mm6",&QWP(48,"esi")); 396 &paddq ("mm7",&QWP(56,"esi")); 397 398 &movq (&QWP(0,"esi"),$A); 399 &movq (&QWP(8,"esi"),"mm1"); 400 &movq (&QWP(16,"esi"),"mm2"); 401 &movq (&QWP(24,"esi"),"mm3"); 402 &movq (&QWP(32,"esi"),$E); 403 &movq (&QWP(40,"esi"),"mm5"); 404 &movq (&QWP(48,"esi"),"mm6"); 405 &movq (&QWP(56,"esi"),"mm7"); 406 407 &add ("esp",8*80); # destroy frame 408 &sub ($K512,8*80); # rewind K 409 410 &cmp ("edi",&DWP(8*10+8,"esp")); # are we done yet? 411 &jb (&label("loop_sse2")); 412 413 &emms (); 414 &mov ("esp",&DWP(8*10+12,"esp")); # restore sp 415&function_end_A(); 416} 417&set_label("loop_x86",16); 418 # copy input block to stack reversing byte and qword order 419 for ($i=0;$i<8;$i++) { 420 &mov ("eax",&DWP($i*16+0,"edi")); 421 &mov ("ebx",&DWP($i*16+4,"edi")); 422 &mov ("ecx",&DWP($i*16+8,"edi")); 423 &mov ("edx",&DWP($i*16+12,"edi")); 424 &bswap ("eax"); 425 &bswap ("ebx"); 426 &bswap ("ecx"); 427 &bswap ("edx"); 428 &push ("eax"); 429 &push ("ebx"); 430 &push ("ecx"); 431 &push ("edx"); 432 } 433 &add ("edi",128); 434 &sub ("esp",9*8); # place for T,A,B,C,D,E,F,G,H 435 &mov (&DWP(8*(9+16)+4,"esp"),"edi"); 436 437 # copy ctx->h[0-7] to A,B,C,D,E,F,G,H on stack 438 &lea ("edi",&DWP(8,"esp")); 439 &mov ("ecx",16); 440 &data_word(0xA5F3F689); # rep movsd 441 442&set_label("00_15_x86",16); 443 &BODY_00_15_x86(); 444 445 &cmp (&LB("edx"),0x94); 446 &jne (&label("00_15_x86")); 447 448&set_label("16_79_x86",16); 449 #define sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) 450 # LO lo>>1^hi<<31 ^ lo>>8^hi<<24 ^ lo>>7^hi<<25 451 # HI hi>>1^lo<<31 ^ hi>>8^lo<<24 ^ hi>>7 452 &mov ("ecx",&DWP(8*(9+15+16-1)+0,"esp")); 453 &mov ("edx",&DWP(8*(9+15+16-1)+4,"esp")); 454 &mov ("esi","ecx"); 455 456 &shr ("ecx",1); # lo>>1 457 &mov ("edi","edx"); 458 &shr ("edx",1); # hi>>1 459 &mov ("eax","ecx"); 460 &shl ("esi",24); # lo<<24 461 &mov ("ebx","edx"); 462 &shl ("edi",24); # hi<<24 463 &xor ("ebx","esi"); 464 465 &shr ("ecx",7-1); # lo>>7 466 &xor ("eax","edi"); 467 &shr ("edx",7-1); # hi>>7 468 &xor ("eax","ecx"); 469 &shl ("esi",31-24); # lo<<31 470 &xor ("ebx","edx"); 471 &shl ("edi",25-24); # hi<<25 472 &xor ("ebx","esi"); 473 474 &shr ("ecx",8-7); # lo>>8 475 &xor ("eax","edi"); 476 &shr ("edx",8-7); # hi>>8 477 &xor ("eax","ecx"); 478 &shl ("edi",31-25); # hi<<31 479 &xor ("ebx","edx"); 480 &xor ("eax","edi"); # T1 = sigma0(X[-15]) 481 482 &mov (&DWP(0,"esp"),"eax"); 483 &mov (&DWP(4,"esp"),"ebx"); # put T1 away 484 485 #define sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) 486 # LO lo>>19^hi<<13 ^ hi>>29^lo<<3 ^ lo>>6^hi<<26 487 # HI hi>>19^lo<<13 ^ lo>>29^hi<<3 ^ hi>>6 488 &mov ("ecx",&DWP(8*(9+15+16-14)+0,"esp")); 489 &mov ("edx",&DWP(8*(9+15+16-14)+4,"esp")); 490 &mov ("esi","ecx"); 491 492 &shr ("ecx",6); # lo>>6 493 &mov ("edi","edx"); 494 &shr ("edx",6); # hi>>6 495 &mov ("eax","ecx"); 496 &shl ("esi",3); # lo<<3 497 &mov ("ebx","edx"); 498 &shl ("edi",3); # hi<<3 499 &xor ("eax","esi"); 500 501 &shr ("ecx",19-6); # lo>>19 502 &xor ("ebx","edi"); 503 &shr ("edx",19-6); # hi>>19 504 &xor ("eax","ecx"); 505 &shl ("esi",13-3); # lo<<13 506 &xor ("ebx","edx"); 507 &shl ("edi",13-3); # hi<<13 508 &xor ("ebx","esi"); 509 510 &shr ("ecx",29-19); # lo>>29 511 &xor ("eax","edi"); 512 &shr ("edx",29-19); # hi>>29 513 &xor ("ebx","ecx"); 514 &shl ("edi",26-13); # hi<<26 515 &xor ("eax","edx"); 516 &xor ("eax","edi"); # sigma1(X[-2]) 517 518 &mov ("ecx",&DWP(8*(9+15+16)+0,"esp")); 519 &mov ("edx",&DWP(8*(9+15+16)+4,"esp")); 520 &add ("eax",&DWP(0,"esp")); 521 &adc ("ebx",&DWP(4,"esp")); # T1 = sigma1(X[-2])+T1 522 &mov ("esi",&DWP(8*(9+15+16-9)+0,"esp")); 523 &mov ("edi",&DWP(8*(9+15+16-9)+4,"esp")); 524 &add ("eax","ecx"); 525 &adc ("ebx","edx"); # T1 += X[-16] 526 &add ("eax","esi"); 527 &adc ("ebx","edi"); # T1 += X[-7] 528 &mov (&DWP(8*(9+15)+0,"esp"),"eax"); 529 &mov (&DWP(8*(9+15)+4,"esp"),"ebx"); # save X[0] 530 531 &BODY_00_15_x86(); 532 533 &cmp (&LB("edx"),0x17); 534 &jne (&label("16_79_x86")); 535 536 &mov ("esi",&DWP(8*(9+16+80)+0,"esp"));# ctx 537 &mov ("edi",&DWP(8*(9+16+80)+4,"esp"));# inp 538 for($i=0;$i<4;$i++) { 539 &mov ("eax",&DWP($i*16+0,"esi")); 540 &mov ("ebx",&DWP($i*16+4,"esi")); 541 &mov ("ecx",&DWP($i*16+8,"esi")); 542 &mov ("edx",&DWP($i*16+12,"esi")); 543 &add ("eax",&DWP(8+($i*16)+0,"esp")); 544 &adc ("ebx",&DWP(8+($i*16)+4,"esp")); 545 &mov (&DWP($i*16+0,"esi"),"eax"); 546 &mov (&DWP($i*16+4,"esi"),"ebx"); 547 &add ("ecx",&DWP(8+($i*16)+8,"esp")); 548 &adc ("edx",&DWP(8+($i*16)+12,"esp")); 549 &mov (&DWP($i*16+8,"esi"),"ecx"); 550 &mov (&DWP($i*16+12,"esi"),"edx"); 551 } 552 &add ("esp",8*(9+16+80)); # destroy frame 553 &sub ($K512,8*80); # rewind K 554 555 &cmp ("edi",&DWP(8,"esp")); # are we done yet? 556 &jb (&label("loop_x86")); 557 558 &mov ("esp",&DWP(12,"esp")); # restore sp 559&function_end_A(); 560&function_end_B("sha512_block_data_order"); 561 562 &rodataseg(); 563&set_label("K512",64); 564 &data_word(0xd728ae22,0x428a2f98); # u64 565 &data_word(0x23ef65cd,0x71374491); # u64 566 &data_word(0xec4d3b2f,0xb5c0fbcf); # u64 567 &data_word(0x8189dbbc,0xe9b5dba5); # u64 568 &data_word(0xf348b538,0x3956c25b); # u64 569 &data_word(0xb605d019,0x59f111f1); # u64 570 &data_word(0xaf194f9b,0x923f82a4); # u64 571 &data_word(0xda6d8118,0xab1c5ed5); # u64 572 &data_word(0xa3030242,0xd807aa98); # u64 573 &data_word(0x45706fbe,0x12835b01); # u64 574 &data_word(0x4ee4b28c,0x243185be); # u64 575 &data_word(0xd5ffb4e2,0x550c7dc3); # u64 576 &data_word(0xf27b896f,0x72be5d74); # u64 577 &data_word(0x3b1696b1,0x80deb1fe); # u64 578 &data_word(0x25c71235,0x9bdc06a7); # u64 579 &data_word(0xcf692694,0xc19bf174); # u64 580 &data_word(0x9ef14ad2,0xe49b69c1); # u64 581 &data_word(0x384f25e3,0xefbe4786); # u64 582 &data_word(0x8b8cd5b5,0x0fc19dc6); # u64 583 &data_word(0x77ac9c65,0x240ca1cc); # u64 584 &data_word(0x592b0275,0x2de92c6f); # u64 585 &data_word(0x6ea6e483,0x4a7484aa); # u64 586 &data_word(0xbd41fbd4,0x5cb0a9dc); # u64 587 &data_word(0x831153b5,0x76f988da); # u64 588 &data_word(0xee66dfab,0x983e5152); # u64 589 &data_word(0x2db43210,0xa831c66d); # u64 590 &data_word(0x98fb213f,0xb00327c8); # u64 591 &data_word(0xbeef0ee4,0xbf597fc7); # u64 592 &data_word(0x3da88fc2,0xc6e00bf3); # u64 593 &data_word(0x930aa725,0xd5a79147); # u64 594 &data_word(0xe003826f,0x06ca6351); # u64 595 &data_word(0x0a0e6e70,0x14292967); # u64 596 &data_word(0x46d22ffc,0x27b70a85); # u64 597 &data_word(0x5c26c926,0x2e1b2138); # u64 598 &data_word(0x5ac42aed,0x4d2c6dfc); # u64 599 &data_word(0x9d95b3df,0x53380d13); # u64 600 &data_word(0x8baf63de,0x650a7354); # u64 601 &data_word(0x3c77b2a8,0x766a0abb); # u64 602 &data_word(0x47edaee6,0x81c2c92e); # u64 603 &data_word(0x1482353b,0x92722c85); # u64 604 &data_word(0x4cf10364,0xa2bfe8a1); # u64 605 &data_word(0xbc423001,0xa81a664b); # u64 606 &data_word(0xd0f89791,0xc24b8b70); # u64 607 &data_word(0x0654be30,0xc76c51a3); # u64 608 &data_word(0xd6ef5218,0xd192e819); # u64 609 &data_word(0x5565a910,0xd6990624); # u64 610 &data_word(0x5771202a,0xf40e3585); # u64 611 &data_word(0x32bbd1b8,0x106aa070); # u64 612 &data_word(0xb8d2d0c8,0x19a4c116); # u64 613 &data_word(0x5141ab53,0x1e376c08); # u64 614 &data_word(0xdf8eeb99,0x2748774c); # u64 615 &data_word(0xe19b48a8,0x34b0bcb5); # u64 616 &data_word(0xc5c95a63,0x391c0cb3); # u64 617 &data_word(0xe3418acb,0x4ed8aa4a); # u64 618 &data_word(0x7763e373,0x5b9cca4f); # u64 619 &data_word(0xd6b2b8a3,0x682e6ff3); # u64 620 &data_word(0x5defb2fc,0x748f82ee); # u64 621 &data_word(0x43172f60,0x78a5636f); # u64 622 &data_word(0xa1f0ab72,0x84c87814); # u64 623 &data_word(0x1a6439ec,0x8cc70208); # u64 624 &data_word(0x23631e28,0x90befffa); # u64 625 &data_word(0xde82bde9,0xa4506ceb); # u64 626 &data_word(0xb2c67915,0xbef9a3f7); # u64 627 &data_word(0xe372532b,0xc67178f2); # u64 628 &data_word(0xea26619c,0xca273ece); # u64 629 &data_word(0x21c0c207,0xd186b8c7); # u64 630 &data_word(0xcde0eb1e,0xeada7dd6); # u64 631 &data_word(0xee6ed178,0xf57d4f7f); # u64 632 &data_word(0x72176fba,0x06f067aa); # u64 633 &data_word(0xa2c898a6,0x0a637dc5); # u64 634 &data_word(0xbef90dae,0x113f9804); # u64 635 &data_word(0x131c471b,0x1b710b35); # u64 636 &data_word(0x23047d84,0x28db77f5); # u64 637 &data_word(0x40c72493,0x32caab7b); # u64 638 &data_word(0x15c9bebc,0x3c9ebe0a); # u64 639 &data_word(0x9c100d4c,0x431d67c4); # u64 640 &data_word(0xcb3e42b6,0x4cc5d4be); # u64 641 &data_word(0xfc657e2a,0x597f299c); # u64 642 &data_word(0x3ad6faec,0x5fcb6fab); # u64 643 &data_word(0x4a475817,0x6c44198c); # u64 644 &previous(); 645 646&asm_finish(); 647