diff options
author | lloyd <[email protected]> | 2006-09-24 14:34:51 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-09-24 14:34:51 +0000 |
commit | 877f1a962e2b4b57dbef914eda3ef9b40a771b55 (patch) | |
tree | d485327d4dd499a07f150db7dc2f55af16d9fe6f /modules/alg_amd64/asm_macr.h | |
parent | 623917ff27073b3471b7e2fc200d4f2e9217fd86 (diff) |
Initial x86-64 assembly code for the inner multiply-add loop.
Diffstat (limited to 'modules/alg_amd64/asm_macr.h')
-rw-r--r-- | modules/alg_amd64/asm_macr.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/modules/alg_amd64/asm_macr.h b/modules/alg_amd64/asm_macr.h new file mode 100644 index 000000000..689bfa3cb --- /dev/null +++ b/modules/alg_amd64/asm_macr.h @@ -0,0 +1,81 @@ +/************************************************* +* Assembly Macros Header File * +* (C) 1999-2006 The Botan Project * +*************************************************/ + +#ifndef BOTAN_EXT_ASM_MACROS_H__ +#define BOTAN_EXT_ASM_MACROS_H__ + +/************************************************* +* General/Global Macros * +*************************************************/ +#define ALIGN .p2align 4,,15 + +#define START_LISTING(FILENAME) \ + .file #FILENAME; \ + .text; \ + ALIGN; + +/************************************************* +* Function Definitions * +*************************************************/ +#define START_FUNCTION(func_name) \ + ALIGN; \ + .global func_name; \ + .type func_name,@function; \ +func_name: + +#define END_FUNCTION(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) \ + cmp IMM(0), REG; \ + jz LABEL + +#define JUMP_IF_LT(REG, NUM, LABEL) \ + cmp IMM(NUM), REG; \ + jl LABEL + +/************************************************* +* Memory Access Operations * +*************************************************/ +#define ARRAY8(REG, NUM) 8*(NUM)(REG) + +#define ASSIGN(TO, FROM) mov FROM, TO + +/************************************************* +* ALU Operations * +*************************************************/ +#define IMM(VAL) $VAL + +#define ADD(TO, FROM) addq FROM, TO +#define ADD_IMM(TO, NUM) ADD(TO, IMM(NUM)) +#define ADD_W_CARRY(TO1, TO2, FROM) addq FROM, TO1; adcq IMM(0), TO2; +#define SUB_IMM(TO, NUM) sub IMM(NUM), TO +#define MUL(REG) mulq REG + +#define XOR(TO, FROM) xorq FROM, TO +#define AND(TO, FROM) andq FROM, TO +#define OR(TO, FROM) orq FROM, TO +#define NOT(REG) notq REG +#define ZEROIZE(REG) XOR(REG, REG) + +#endif |