-
Notifications
You must be signed in to change notification settings - Fork 0
/
untitled.s
54 lines (46 loc) · 1.06 KB
/
untitled.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
/*
int nums[] = {10, -21, -30, 45};
int main() {
int i, *p;
for (i = 0, p = nums; i != 4; i++, p++)
printf("%d\n", *p);
return 0;
}
*/
.data
nums: .int 10, -21, -30, 45
Sf: .string "%d\n" # string de formato para printf
.text
.globl main
main:
/****** nao mexa - prologo !!!! */
push %ebp
movl %esp, %ebp
pushl %ebx /* salva ebx */
/*******/
movl $0, %ebx /* ebx = 0; */
movl $nums, %ecx /* ecx = &nums; */
L1: cmpl $4, %ebx /* if (ebx == 4) ? */
je L2 /* goto L2 */
movl (%ecx), %eax /* eax = *ecx; */
/****** nao mexa - imprime o valor de %eax !!!! */
/* pode estragar o valor de %eax ******/
pushl %ecx
pushl %edx
pushl %eax
pushl $Sf
call printf
addl $8, %esp
popl %edx
popl %ecx
/*******/
addl $1, %ebx /* ebx += 1; */
addl $4, %ecx /* ecx += 4; */
jmp L1 /* goto L1; */
L2: movl $0, %eax /* eax = 0; (valor de retorno) */
/****** nao mexa - finalizacao!!!! */
popl %ebx
movl %ebp, %esp
popl %ebp
ret
/*******/