Botan
1.10.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
utils
asm_x86_64
asm_x86_64.h
Go to the documentation of this file.
1
/*
2
* Assembly Macros for 64-bit x86
3
* (C) 1999-2008 Jack Lloyd
4
*
5
* Distributed under the terms of the Botan license
6
*/
7
8
#ifndef BOTAN_ASM_MACROS_X86_64_H__
9
#define BOTAN_ASM_MACROS_X86_64_H__
10
11
/*
12
* General/Global Macros
13
*/
14
#define ALIGN .p2align 4,,15
15
16
#define START_LISTING(FILENAME) \
17
.file #FILENAME; \
18
.text; \
19
ALIGN;
20
21
#if defined(__ELF__)
22
.section .note.GNU-stack,
""
,%progbits
23
#endif
24
25
/*
26
* Function Definitions
27
*/
28
#define START_FUNCTION(func_name) \
29
ALIGN; \
30
.global func_name; \
31
.type func_name,@function; \
32
func_name:
33
34
#define END_FUNCTION(func_name) \
35
ret
36
37
/*
38
* Conditional Jumps
39
*/
40
#define JUMP_IF_ZERO(REG, LABEL) \
41
cmp IMM(0), REG; \
42
jz LABEL
43
44
#define JUMP_IF_LT(REG, NUM, LABEL) \
45
cmp IMM(NUM), REG; \
46
jl LABEL
47
48
/*
49
* Register Names
50
*/
51
#define R0 %rax
52
#define R1 %rbx
53
#define R2 %rcx
54
#define R2_32 %ecx
55
#define R3 %rdx
56
#define R3_32 %edx
57
#define R4 %rsp
58
#define R5 %rbp
59
#define R6 %rsi
60
#define R6_32 %esi
61
#define R7 %rdi
62
#define R8 %r8
63
#define R9 %r9
64
#define R9_32 %r9d
65
#define R10 %r10
66
#define R11 %r11
67
#define R12 %r12
68
#define R13 %r13
69
#define R14 %r14
70
#define R15 %r15
71
#define R16 %r16
72
73
#define ARG_1 R7
74
#define ARG_2 R6
75
#define ARG_2_32 R6_32
76
#define ARG_3 R3
77
#define ARG_3_32 R3_32
78
#define ARG_4 R2
79
#define ARG_4_32 R2_32
80
#define ARG_5 R8
81
#define ARG_6 R9
82
#define ARG_6_32 R9_32
83
84
#define TEMP_1 R10
85
#define TEMP_2 R11
86
#define TEMP_3 ARG_6
87
#define TEMP_4 ARG_5
88
#define TEMP_5 ARG_4
89
#define TEMP_5_32 ARG_4_32
90
#define TEMP_6 ARG_3
91
#define TEMP_7 ARG_2
92
#define TEMP_8 ARG_1
93
#define TEMP_9 R0
94
95
/*
96
* Memory Access Operations
97
*/
98
#define ARRAY8(REG, NUM) 8*(NUM)(REG)
99
#define ARRAY4(REG, NUM) 4*(NUM)(REG)
100
101
#define ASSIGN(TO, FROM) mov FROM, TO
102
103
/*
104
* ALU Operations
105
*/
106
#define IMM(VAL) $VAL
107
108
#define ADD(TO, FROM) add FROM, TO
109
#define ADD_LAST_CARRY(REG) adc IMM(0), REG
110
#define ADD_IMM(TO, NUM) ADD(TO, IMM(NUM))
111
#define ADD_W_CARRY(TO1, TO2, FROM) add FROM, TO1; adc IMM(0), TO2;
112
#define SUB_IMM(TO, NUM) sub IMM(NUM), TO
113
#define MUL(REG) mul REG
114
115
#define XOR(TO, FROM) xor FROM, TO
116
#define AND(TO, FROM) and FROM, TO
117
#define OR(TO, FROM) or FROM, TO
118
#define NOT(REG) not REG
119
#define ZEROIZE(REG) XOR(REG, REG)
120
121
#define RETURN_VALUE_IS(V) ASSIGN(%rax, V)
122
123
#define ROTL_IMM(REG, NUM) rol IMM(NUM), REG
124
#define ROTR_IMM(REG, NUM) ror IMM(NUM), REG
125
#define ADD3_IMM(TO, FROM, NUM) lea NUM(TO,FROM,1), TO
126
127
#endif
Generated on Sat Aug 20 2016 08:18:49 for Botan by
1.8.9.1