-
Notifications
You must be signed in to change notification settings - Fork 0
/
threadf.asm
115 lines (77 loc) · 1 KB
/
threadf.asm
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
BITS 64
DEFAULT REL
global temp_var
section .tdata write tls
temp_var db 0
section .text
;without temp variable
global TestFnAsm1
TestFnAsm1:
xor rcx,rcx
.label_1:
mov al,[rdi+rcx]
inc al
mov [rdi+rcx],al
inc rcx
cmp rcx,rsi
jl .label_1
xor rax,rax
ret
;with TLS (thread-local storage)
global TestFnAsm2
TestFnAsm2:
push rbx
xor rcx,rcx
.label_1:
mov r8,[rel temp_var wrt ..gottpoff]
mov al,[rdi+rcx]
mov [fs:r8],al
mov bl,[fs:r8]
inc bl
mov [fs:r8],bl
mov al,[fs:r8]
mov [rdi+rcx],al
inc rcx
cmp rcx,rsi
jl .label_1
pop rbx
xor rax,rax
ret
;with temporary variable from C
global TestFnAsm3
TestFnAsm3:
push rbx
xor rcx,rcx
.label_1:
mov al,[rdi+rcx]
mov [rdx],al
mov bl,[rdx]
inc bl
mov [rdx],bl
mov al,[rdx]
mov [rdi+rcx],al
inc rcx
cmp rcx,rsi
jl .label_1
pop rbx
xor rax,rax
ret
;with stack
global TestFnAsm4
TestFnAsm4:
push rbx
xor rcx,rcx
.label_1:
mov al,[rdi+rcx]
push rax
pop rbx
inc bl
push rbx
pop rax
mov [rdi+rcx],al
inc rcx
cmp rcx,rsi
jl .label_1
pop rbx
xor rax,rax
ret