-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditionaljumptest.asm
More file actions
177 lines (154 loc) · 2.3 KB
/
Copy pathconditionaljumptest.asm
File metadata and controls
177 lines (154 loc) · 2.3 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
section .data
msg_equal db "JE/JZ worked", 10, 0
msg_notequal db "JNE/JNZ worked", 10, 0
msg_greater db "JG/JNLE worked", 10, 0
msg_ge db "JGE/JNL worked", 10, 0
msg_less db "JL/JNGE worked", 10, 0
msg_le db "JLE/JNG worked", 10, 0
msg_ja db "JA/JNBE worked", 10, 0
msg_jae db "JAE/JNB worked", 10, 0
msg_jb db "JB/JNAE worked", 10, 0
msg_jbe db "JBE/JNA worked", 10, 0
msg_jo db "JO worked", 10, 0
msg_jno db "JNO worked", 10, 0
msg_js db "JS worked", 10, 0
msg_jns db "JNS worked", 10, 0
msg_jp db "JP/JPE worked", 10, 0
msg_jnp db "JNP/JPO worked", 10, 0
section .text
_start:
; -------- ZF test --------
mov rax, 5
mov rbx, 5
cmp rax, rbx
je je_label
jne jne_label
je_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_equal
mov rdx, 14
syscall
jne_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_notequal
mov rdx, 17
syscall
; -------- Signed comparison test --------
mov rax, 10
mov rbx, 5
cmp rax, rbx
jg jg_label
jge jge_label
jl jl_label
jle jle_label
jg_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_greater
mov rdx, 16
syscall
jge_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_ge
mov rdx, 15
syscall
jl_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_less
mov rdx, 15
syscall
jle_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_le
mov rdx, 15
syscall
; -------- Unsigned comparison test --------
mov rax, 5
mov rbx, 10
cmp rax, rbx
ja ja_label
jae jae_label
jb jb_label
jbe jbe_label
ja_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_ja
mov rdx, 15
syscall
jae_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jae
mov rdx, 16
syscall
jb_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jb
mov rdx, 15
syscall
jbe_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jbe
mov rdx, 16
syscall
; -------- Overflow test --------
mov rax, 127
add rax, 1
jo jo_label
jno jno_label
jo_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jo
mov rdx, 11
syscall
jno_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jno
mov rdx, 12
syscall
; -------- Sign test --------
mov rax, -5
js js_label
jns jns_label
js_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_js
mov rdx, 10
syscall
jns_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jns
mov rdx, 11
syscall
; -------- Parity test --------
mov al, 0b00001111
jp jp_label
jnp jnp_label
jp_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jp
mov rdx, 16
syscall
jnp_label:
mov rax, 1
mov rdi, 1
lea rsi, msg_jnp
mov rdx, 17
syscall
; -------- Exit --------
mov rax, 60
mov rdi, 0
syscall