progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / symm / rijndael-x86ish-aesni.S
index dc80f4d..ad9236a 100644 (file)
 /// MA 02111-1307, USA.
 
 ///--------------------------------------------------------------------------
-/// External definitions.
+/// Preliminaries.
 
 #include "config.h"
 #include "asm-common.h"
 
+       .arch   .aes
+
        .extern F(abort)
        .extern F(rijndael_rcon)
 
+       .text
+
 ///--------------------------------------------------------------------------
 /// Main code.
 
-       .arch   .aes
-       .text
-
 /// The AESNI instructions implement a little-endian version of AES, but
 /// Catacomb's internal interface presents as big-endian so as to work better
 /// with things like GCM.  We therefore maintain the round keys in
@@ -69,15 +70,12 @@ ENDFUNC
 
 FUNC(rijndael_setup_x86ish_aesni)
 
-#define SI WHOLE(si)
-#define DI WHOLE(di)
-
 #if CPUFAM_X86
        // Arguments are on the stack.  We'll need to stack the caller's
        // register veriables, but we'll manage.
 
-#  define CTX ebp                      // context pointer
-#  define BLKSZ [esp + 24]             // block size
+#  define CTX BP                       // context pointer
+#  define BLKSZ [SP + 24]              // block size
 
 #  define KSZ ebx                      // key size
 #  define NKW edx                      // total number of key words
@@ -91,15 +89,15 @@ FUNC(rijndael_setup_x86ish_aesni)
 #  define BLKOFF edx                   // block size in bytes
 
        // Stack the caller's registers.
-       pushreg ebp
+       pushreg BP
        pushreg ebx
        pushreg esi
        pushreg edi
 
        // Set up our own variables.
-       mov     CTX, [esp + 20]         // context base pointer
-       mov     SI, [esp + 28]          // key material
-       mov     KSZ, [esp + 32]         // key size, in words
+       mov     CTX, [SP + 20]          // context base pointer
+       mov     SI, [SP + 28]           // key material
+       mov     KSZ, [SP + 32]          // key size, in words
 #endif
 
 #if CPUFAM_AMD64 && ABI_SYSV
@@ -211,16 +209,16 @@ FUNC(rijndael_setup_x86ish_aesni)
        // Fourth word of the cycle, and seven or eight words of key.  Do a
        // byte substitution.
        movd    xmm0, eax
-       pshufd  xmm0, xmm0, SHUF(3, 0, 1, 2)
+       pshufd  xmm0, xmm0, SHUF(2, 1, 0, 3)
        aeskeygenassist xmm1, xmm0, 0
        movd    eax, xmm1
        jmp     2f
 
        // First word of the cycle.  This is the complicated piece.
 1:     movd    xmm0, eax
-       pshufd  xmm0, xmm0, SHUF(1, 2, 3, 0)
+       pshufd  xmm0, xmm0, SHUF(0, 3, 2, 1)
        aeskeygenassist xmm1, xmm0, 0
-       pshufd  xmm1, xmm1, SHUF(3, 0, 1, 2)
+       pshufd  xmm1, xmm1, SHUF(2, 1, 0, 3)
        movd    eax, xmm1
        xor     al, [RCON]
        inc     RCON
@@ -329,7 +327,7 @@ FUNC(rijndael_setup_x86ish_aesni)
        popreg  edi
        popreg  esi
        popreg  ebx
-       popreg  ebp
+       popreg  BP
 #endif
 #if CPUFAM_AMD64 && ABI_WIN
        popreg  rdi
@@ -388,8 +386,8 @@ ENDFUNC
 #  define DST edx
 #  define NR ecx
 
-       mov     K, [esp + 4]
-       mov     SRC, [esp + 8]
+       mov     K, [SP + 4]
+       mov     SRC, [SP + 8]
 #endif
 
 #if CPUFAM_AMD64 && ABI_SYSV
@@ -427,7 +425,7 @@ ENDFUNC
        add     K, 16
        pxor    xmm0, xmm1
 #if CPUFAM_X86
-       mov     DST, [esp + 12]
+       mov     DST, [SP + 12]
 #endif
 
        // Dispatch to the correct code.