diff options
author | lloyd <[email protected]> | 2006-08-13 07:13:52 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-08-13 07:13:52 +0000 |
commit | 7668bc4c22e12b95048222ebefa21d4990c7abad (patch) | |
tree | 9f6fcff71755c126c233d9dba1ed20bc40032229 /modules | |
parent | faf83849264e07d7606157e350034fddf64a48fe (diff) |
Further macro-ization
Diffstat (limited to 'modules')
-rw-r--r-- | modules/sha_x86/asm_macr.h | 9 | ||||
-rw-r--r-- | modules/sha_x86/sha1core.S | 78 |
2 files changed, 44 insertions, 43 deletions
diff --git a/modules/sha_x86/asm_macr.h b/modules/sha_x86/asm_macr.h index 095d656bf..d5dcfd238 100644 --- a/modules/sha_x86/asm_macr.h +++ b/modules/sha_x86/asm_macr.h @@ -22,7 +22,11 @@ func_name: #define LOOP_UNTIL(REG, NUM, LABEL) \ cmpl NUM, REG; \ - jne LABEL + jne LABEL##_LOOP + +#define START_LOOP(LABEL) \ + ALIGN; \ + LABEL##_LOOP: #define EAX %eax #define EBX %ebx @@ -37,6 +41,9 @@ func_name: #define ADD(FROM, TO) addl FROM, TO +#define XOR(FROM, TO) xorl FROM, TO +#define ROTL(NUM, REG) roll NUM, REG + #define ARRAY(REG, NUM) 4*NUM(REG) diff --git a/modules/sha_x86/sha1core.S b/modules/sha_x86/sha1core.S index 01c6c7c18..77128ffa1 100644 --- a/modules/sha_x86/sha1core.S +++ b/modules/sha_x86/sha1core.S @@ -20,8 +20,7 @@ FUNCTION(sha160_core) ZEROIZE(ESI) - ALIGN -.LOAD_INPUT_LOOP: +START_LOOP(.LOAD_INPUT) ADD(IMM(4), ESI) MOV(ARRAY(EBP, 0), EAX) @@ -40,52 +39,47 @@ FUNCTION(sha160_core) movl EBX, -12(EDI,ESI,4) movl ECX, -8(EDI,ESI,4) movl EDX, -4(EDI,ESI,4) - - LOOP_UNTIL(ESI, IMM(16), .LOAD_INPUT_LOOP) +LOOP_UNTIL(ESI, IMM(16), .LOAD_INPUT) leal 64(EDI), EBP - ALIGN -.EXPANSION_LOOP: +START_LOOP(.EXPANSION) ADD(IMM(4), ESI) ZEROIZE(EAX) - - movl -4(EBP), EBX - movl -8(EBP), ECX - movl -12(EBP), EDX - - xorl -20(EBP), EAX - xorl -24(EBP), EBX - xorl -28(EBP), ECX - xorl -32(EBP), EDX - - xorl -44(EBP), EAX - xorl -48(EBP), EBX - xorl -52(EBP), ECX - xorl -56(EBP), EDX - - xorl -52(EBP), EAX - xorl -56(EBP), EBX - xorl -60(EBP), ECX - xorl -64(EBP), EDX - - roll $1, EDX - - roll $1, ECX - movl EDX, (EBP) - - roll $1, EBX - movl ECX, 4(EBP) - - xorl EDX, EAX - movl EBX, 8(EBP) - roll $1, EAX - movl EAX, 12(EBP) - - addl $16, EBP - cmpl $80, ESI - LOOP_UNTIL(ESI, IMM(80), .EXPANSION_LOOP) + + MOV(ARRAY(EBP, -1), EBX) + MOV(ARRAY(EBP, -2), ECX) + MOV(ARRAY(EBP, -3), EDX) + + XOR(ARRAY(EBP, -5), EAX) + XOR(ARRAY(EBP, -6), EBX) + XOR(ARRAY(EBP, -7), ECX) + XOR(ARRAY(EBP, -8), EDX) + + XOR(ARRAY(EBP, -11), EAX) + XOR(ARRAY(EBP, -12), EBX) + XOR(ARRAY(EBP, -13), ECX) + XOR(ARRAY(EBP, -14), EDX) + + XOR(ARRAY(EBP, -13), EAX) + XOR(ARRAY(EBP, -14), EBX) + XOR(ARRAY(EBP, -15), ECX) + XOR(ARRAY(EBP, -16), EDX) + + ROTL(IMM(1), EDX) + ROTL(IMM(1), ECX) + ROTL(IMM(1), EBX) + XOR(EDX, EAX) + ROTL(IMM(1), EAX) + + MOV(EDX, ARRAY(EBP, 0)) + MOV(ECX, ARRAY(EBP, 1)) + MOV(EBX, ARRAY(EBP, 2)) + MOV(EAX, ARRAY(EBP, 3)) + + ADD(IMM(16), EBP) +LOOP_UNTIL(ESI, IMM(80), .EXPANSION) movl 20(%esp), EBP movl 0(EBP), EAX |