diff options
author | lloyd <[email protected]> | 2006-08-13 08:47:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-08-13 08:47:33 +0000 |
commit | 91da72f10e640b7324cf9868ebc7e4ba83d820ee (patch) | |
tree | 99eeb892d3d8a0979dd372d1c5684e1cacb2b411 /modules/sha_x86 | |
parent | 142d02d458a5660e2d60af715b997faaf8ed4fb6 (diff) |
Introduce some new macros to improve the readability of the code
Diffstat (limited to 'modules/sha_x86')
-rw-r--r-- | modules/sha_x86/asm_macr.h | 4 | ||||
-rw-r--r-- | modules/sha_x86/sha1core.S | 42 |
2 files changed, 24 insertions, 22 deletions
diff --git a/modules/sha_x86/asm_macr.h b/modules/sha_x86/asm_macr.h index 9f91eecfb..162e7e7a7 100644 --- a/modules/sha_x86/asm_macr.h +++ b/modules/sha_x86/asm_macr.h @@ -39,11 +39,13 @@ func_name: #define PUSH(REG) pushl REG #define POP(REG) popl REG #define MOV(FROM, TO) movl FROM, TO - +#define ASSIGN(TO, FROM) movl FROM, TO #define ADD(FROM, TO) addl FROM, TO #define ADD2(FROM, NUM, TO) leal NUM(FROM), TO +#define ADD_IMM(REG, NUM) addl IMM(NUM), REG + #define XOR(FROM, TO) xorl FROM, TO #define AND(FROM, TO) andl FROM, TO #define OR(FROM, TO) orl FROM, TO diff --git a/modules/sha_x86/sha1core.S b/modules/sha_x86/sha1core.S index 37e16b5d7..cbc8fdb1a 100644 --- a/modules/sha_x86/sha1core.S +++ b/modules/sha_x86/sha1core.S @@ -15,18 +15,18 @@ FUNCTION(sha160_core) #define PUSHED 4 - MOV(ARG(2), EBP) - MOV(ARG(3), EDI) + ASSIGN(EBP, ARG(2)) + ASSIGN(EDI, ARG(3)) ZEROIZE(ESI) START_LOOP(.LOAD_INPUT) - ADD(IMM(4), ESI) + ADD_IMM(ESI, 4) - MOV(ARRAY(EBP, 0), EAX) - MOV(ARRAY(EBP, 1), EBX) - MOV(ARRAY(EBP, 2), ECX) - MOV(ARRAY(EBP, 3), EDX) + ASSIGN(EAX, ARRAY(EBP, 0)) + ASSIGN(EBX, ARRAY(EBP, 1)) + ASSIGN(ECX, ARRAY(EBP, 2)) + ASSIGN(EDX, ARRAY(EBP, 3)) ADD(IMM(16), EBP) @@ -48,9 +48,9 @@ START_LOOP(.EXPANSION) ZEROIZE(EAX) - MOV(ARRAY(EBP, -1), EBX) - MOV(ARRAY(EBP, -2), ECX) - MOV(ARRAY(EBP, -3), EDX) + ASSIGN(EBX, ARRAY(EBP, -1)) + ASSIGN(ECX, ARRAY(EBP, -2)) + ASSIGN(EDX, ARRAY(EBP, -3)) XOR(ARRAY(EBP, -5), EAX) XOR(ARRAY(EBP, -6), EBX) @@ -73,20 +73,20 @@ START_LOOP(.EXPANSION) 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)) + ASSIGN(ARRAY(EBP, 0), EDX) + ASSIGN(ARRAY(EBP, 1), ECX) + ASSIGN(ARRAY(EBP, 2), EBX) + ASSIGN(ARRAY(EBP, 3), EAX) ADD(IMM(16), EBP) LOOP_UNTIL(ESI, IMM(80), .EXPANSION) - MOV(ARG(1), EBP) - MOV(ARRAY(EBP, 0), EAX) - MOV(ARRAY(EBP, 1), EBX) - MOV(ARRAY(EBP, 2), ECX) - MOV(ARRAY(EBP, 3), EDX) - MOV(ARRAY(EBP, 4), ESI) + ASSIGN(EBP, ARG(1)) + ASSIGN(EAX, ARRAY(EBP, 0)) + ASSIGN(EBX, ARRAY(EBP, 1)) + ASSIGN(ECX, ARRAY(EBP, 2)) + ASSIGN(EDX, ARRAY(EBP, 3)) + ASSIGN(ESI, ARRAY(EBP, 4)) #define MAGIC1 0x5A827999 #define MAGIC2 0x6ED9EBA1 @@ -163,7 +163,7 @@ LOOP_UNTIL(ESI, IMM(80), .EXPANSION) F_BLOCK(F4, 70) F_BLOCK(F4, 75) - MOV(ARG(1), EBP) + ASSIGN(EBP, ARG(1)) ADD(EAX, ARRAY(EBP, 0)) ADD(EBX, ARRAY(EBP, 1)) ADD(ECX, ARRAY(EBP, 2)) |