1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# main.S
.section .text
.globl _start
_start:
mov $0, %rax # total count
mov $0, %r8 # 1-BHT
mov $0, %r9 # 1-BHT success count
mov $0, %r10 # 2-BHT
mov $0, %r11 # 2-BHT success count
mov $0, %r13 # zero
mov $1, %r14 # one
mov $3, %r15 # three
loop_1_start:
mov $10, %rbx
loop_1:
inc %rax
test %rbx, %rbx
je loop_1_end # branch 1
dec %rbx
loop_2_start:
mov $10, %rcx
# no branch 1 (1-BHT)
mov $0, %r12
test %r8, %r8
cmove %r14, %r12
add %r12, %r9
mov $0, %r8
# no branch 1 (2-BHT)
mov $0, %r12
cmp $2, %r10
cmovb %r14, %r12
add %r12, %r11
dec %r10
cmp $0, %r10
cmovl %r13, %r10
loop_2:
inc %rax
test %rcx, %rcx
je loop_2_end # branch 2
dec %rcx
loop_3_start:
mov $10, %rdx
# no branch 2 (1-BHT)
mov $0, %r12
test %r8, %r8
cmove %r14, %r12
add %r12, %r9
mov $0, %r8
# no branch 2 (2-BHT)
mov $0, %r12
cmp $2, %r10
cmovb %r14, %r12
add %r12, %r11
dec %r10
cmp $0, %r10
cmovl %r13, %r10
loop_3:
inc %rax
test %rdx, %rdx
je loop_3_end # branch 3
# no branch 3 (1-BHT)
mov $0, %r12
test %r8, %r8
cmove %r14, %r12
add %r12, %r9
mov $0, %r8
# no branch 3 (2-BHT)
mov $0, %r12
cmp $2, %r10
cmovb %r14, %r12
add %r12, %r11
dec %r10
cmp $0, %r10
cmovl %r13, %r10
dec %rdx
jmp loop_3
loop_3_end:
# branch 3 (1-BHT)
mov $0, %r12
test %r8, %r8
cmovne %r14, %r12
add %r12, %r9
mov $1, %r8
# branch 3 (2-BHT)
mov $0, %r12
cmp $1, %r10
cmova %r14, %r12
add %r12, %r11
inc %r10
cmp $3, %r10
cmovg %r15, %r10
jmp loop_2
loop_2_end:
# branch 2 (1-BHT)
mov $0, %r12
test %r8, %r8
cmovne %r14, %r12
add %r12, %r9
mov $1, %r8
# branch 2 (2-BHT)
mov $0, %r12
cmp $1, %r10
cmova %r14, %r12
add %r12, %r11
inc %r10
cmp $3, %r10
cmovg %r15, %r10
jmp loop_1
loop_1_end:
# branch 1 (1-BHT)
mov $0, %r12
test %r8, %r8
cmovne %r14, %r12
add %r12, %r9
mov $1, %r8
# branch 1 (2-BHT)
mov $0, %r12
cmp $1, %r10
cmova %r14, %r12
add %r12, %r11
inc %r10
cmp $3, %r10
cmovg %r15, %r10
real_end:
jmp real_end
|