forked from sonictk/asm_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello_if_else.asm
62 lines (50 loc) · 822 Bytes
/
hello_if_else.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
default rel
bits 64
segment .data
a: dq 5
b: dq 2
c: dq 3
segment .bss
max resq 1
result resq 1
segment .text
global main
extern ExitProcess
main:
; if (a < b) {
; max = b
; } else {
; max = a
; }
mov rax, [a]
mov rbx, [b]
cmp rax, rbx
jnl else
mov [max], rbx
jmp endif
;if (a < b) {
; result = 1
;} else if (a > c) {
; result = 2
;} else {
; result = 3
;}
mov rax, [a]
mov rbx, [b]
cmp rax, rbx
jnl elseif
mov qword [result], 1
jmp endif
else:
mov [max], rax
elseif:
mov rcx, [c]
cmp rax, rcx
jng else2
mov qword [result], 2
jmp endif
else2:
mov qword [result], 3
endif:
xor eax, eax
call ExitProcess