chiark / gitweb /
symm/rijndael-x86ish-aesni.S: Have `endswap_block' copy NKW to ECX.
[catacomb] / symm / rijndael-x86ish-aesni.S
index 520a72e4a21c8c43e26a7910242b7c04eb8d4514..f9386541c8ff4be7524d32dd3c4606ee622b7351 100644 (file)
@@ -374,12 +374,10 @@ FUNC(rijndael_setup_x86ish_aesni)
 #endif
 
        // End-swap the encryption keys.
-       mov     ecx, NKW
        lea     SI, [CTX + w]
        call    endswap_block
 
        // And the decryption keys.
-       mov     ecx, NKW
        lea     SI, [CTX + wi]
        call    endswap_block
 
@@ -398,14 +396,15 @@ FUNC(rijndael_setup_x86ish_aesni)
 
        .align  16
 endswap_block:
-       // End-swap ECX words starting at SI.  The end-swapping table is
+       // End-swap NKW words starting at SI.  The end-swapping table is
        // already loaded into XMM5; and it's OK to work in 16-byte chunks.
-       movdqu  xmm1, [SI]
+       mov     ecx, NKW
+0:     movdqu  xmm1, [SI]
        pshufb  xmm1, xmm5
        movdqu  [SI], xmm1
        add     SI, 16
        sub     ecx, 4
-       ja      endswap_block
+       ja      0b
        ret
 
 #undef CTX