-
Notifications
You must be signed in to change notification settings - Fork 0
/
consoleio.s
119 lines (119 loc) · 1.99 KB
/
consoleio.s
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
.file "consoleio.c"
.intel_syntax noprefix
.text
.section .rodata
.LC0:
.string "Enter n: "
.LC1:
.string "%d"
.LC2:
.string "n must be in range [1, %d]\n"
.text
.globl read_array_from_console
.type read_array_from_console, @function
read_array_from_console:
endbr64
push rbp
mov rbp, rsp
sub rsp, 32
mov QWORD PTR -24[rbp], rdi
mov DWORD PTR -28[rbp], esi
.L4:
lea rdi, .LC0[rip]
mov eax, 0
call printf@PLT
lea rax, -8[rbp]
mov rsi, rax
lea rdi, .LC1[rip]
mov eax, 0
call __isoc99_scanf@PLT
mov eax, DWORD PTR -8[rbp]
test eax, eax
jle .L2
mov eax, DWORD PTR -8[rbp]
cmp DWORD PTR -28[rbp], eax
jge .L3
.L2:
mov eax, DWORD PTR -28[rbp]
mov esi, eax
lea rdi, .LC2[rip]
mov eax, 0
call printf@PLT
jmp .L4
.L3:
mov DWORD PTR -4[rbp], 0
jmp .L5
.L6:
mov eax, DWORD PTR -4[rbp]
cdqe
lea rdx, 0[0+rax*4]
mov rax, QWORD PTR -24[rbp]
add rax, rdx
mov rsi, rax
lea rdi, .LC1[rip]
mov eax, 0
call __isoc99_scanf@PLT
add DWORD PTR -4[rbp], 1
.L5:
mov eax, DWORD PTR -8[rbp]
cmp DWORD PTR -4[rbp], eax
jl .L6
mov eax, DWORD PTR -8[rbp]
leave
ret
.size read_array_from_console, .-read_array_from_console
.section .rodata
.LC3:
.string "%d "
.text
.globl print_array
.type print_array, @function
print_array:
endbr64
push rbp
mov rbp, rsp
sub rsp, 32
mov QWORD PTR -24[rbp], rdi
mov DWORD PTR -28[rbp], esi
mov DWORD PTR -4[rbp], 0
jmp .L9
.L10:
mov eax, DWORD PTR -4[rbp]
cdqe
lea rdx, 0[0+rax*4]
mov rax, QWORD PTR -24[rbp]
add rax, rdx
mov eax, DWORD PTR [rax]
mov esi, eax
lea rdi, .LC3[rip]
mov eax, 0
call printf@PLT
add DWORD PTR -4[rbp], 1
.L9:
mov eax, DWORD PTR -4[rbp]
cmp eax, DWORD PTR -28[rbp]
jl .L10
mov edi, 10
call putchar@PLT
nop
leave
ret
.size print_array, .-print_array
.ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4: