diff options
author | lloyd <[email protected]> | 2006-08-13 07:00:44 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-08-13 07:00:44 +0000 |
commit | faf83849264e07d7606157e350034fddf64a48fe (patch) | |
tree | 2acc67953f0361b2b5b24cc9fd95aa2ca53d2881 /modules | |
parent | 386e319a6ce652cf09798c0b6c010feca2c922f4 (diff) |
Add a loop macro, continue converting the assembly to use the wrapper
macros.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/sha_x86/asm_macr.h | 8 | ||||
-rw-r--r-- | modules/sha_x86/sha1core.S | 30 |
2 files changed, 24 insertions, 14 deletions
diff --git a/modules/sha_x86/asm_macr.h b/modules/sha_x86/asm_macr.h index 2736c7d9a..095d656bf 100644 --- a/modules/sha_x86/asm_macr.h +++ b/modules/sha_x86/asm_macr.h @@ -20,6 +20,10 @@ .type func_name,@function; \ func_name: +#define LOOP_UNTIL(REG, NUM, LABEL) \ + cmpl NUM, REG; \ + jne LABEL + #define EAX %eax #define EBX %ebx #define ECX %ecx @@ -34,6 +38,10 @@ func_name: #define ADD(FROM, TO) addl FROM, TO +#define ARRAY(REG, NUM) 4*NUM(REG) + +#define BSWAP(REG) bswapl REG + #define IMM(VAL) $VAL #define ZEROIZE(REG) xorl REG, REG diff --git a/modules/sha_x86/sha1core.S b/modules/sha_x86/sha1core.S index b1f0e4873..01c6c7c18 100644 --- a/modules/sha_x86/sha1core.S +++ b/modules/sha_x86/sha1core.S @@ -24,31 +24,33 @@ FUNCTION(sha160_core) .LOAD_INPUT_LOOP: ADD(IMM(4), ESI) - movl 0(EBP), EAX - movl 4(EBP), EBX - movl 8(EBP), ECX - bswapl EAX - movl 12(EBP), EDX - bswapl EBX - addl $16, EBP - bswapl ECX - bswapl EDX + MOV(ARRAY(EBP, 0), EAX) + MOV(ARRAY(EBP, 1), EBX) + MOV(ARRAY(EBP, 2), ECX) + MOV(ARRAY(EBP, 3), EDX) + + ADD(IMM(16), EBP) + + BSWAP(EAX) + BSWAP(EBX) + BSWAP(ECX) + BSWAP(EDX) movl EAX, -16(EDI,ESI,4) movl EBX, -12(EDI,ESI,4) movl ECX, -8(EDI,ESI,4) movl EDX, -4(EDI,ESI,4) - cmpl $16, ESI - jne .LOAD_INPUT_LOOP + LOOP_UNTIL(ESI, IMM(16), .LOAD_INPUT_LOOP) leal 64(EDI), EBP ALIGN .EXPANSION_LOOP: - addl $4, ESI + ADD(IMM(4), ESI) - ZEROIZE(EAX) + ZEROIZE(EAX) + movl -4(EBP), EBX movl -8(EBP), ECX movl -12(EBP), EDX @@ -83,7 +85,7 @@ FUNCTION(sha160_core) addl $16, EBP cmpl $80, ESI - jne .EXPANSION_LOOP + LOOP_UNTIL(ESI, IMM(80), .EXPANSION_LOOP) movl 20(%esp), EBP movl 0(EBP), EAX |