#include <stdio.h>
#include <stdlib.h>
void test1(float a1, double a2, short a3, int a4,
unsigned int a5, unsigned char a6) {
int b1 = 0;
b1 = a1 + a2;
b1 = a3 + a4 + b1;
b1 = a5 + a6 + b1;
}
void test(int *ptr, int val, unsigned short val1) {
ptr[10] = val + val1;
}
void fn0() {
printf( "first register, last call\n" );
}
void fn1() {
printf( "next.\n" );
}
int main()
{
printf("start run \n");
atexit(fn0);
atexit(fn1);
float a1 = 10.1;
double a2 = 12.54;
short a3 = 0xDCAB;
int a4 = 0xABCDABCD;
unsigned int a5 = 0xADCBADCB;
unsigned char a6 = 0xDE;
test1(a1, a2,a3, a4, a5, a6);
int *null_ptr = NULL;
unsigned int val = 11;
unsigned short val1 = 9;
test(null_ptr, val, val1); //对空指针指向的内存区域写,会发生段错误
printf("this is good \n");
return 0;
}
00000000004005d6 <test1>:
; rsp 0x7fffffffe238, rbp 0x7fffffffe270
4005d6: 55 push %rbp
; rsp 0x7fffffffe230, rbp 0x7fffffffe230
4005d7: 48 89 e5 mov %rsp,%rbp
; rsp 0x7fffffffe230, rbp 0x7fffffffe230
4005da: f3 0f 11 45 ec movss %xmm0,-0x14(%rbp)
4005df: f2 0f 11 4d e0 movsd %xmm1,-0x20(%rbp)
4005e4: 89 f8 mov %edi,%eax
4005e6: 89 75 dc mov %esi,-0x24(%rbp)
4005e9: 89 55 d8 mov %edx,-0x28(%rbp)
4005ec: 89 ca mov %ecx,%edx
4005ee: 66 89 45 e8 mov %ax,-0x18(%rbp)
4005f2: 89 d0 mov %edx,%eax
4005f4: 88 45 d4 mov %al,-0x2c(%rbp)
4005f7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
4005fe: f3 0f 5a 45 ec cvtss2sd -0x14(%rbp),%xmm0
400603: f2 0f 58 45 e0 addsd -0x20(%rbp),%xmm0
400608: f2 0f 2c c0 cvttsd2si %xmm0,%eax
40060c: 89 45 fc mov %eax,-0x4(%rbp)
40060f: 0f bf 55 e8 movswl -0x18(%rbp),%edx
400613: 8b 45 dc mov -0x24(%rbp),%eax
400616: 01 d0 add %edx,%eax
400618: 01 45 fc add %eax,-0x4(%rbp)
40061b: 0f b6 55 d4 movzbl -0x2c(%rbp),%edx
40061f: 8b 45 d8 mov -0x28(%rbp),%eax
400622: 01 c2 add %eax,%edx
400624: 8b 45 fc mov -0x4(%rbp),%eax
400627: 01 d0 add %edx,%eax
400629: 89 45 fc mov %eax,-0x4(%rbp)
40062c: 90 nop
; rsp 0x7fffffffe230, rbp 0x7fffffffe230
40062d: 5d pop %rbp
; rsp 0x7fffffffe238, rbp 0x7fffffffe270
40062e: c3 retq
000000000040062f <test>:
; rsp 0x7fffffffe238, rbp 0x7fffffffe270
40062f: 55 push %rbp
; rsp 0x7fffffffe230, rbp 0x7fffffffe270
400630: 48 89 e5 mov %rsp,%rbp
; rsp 0x7fffffffe230, rbp 0x7fffffffe230
400633: 48 89 7d f8 mov %rdi,-0x8(%rbp)
400637: 89 75 f4 mov %esi,-0xc(%rbp)
40063a: 89 d0 mov %edx,%eax
40063c: 66 89 45 f0 mov %ax,-0x10(%rbp)
400640: 0f b7 4d f0 movzwl -0x10(%rbp),%ecx
400644: 48 8b 45 f8 mov -0x8(%rbp),%rax
400648: 48 83 c0 28 add $0x28,%rax
40064c: 8b 55 f4 mov -0xc(%rbp),%edx
40064f: 01 ca add %ecx,%edx
400651: 89 10 mov %edx,(%rax)
400653: 90 nop
; rsp 0x7fffffffe230, rbp 0x7fffffffe270
400654: 5d pop %rbp
; rsp 0x7fffffffe238, rbp 0x7fffffffe270
400655: c3 retq
0000000000400678 <main>:
; rsp 0x7fffffffe278, rbp 0x400730 <__libc_csu_init>, 进入main函数之前,
400678: 55 push %rbp ;
; rsp 0x7fffffffe270, rbp 0x400730
400679: 48 89 e5 mov %rsp,%rbp ; 将rsp
; rsp 0x7fffffffe270, rbp 0x7fffffffe270
40067c: 48 83 ec 30 sub $0x30,%rsp
; rsp 0x7fffffffe240, rbp 0x7fffffffe270
400680: bf 08 08 40 00 mov $0x400808,%edi
400685: e8 46 fe ff ff callq 4004d0 <puts@plt>
40068a: bf 56 06 40 00 mov $0x400656,%edi
40068f: e8 1c 01 00 00 callq 4007b0 <atexit>
400694: bf 67 06 40 00 mov $0x400667,%edi
400699: e8 12 01 00 00 callq 4007b0 <atexit>
;test1 参数初始化传递
40069e: f3 0f 10 05 7e 01 00 movss 0x17e(%rip),%xmm0 # 400824 <__dso_handle+0x44>
4006a5: 00
4006a6: f3 0f 11 45 fc movss %xmm0,-0x4(%rbp)
4006ab: f2 0f 10 05 75 01 00 movsd 0x175(%rip),%xmm0 # 400828 <__dso_handle+0x48>
4006b2: 00
4006b3: f2 0f 11 45 f0 movsd %xmm0,-0x10(%rbp)
4006b8: 66 c7 45 ee ab dc movw $0xdcab,-0x12(%rbp)
4006be: c7 45 e8 cd ab cd ab movl $0xabcdabcd,-0x18(%rbp)
4006c5: c7 45 e4 cb ad cb ad movl $0xadcbadcb,-0x1c(%rbp)
4006cc: c6 45 e3 de movb $0xde,-0x1d(%rbp)
4006d0: 0f b6 4d e3 movzbl -0x1d(%rbp),%ecx
4006d4: 0f bf 45 ee movswl -0x12(%rbp),%eax
4006d8: 8b 55 e4 mov -0x1c(%rbp),%edx
4006db: 8b 75 e8 mov -0x18(%rbp),%esi
4006de: f2 0f 10 4d f0 movsd -0x10(%rbp),%xmm1
4006e3: f3 0f 10 45 fc movss -0x4(%rbp),%xmm0
4006e8: 89 c7 mov %eax,%edi
; rsp 0x7fffffffe240, rbp 0x7fffffffe270
4006ea: e8 e7 fe ff ff callq 4005d6 <test1>
; rsp 0x7fffffffe240, rbp 0x7fffffffe270
;test 参数初始化传递
4006ef: 48 c7 45 d8 00 00 00 movq $0x0,-0x28(%rbp)
4006f6: 00
4006f7: c7 45 d4 0b 00 00 00 movl $0xb,-0x2c(%rbp)
4006fe: 66 c7 45 d2 09 00 movw $0x9,-0x2e(%rbp)
400704: 0f b7 55 d2 movzwl -0x2e(%rbp),%edx
400708: 8b 4d d4 mov -0x2c(%rbp),%ecx
40070b: 48 8b 45 d8 mov -0x28(%rbp),%rax
40070f: 89 ce mov %ecx,%esi
400711: 48 89 c7 mov %rax,%rdi
400714: e8 16 ff ff ff callq 40062f <test>
400706: bf 03 08 40 00 mov $0x400803,%edi
40070b: e8 c0 fd ff ff callq 4004d0 <puts@plt>
400710: b8 00 00 00 00 mov $0x0,%eax
; rsp 0x7fffffffe240, rbp 0x7fffffffe270
400715: c9 leaveq
; rsp 0x7fffffffe238, rbp 0x400730 <__libc_csu_init>
400716: c3 retq
400717: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1)
40071e: 00 00
标签:汇编,00,x86,45,mov,rbp,指令,89,rsp
From: https://www.cnblogs.com/han-guang-xue/p/16939626.html