forked from mizabrik/acos-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasm-example.s
More file actions
53 lines (52 loc) · 862 Bytes
/
asm-example.s
File metadata and controls
53 lines (52 loc) · 862 Bytes
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
.section .rodata
.LC0:
.string "result = %d\n"
.text
.globl func
func:
.LFB0:
pushq %rbp
movq %rsp, %rbp
subq $64, %rsp
movq %rdi, -24(%rbp)
movq %rsi, -32(%rbp)
movq %rdx, -40(%rbp)
movq %rcx, -48(%rbp)
movq %r8, -56(%rbp)
movq %r9, -64(%rbp)
movq -24(%rbp), %rax
movl %eax, %edx
movq -32(%rbp), %rax
addl %eax, %edx
movq -40(%rbp), %rax
addl %eax, %edx
movq -48(%rbp), %rax
addl %eax, %edx
movq -56(%rbp), %rax
addl %eax, %edx
movq -64(%rbp), %rax
addl %edx, %eax
movl %eax, -4(%rbp)
movl -4(%rbp), %eax
movl %eax, %esi
movl $.LC0, %edi
movl $0, %eax
call printf
movl $10, %eax
leave
ret
.globl main
main:
.LFB1:
pushq %rbp
movq %rsp, %rbp
movl $6, %r9d
movl $5, %r8d
movl $4, %ecx
movl $3, %edx
movl $2, %esi
movl $1, %edi
call func
movl $0, %eax
popq %rbp
ret