-
Notifications
You must be signed in to change notification settings - Fork 0
/
ans.S
113 lines (113 loc) · 1.6 KB
/
ans.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
.file "test6.c"
.text
.globl func1
.type func1, @function
func1:
endbr32
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $1, -4(%ebp)
movl -4(%ebp), %eax
leave
ret
.globl func2
.type func2, @function
func2:
endbr32
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $2, -4(%ebp)
movl -4(%ebp), %eax
leave
ret
.globl func3
.type func3, @function
func3:
endbr32
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $4, -4(%ebp)
movl -4(%ebp), %eax
leave
ret
.globl func4
.type func4, @function
func4:
endbr32
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $8, -12(%ebp)
movl -12(%ebp), %eax
movl %eax, -8(%ebp)
movl $16, -4(%ebp)
movl -4(%ebp), %eax
addl %eax, -8(%ebp)
movl -8(%ebp), %eax
leave
ret
.section .rodata
.LC0:
.string "%d\n"
.text
.globl main
.type main, @function
main:
endbr32
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ebx
pushl %ecx
subl $16, %esp
movl $32, -20(%ebp)
movl $32, -16(%ebp)
movl $32, -12(%ebp)
call func1
movl %eax, %ebx
call func2
addl %eax, %ebx
call func3
addl %eax, %ebx
call func4
leal (%ebx,%eax), %edx
movl -20(%ebp), %eax
addl %eax, %edx
movl -16(%ebp), %eax
addl %eax, %edx
movl -12(%ebp), %eax
addl %edx, %eax
subl $8, %esp
pushl %eax
pushl $.LC0
call printf
addl $16, %esp
movl $0, %eax
leal -8(%ebp), %esp
popl %ecx
popl %ebx
popl %ebp
leal -4(%ecx), %esp
ret
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 4
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 4
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 4
4: