-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlista.s
359 lines (359 loc) · 5.84 KB
/
lista.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
cria():
movl $0, %eax
ret
vazia(nodo*):
pushq %rbp
movq %rsp, %rbp
movq %rdi, -24(%rbp)
movq -24(%rbp), %rax
movq %rax, -8(%rbp)
.L7:
cmpq $0, -8(%rbp)
je .L4
cmpq $0, -8(%rbp)
je .L5
movl $0, %eax
jmp .L3
.L5:
movq -8(%rbp), %rax
movq 112(%rax), %rax
movq %rax, -8(%rbp)
jmp .L7
.L4:
cmpq $0, -8(%rbp)
jne .L8
movl $1, %eax
jmp .L3
.L8:
.L3:
popq %rbp
ret
.LC0:
.string "clear"
.LC1:
.string "\t___________~<>~___________"
.LC2:
.string "\tC\303\263digo do produto: "
.LC3:
.string "%d"
.LC4:
.string "\tNome: "
.LC5:
.string "\tPre\303\247o: "
.LC6:
.string "%f"
push(nodo*):
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp
movq %rdi, -24(%rbp)
movl $120, %edi
call malloc
movq %rax, -8(%rbp)
movl $.LC0, %edi
call system
movl $.LC1, %edi
call puts
movl $.LC2, %edi
movl $0, %eax
call printf
movq -8(%rbp), %rax
movq %rax, %rsi
movl $.LC3, %edi
movl $0, %eax
call scanf
movl $.LC4, %edi
movl $0, %eax
call printf
call getchar
movq stdin(%rip), %rax
movq -8(%rbp), %rdx
leaq 4(%rdx), %rcx
movq %rax, %rdx
movl $100, %esi
movq %rcx, %rdi
call fgets
movl $.LC5, %edi
movl $0, %eax
call printf
movq -8(%rbp), %rax
addq $104, %rax
movq %rax, %rsi
movl $.LC6, %edi
movl $0, %eax
call scanf
movq -8(%rbp), %rax
movq -24(%rbp), %rdx
movq %rdx, 112(%rax)
movq -8(%rbp), %rax
leave
ret
.LC7:
.string "\t___________~<>~__________"
.LC8:
.string "\tLista vazia."
.LC9:
.string "\tAperte 1 para voltar: "
.LC10:
.string "\t___________________~<>~__________________"
.LC11:
.string "\tC\303\263digo do produto que deseja retirar: "
.LC12:
.string "%i"
.LC13:
.string "\t____________~<>~___________"
.LC14:
.string "\tProduto n\303\243o encontrado"
pop(nodo*):
pushq %rbp
movq %rsp, %rbp
subq $48, %rsp
movq %rdi, -40(%rbp)
movq $0, -16(%rbp)
movq -40(%rbp), %rax
movq %rax, %rdi
call vazia(nodo*)
testl %eax, %eax
setne %al
testb %al, %al
je .L12
movl $.LC0, %edi
call system
movl $.LC7, %edi
call puts
movl $.LC8, %edi
call puts
movl $.LC9, %edi
movl $0, %eax
call printf
leaq -32(%rbp), %rax
movq %rax, %rsi
movl $.LC3, %edi
movl $0, %eax
call scanf
movq -40(%rbp), %rax
jmp .L18
.L12:
movl $.LC0, %edi
call system
movl $.LC10, %edi
call puts
movl $.LC11, %edi
movl $0, %eax
call printf
leaq -28(%rbp), %rax
movq %rax, %rsi
movl $.LC12, %edi
movl $0, %eax
call scanf
movq -40(%rbp), %rax
movq %rax, -8(%rbp)
.L17:
cmpq $0, -8(%rbp)
je .L14
movq -8(%rbp), %rax
movl (%rax), %edx
movl -28(%rbp), %eax
cmpl %eax, %edx
jne .L15
movq -8(%rbp), %rax
movq %rax, -24(%rbp)
cmpq $0, -16(%rbp)
jne .L16
movq -8(%rbp), %rax
movq 112(%rax), %rax
movq %rax, -8(%rbp)
movq -8(%rbp), %rax
jmp .L18
.L16:
movq -24(%rbp), %rax
movq 112(%rax), %rdx
movq -16(%rbp), %rax
movq %rdx, 112(%rax)
movq -40(%rbp), %rax
jmp .L18
.L15:
movq -8(%rbp), %rax
movq %rax, -16(%rbp)
movq -8(%rbp), %rax
movq 112(%rax), %rax
movq %rax, -8(%rbp)
jmp .L17
.L14:
movl $.LC0, %edi
call system
movl $.LC13, %edi
call puts
movl $.LC14, %edi
call puts
movl $.LC9, %edi
movl $0, %eax
call printf
leaq -32(%rbp), %rax
movq %rax, %rsi
movl $.LC3, %edi
movl $0, %eax
call scanf
movq -40(%rbp), %rax
.L18:
leave
ret
.LC15:
.string "\tC\303\263digo do produto: %d\n"
.LC16:
.string "\tNome: %s"
.LC17:
.string "\tPre\303\247o: %.2f"
.LC18:
.string "\n"
display(nodo*):
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp
movq %rdi, -24(%rbp)
movl $.LC0, %edi
call system
movl $.LC7, %edi
call puts
movq -24(%rbp), %rax
movq %rax, -8(%rbp)
.L21:
cmpq $0, -8(%rbp)
je .L20
movq -8(%rbp), %rax
movl (%rax), %eax
movl %eax, %esi
movl $.LC15, %edi
movl $0, %eax
call printf
movq -8(%rbp), %rax
addq $4, %rax
movq %rax, %rsi
movl $.LC16, %edi
movl $0, %eax
call printf
movq -8(%rbp), %rax
movss 104(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movl $.LC17, %edi
movl $1, %eax
call printf
movl $.LC18, %edi
call puts
movq -8(%rbp), %rax
movq 112(%rax), %rax
movq %rax, -8(%rbp)
jmp .L21
.L20:
movq -24(%rbp), %rax
movq %rax, %rdi
call vazia(nodo*)
testl %eax, %eax
setne %al
testb %al, %al
je .L22
movl $.LC0, %edi
call system
movl $.LC7, %edi
call puts
movl $.LC8, %edi
call puts
.L22:
movl $.LC7, %edi
call puts
movl $.LC9, %edi
movl $0, %eax
call printf
leaq -12(%rbp), %rax
movq %rax, %rsi
movl $.LC3, %edi
movl $0, %eax
call scanf
nop
leave
ret
libera(nodo*):
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call free
nop
leave
ret
.LC19:
.string "\t|0| Sair"
.LC20:
.string "\t|1| Inserir produto"
.LC21:
.string "\t|2| Excluir produto"
.LC22:
.string "\t|3| Exibir lista"
.LC23:
.string "\tEscolha sua op\303\247\303\243o: "
main:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
call cria()
movq %rax, -8(%rbp)
.L29:
movl $.LC0, %edi
call system
movl $.LC7, %edi
call puts
movl $.LC19, %edi
call puts
movl $.LC20, %edi
call puts
movl $.LC21, %edi
call puts
movl $.LC22, %edi
call puts
movl $.LC7, %edi
call puts
movl $.LC23, %edi
movl $0, %eax
call printf
leaq -12(%rbp), %rax
movq %rax, %rsi
movl $.LC3, %edi
movl $0, %eax
call scanf
movl -12(%rbp), %eax
cmpl $2, %eax
je .L25
cmpl $3, %eax
je .L26
cmpl $1, %eax
jne .L27
movq -8(%rbp), %rax
movq %rax, %rdi
call push(nodo*)
movq %rax, -8(%rbp)
jmp .L27
.L25:
movq -8(%rbp), %rax
movq %rax, %rdi
call pop(nodo*)
movq %rax, -8(%rbp)
jmp .L27
.L26:
movq -8(%rbp), %rax
movq %rax, %rdi
call display(nodo*)
nop
.L27:
movl -12(%rbp), %eax
testl %eax, %eax
je .L28
jmp .L29
.L28:
movq -8(%rbp), %rax
movq %rax, %rdi
call libera(nodo*)
movl $0, %eax
leave
ret