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
|
edit_point:
addl $1, (%rdi)
addl $1, 4(%rdi)
movl $0, %eax
ret
change_point:
pushq %r12
pushq %rbp
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi # 此时%rdi为0x7fffffffe040,这条指令把0x7fffffffe040内存位置中的值(0x555555756260)复制到%rdi
movl (%rdi), %r12d # 0x7fffffffe040中存储的是0x555555756260,这才是Point所在的内存地址,把point->x复制给%r12
movl 4(%rdi), %ebp # 把 point->y 复制给%ebp
call free@PLT
movl $8, %esi
movq (%rbx), %rdi
call realloc@PLT
movq %rax, (%rbx)
testq %rax, %rax
je .L4
leal (%r12,%r12,4), %ecx
leal (%rcx,%rcx), %edx
movl %edx, (%rax)
movq (%rbx), %rcx
leal 0(%rbp,%rbp,4), %edx
leal (%rdx,%rdx), %eax
movl %eax, 4(%rcx)
movl $0, %eax
.L2:
popq %rbx
popq %rbp
popq %r12
ret
.L4:
movl $-1, %eax
jmp .L2
main:
subq $24, %rsp
movq %fs:40, %rax
movq %rax, 8(%rsp)
xorl %eax, %eax
movl $8, %edi
call malloc@PLT
movq %rax, (%rsp)
movl $1, (%rax)
movl $2, 4(%rax)
movq %rax, %rdi
call show_point
movq (%rsp), %rdi
call edit_point
movq (%rsp), %rdi
call show_point
movq %rsp, %rdi # %rps中保存的是二级指针的内存地址(0x7fffffffe040)
call change_point
movq (%rsp), %rdi
call show_point
movq 8(%rsp), %rdx
xorq %fs:40, %rdx
jne .L11
movl $0, %eax
addq $24, %rsp
ret
|