diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/alg_amd64/asm_macr.h | 15 | ||||
-rw-r--r-- | modules/alg_amd64/mp_mulop.S | 23 | ||||
-rw-r--r-- | modules/alg_amd64/sha160.cpp | 4 | ||||
-rw-r--r-- | modules/alg_amd64/sha1core.S | 20 |
4 files changed, 29 insertions, 33 deletions
diff --git a/modules/alg_amd64/asm_macr.h b/modules/alg_amd64/asm_macr.h index 380d05b02..4ac98bd03 100644 --- a/modules/alg_amd64/asm_macr.h +++ b/modules/alg_amd64/asm_macr.h @@ -29,21 +29,6 @@ func_name: ret /************************************************* -* Loop Control * -*************************************************/ -#define START_LOOP(LABEL) \ - ALIGN; \ - LABEL##_LOOP: - -#define LOOP_UNTIL_EQ(REG, NUM, LABEL) \ - cmp IMM(NUM), REG; \ - jne LABEL##_LOOP - -#define LOOP_UNTIL_LT(REG, NUM, LABEL) \ - cmp IMM(NUM), REG; \ - jge LABEL##_LOOP - -/************************************************* * Conditional Jumps * *************************************************/ #define JUMP_IF_ZERO(REG, LABEL) \ diff --git a/modules/alg_amd64/mp_mulop.S b/modules/alg_amd64/mp_mulop.S index f1a2a2e75..983a34a82 100644 --- a/modules/alg_amd64/mp_mulop.S +++ b/modules/alg_amd64/mp_mulop.S @@ -1,6 +1,6 @@ /************************************************* * Multiply/Add Algorithm Source File * -* (C) 1999-2007 Jack Lloyd * +* (C) 1999-2008 Jack Lloyd * *************************************************/ #include <botan/asm_macr.h> @@ -24,8 +24,8 @@ START_FUNCTION(bigint_mul_add_words) ASSIGN(LOOP_CTR, X_SIZE) - JUMP_IF_ZERO(LOOP_CTR, .DONE) - JUMP_IF_LT(LOOP_CTR, 8, .MULADD1_LOOP) + JUMP_IF_ZERO(LOOP_CTR, .L_MULADD_DONE) + JUMP_IF_LT(LOOP_CTR, 8, .LOOP_MULADD1) #define MULADD_OP(N) \ ASSIGN(MUL_LO, ARRAY8(X_ARR, N)) ; \ @@ -38,7 +38,8 @@ START_FUNCTION(bigint_mul_add_words) ADD_LAST_CARRY(CARRY) ; \ ASSIGN(ARRAY8(Z_ARR, N), Z_WORD) -START_LOOP(.MULADD8) +ALIGN +.LOOP_MULADD8: MULADD_OP(0) MULADD_OP(1) MULADD_OP(2) @@ -51,18 +52,22 @@ START_LOOP(.MULADD8) SUB_IMM(LOOP_CTR, 8) ADD_IMM(Z_ARR, 64) ADD_IMM(X_ARR, 64) -LOOP_UNTIL_LT(LOOP_CTR, 8, .MULADD8) + cmp IMM(8), LOOP_CTR + jge .LOOP_MULADD8 - JUMP_IF_ZERO(LOOP_CTR, .DONE) + JUMP_IF_ZERO(LOOP_CTR, .L_MULADD_DONE) -START_LOOP(.MULADD1) +ALIGN +.LOOP_MULADD1: MULADD_OP(0) SUB_IMM(LOOP_CTR, 1) ADD_IMM(Z_ARR, 8) ADD_IMM(X_ARR, 8) -LOOP_UNTIL_EQ(LOOP_CTR, 0, .MULADD1) -.DONE: + cmp IMM(0), LOOP_CTR + jne .LOOP_MULADD1 + +.L_MULADD_DONE: RETURN_VALUE_IS(CARRY) END_FUNCTION(bigint_mul_add_words) diff --git a/modules/alg_amd64/sha160.cpp b/modules/alg_amd64/sha160.cpp index 180f050c9..97ec9d522 100644 --- a/modules/alg_amd64/sha160.cpp +++ b/modules/alg_amd64/sha160.cpp @@ -8,14 +8,14 @@ namespace Botan { -extern "C" void sha160_core(u32bit[5], const byte[64], u32bit[80]); +extern "C" void botan_asm_sha160_core(u32bit[5], const byte[64], u32bit[80]); /************************************************* * SHA-160 Compression Function * *************************************************/ void SHA_160::hash(const byte input[]) { - sha160_core(digest, input, W); + botan_asm_sha160_core(digest, input, W); } /************************************************* diff --git a/modules/alg_amd64/sha1core.S b/modules/alg_amd64/sha1core.S index c3f530d70..f145f8517 100644 --- a/modules/alg_amd64/sha1core.S +++ b/modules/alg_amd64/sha1core.S @@ -7,7 +7,7 @@ START_LISTING(sha1core.S) -START_FUNCTION(sha160_core) +START_FUNCTION(botan_asm_sha160_core) #define DIGEST_ARR %rdi #define INPUT %rsi @@ -22,7 +22,8 @@ START_FUNCTION(sha160_core) ZEROIZE(LOOP_CTR) -START_LOOP(.LOAD_INPUT) +ALIGN; +.LOOP_LOAD_INPUT: addl $8, %eax movq ARRAY8(INPUT, 0), %r8 @@ -47,16 +48,20 @@ START_LOOP(.LOAD_INPUT) addq $32, W addq $32, INPUT -LOOP_UNTIL_EQ(LOOP_CTR, 16, .LOAD_INPUT) + + cmp IMM(16), LOOP_CTR + jne .LOOP_LOAD_INPUT /* - #define A %r8d +#define A %r8d #define B %r9d #define C %r10d #define D %r11d #define E %ecx */ -START_LOOP(.EXPANSION) + +ALIGN; +.LOOP_EXPANSION: addl $4, LOOP_CTR ZEROIZE(A) @@ -91,7 +96,8 @@ START_LOOP(.EXPANSION) ASSIGN(ARRAY4(W, 3), A) addq $16, W -LOOP_UNTIL_EQ(LOOP_CTR, 80, .EXPANSION) + cmp IMM(80), LOOP_CTR + jne .LOOP_EXPANSION subq $320, W @@ -249,4 +255,4 @@ LOOP_UNTIL_EQ(LOOP_CTR, 80, .EXPANSION) ADD(ARRAY4(DIGEST_ARR, 3), B) ADD(ARRAY4(DIGEST_ARR, 4), C) -END_FUNCTION(sha160_core) +END_FUNCTION(botan_asm_sha160_core) |