-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.asm
More file actions
78 lines (77 loc) · 1.16 KB
/
Copy pathprogram.asm
File metadata and controls
78 lines (77 loc) · 1.16 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
section .data
print_fmt: db "%d", 10, 0
scan_fmt: db "%d", 0
t4: dd 0
t5: dd 0
t6: dd 0
t7: dd 0
t8: dd 0
t9: dd 0
t10: dd 0
t12: dd 0
t11: dd 0
x: dd 0
t1: dd 0
t2: dd 0
t3: dd 0
section .text
global main
extern printf, scanf
main:
; READ x
lea rdi, [rel scan_fmt]
lea rsi, [x]
xor eax, eax
call scanf
mov dword [t1], 3
mov dword [t2], 5
mov dword [t3], 2
mov dword [t4], 1
mov dword [t5], 1
mov dword [t6], 5
mov dword [t7], 8
; unhandled: x = t7
; PRINT x
lea rdi, [rel print_fmt]
mov esi, [x]
xor eax, eax
call printf
; IFZ x GOTO L1
mov eax, [x]
cmp eax, 0
je L1
mov dword [t8], 1
; unhandled: t9 = x - t8
; unhandled: x = t9
; PRINT x
lea rdi, [rel print_fmt]
mov esi, [x]
xor eax, eax
call printf
jmp L2
L1:
mov dword [t10], 10
; unhandled: x = t10
; PRINT x
lea rdi, [rel print_fmt]
mov esi, [x]
xor eax, eax
call printf
L2:
L3:
; IFZ x GOTO L4
mov eax, [x]
cmp eax, 0
je L4
; PRINT x
lea rdi, [rel print_fmt]
mov esi, [x]
xor eax, eax
call printf
mov dword [t11], 1
; unhandled: t12 = x - t11
; unhandled: x = t12
jmp L3
L4:
mov eax, 0
ret