|
1 |
| - .file "22.cpp" |
2 | 1 | .text
|
3 |
| - .globl _Z8sumstorellPl |
4 |
| - .type _Z8sumstorellPl, @function |
5 |
| -_Z8sumstorellPl: |
| 2 | + .globl add_sum |
| 3 | + .type add_sum, @function |
| 4 | +add_sum: |
6 | 5 | .LFB0:
|
7 |
| - .cfi_startproc |
8 |
| - endbr64 |
9 |
| - pushq %rbp |
| 6 | + .cfi_startproc #program start |
| 7 | + #endbr64 #TERMINATE BRANCH 64bit |
| 8 | + pushq %rbp #stack pointer |
| 9 | + |
| 10 | + |
| 11 | +#+----------------+ |
| 12 | +#|stack pointer rbp| |
| 13 | +#+----------------+ |
| 14 | + |
10 | 15 | .cfi_def_cfa_offset 16
|
11 | 16 | .cfi_offset 6, -16
|
12 |
| - movq %rsp, %rbp |
13 |
| - .cfi_def_cfa_register 6 |
14 |
| - movq %rdi, -24(%rbp) |
15 |
| - movq %rsi, -32(%rbp) |
16 |
| - movq %rdx, -40(%rbp) |
17 |
| - movq -24(%rbp), %rdx |
18 |
| - movq -32(%rbp), %rax |
19 |
| - addq %rdx, %rax |
20 |
| - movq %rax, -8(%rbp) |
21 |
| - movq -40(%rbp), %rax |
22 |
| - movq -8(%rbp), %rdx |
23 |
| - movq %rdx, (%rax) |
| 17 | + |
| 18 | + |
| 19 | +#8:64bits |
| 20 | +#: : |
| 21 | +#| whatever | <--- CFA |
| 22 | +#+----------------+ |
| 23 | +#| return address | <--- %rsp == CFA - 8 |
| 24 | +#+----------------+ |
| 25 | + |
| 26 | + |
| 27 | +#: : |
| 28 | +#| whatever | <--- CFA |
| 29 | +#+----------------+ |
| 30 | +#| return address |<- when c call asm, push address |
| 31 | +#+----------------+ |
| 32 | +#| reserved space | <--- %rsp == CFA - 16 ,call site |
| 33 | +#+----------------+ |
| 34 | + |
| 35 | + |
| 36 | + movq %rsp, %rbp |
| 37 | +#rbp is the base pointer, which points to the base of the current stack frame, and rsp is the stack pointer, which points to the top of the current stack frame. |
| 38 | + .cfi_def_cfa_register 6 #cfa register is rbp |
| 39 | + movq %rdi, -24(%rbp) #arg0 *(rbp-24) = rdi; |
| 40 | + movq %rsi, -32(%rbp) #arg1 *(rbp-32) = rsi; |
| 41 | + movq %rdx, -40(%rbp) #arg2 |
| 42 | + movq -24(%rbp), %rdx #rdx =arg0 |
| 43 | + movq -32(%rbp), %rax #rax = arg1 |
| 44 | + addq %rdx, %rax #add arg0,arg1 to rax |
| 45 | + movq %rax, -8(%rbp) #*(rbp-8) = rax |
| 46 | + movq -40(%rbp), %rax #rax = arg2 |
| 47 | + movq -8(%rbp), %rdx #rdx = *(rbp-8) |
| 48 | + movq %rdx, (%rax) #*rax=rdx |
24 | 49 | nop
|
25 | 50 | popq %rbp
|
26 | 51 | .cfi_def_cfa 7, 8
|
27 | 52 | ret
|
28 |
| - .cfi_endproc |
29 |
| -.LFE0: |
30 |
| - .size _Z8sumstorellPl, .-_Z8sumstorellPl |
31 |
| - .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" |
32 |
| - .section .note.GNU-stack,"",@progbits |
33 |
| - .section .note.gnu.property,"a" |
34 |
| - .align 8 |
35 |
| - .long 1f - 0f |
36 |
| - .long 4f - 1f |
37 |
| - .long 5 |
38 |
| -0: |
39 |
| - .string "GNU" |
40 |
| -1: |
41 |
| - .align 8 |
42 |
| - .long 0xc0000002 |
43 |
| - .long 3f - 2f |
44 |
| -2: |
45 |
| - .long 0x3 |
46 |
| -3: |
47 |
| - .align 8 |
48 |
| -4: |
| 53 | + .cfi_endproc # program end |
| 54 | +#.LFE0: |
| 55 | +#.data_tag: |
| 56 | +# .size add_sum, .-add_sum |
| 57 | +# .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" |
| 58 | +# .section .note.GNU-stack,"",@progbits |
| 59 | +# .section .note.gnu.property,"a" |
| 60 | +# .align 8 |
| 61 | +# .long 1f - 0f |
| 62 | +# .long 4f - 1f |
| 63 | +# .long 5 |
| 64 | +#0: |
| 65 | +# .string "GNU" |
| 66 | +#1: |
| 67 | +# .align 8 |
| 68 | +# .long 0xc0000002 |
| 69 | +# .long 3f - 2f |
| 70 | +#2: |
| 71 | +# .long 0x3 |
| 72 | +#3: |
| 73 | +# .align 8 |
| 74 | +#4: |
0 commit comments