[ARM-assembly]-C语言和汇编对比学习
2023-09-27 14:26:31 时间
快速链接:
.
👉👉👉 个人博客笔记导读目录(全部) 👈👈👈
(1)
static int x;
//static int y = 10;
//int z;
//int w = 20;
int main()
{
int s = 200;
x = 100;
s=s+x;
// s=s+y;
// z=100;
// s=s+z;
// s=s+w;
return 0;
}
hehezhou@buildsrv-165:~/workspace/test/test1$ aarch64-linux-android-objdump -D main.o
main.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <main>:
0: d10043ff sub sp, sp, #0x10
4: 52801900 mov w0, #0xc8 // #200
8: b9000fe0 str w0, [sp,#12]
c: 90000000 adrp x0, 0 <main>
10: 91000000 add x0, x0, #0x0
14: 52800c81 mov w1, #0x64 // #100
18: b9000001 str w1, [x0]
1c: 90000000 adrp x0, 0 <main>
20: 91000000 add x0, x0, #0x0
24: b9400000 ldr w0, [x0]
28: b9400fe1 ldr w1, [sp,#12]
2c: 0b000020 add w0, w1, w0
30: b9000fe0 str w0, [sp,#12]
34: 52800000 mov w0, #0x0 // #0
38: 910043ff add sp, sp, #0x10
3c: d65f03c0 ret
Disassembly of section .bss:
0000000000000000 <x>:
0: 00000000 .word 0x00000000
Disassembly of section .comment:
0000000000000000 <.comment>:
0: 43434700 .inst 0x43434700 ; undefined
4: 4728203a .inst 0x4728203a ; undefined
8: 2029554e .inst 0x2029554e ; undefined
c: 2e392e34 uqsub v20.8b, v17.8b, v25.8b
10: 30322078 adr x24, 6441d <main+0x6441d>
14: 31303531 adds w17, w9, #0xc0d
18: 28203332 stnp w18, w12, [x25,#-256]
1c: 72657270 .inst 0x72657270 ; undefined
20: 61656c65 .inst 0x61656c65 ; undefined
24: 00296573 .inst 0x00296573 ; NYI
(2)
//static int x;
static int y = 10;
//int z;
//int w = 20;
int main()
{
int s = 200;
// x = 100;
// s=s+x;
s=s+y;
// z=100;
// s=s+z;
// s=s+w;
return 0;
}
hehezhou@buildsrv-165:~/workspace/test/test1$ aarch64-linux-android-objdump -D main.o
main.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <main>:
0: d10043ff sub sp, sp, #0x10
4: 52801900 mov w0, #0xc8 // #200
8: b9000fe0 str w0, [sp,#12]
c: 90000000 adrp x0, 0 <main>
10: 91000000 add x0, x0, #0x0
14: b9400000 ldr w0, [x0]
18: b9400fe1 ldr w1, [sp,#12]
1c: 0b000020 add w0, w1, w0
20: b9000fe0 str w0, [sp,#12]
24: 52800000 mov w0, #0x0 // #0
28: 910043ff add sp, sp, #0x10
2c: d65f03c0 ret
Disassembly of section .data:
0000000000000000 <y>:
0: 0000000a .word 0x0000000a
Disassembly of section .comment:
0000000000000000 <.comment>:
0: 43434700 .inst 0x43434700 ; undefined
4: 4728203a .inst 0x4728203a ; undefined
8: 2029554e .inst 0x2029554e ; undefined
c: 2e392e34 uqsub v20.8b, v17.8b, v25.8b
10: 30322078 adr x24, 6441d <main+0x6441d>
14: 31303531 adds w17, w9, #0xc0d
18: 28203332 stnp w18, w12, [x25,#-256]
1c: 72657270 .inst 0x72657270 ; undefined
20: 61656c65 .inst 0x61656c65 ; undefined
24: 00296573 .inst 0x00296573 ; NYI
(3)、
//static int x;
//static int y = 10;
int z;
//int w = 20;
int main()
{
int s = 200;
// x = 100;
// s=s+x;
// s=s+y;
z=100;
s=s+z;
// s=s+w;
return 0;
}
hehezhou@buildsrv-165:~/workspace/test/test1$ aarch64-linux-android-objdump -D main.o
main.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <main>:
0: d10043ff sub sp, sp, #0x10
4: 52801900 mov w0, #0xc8 // #200
8: b9000fe0 str w0, [sp,#12]
c: 90000000 adrp x0, 4 <main+0x4>
10: f9400000 ldr x0, [x0]
14: 52800c81 mov w1, #0x64 // #100
18: b9000001 str w1, [x0]
1c: 90000000 adrp x0, 4 <main+0x4>
20: f9400000 ldr x0, [x0]
24: b9400000 ldr w0, [x0]
28: b9400fe1 ldr w1, [sp,#12]
2c: 0b000020 add w0, w1, w0
30: b9000fe0 str w0, [sp,#12]
34: 52800000 mov w0, #0x0 // #0
38: 910043ff add sp, sp, #0x10
3c: d65f03c0 ret
Disassembly of section .comment:
0000000000000000 <.comment>:
0: 43434700 .inst 0x43434700 ; undefined
4: 4728203a .inst 0x4728203a ; undefined
8: 2029554e .inst 0x2029554e ; undefined
c: 2e392e34 uqsub v20.8b, v17.8b, v25.8b
10: 30322078 adr x24, 6441d <main+0x6441d>
14: 31303531 adds w17, w9, #0xc0d
18: 28203332 stnp w18, w12, [x25,#-256]
1c: 72657270 .inst 0x72657270 ; undefined
20: 61656c65 .inst 0x61656c65 ; undefined
24: 00296573 .inst 0x00296573 ; NYI
(4)、
//static int x;
//static int y = 10;
//int z;
int w = 20;
int main()
{
int s = 200;
// x = 100;
// s=s+x;
// s=s+y;
// z=100;
// s=s+z;
s=s+w;
return 0;
}
hehezhou@buildsrv-165:~/workspace/test/test1$ aarch64-linux-android-gcc-4.9 -c main.c
Android GCC has been deprecated in favor of Clang, and will be removed from
Android in 2020-01 as per the deprecation plan in:
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/master/GCC_4_9_DEPRECATION.md
hehezhou@buildsrv-165:~/workspace/test/test1$ aarch64-linux-android-objdump -D main.o
main.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <main>:
0: d10043ff sub sp, sp, #0x10
4: 52801900 mov w0, #0xc8 // #200
8: b9000fe0 str w0, [sp,#12]
c: 90000000 adrp x0, 0 <main>
10: f9400000 ldr x0, [x0]
14: b9400000 ldr w0, [x0]
18: b9400fe1 ldr w1, [sp,#12]
1c: 0b000020 add w0, w1, w0
20: b9000fe0 str w0, [sp,#12]
24: 52800000 mov w0, #0x0 // #0
28: 910043ff add sp, sp, #0x10
2c: d65f03c0 ret
Disassembly of section .data:
0000000000000000 <w>:
0: 00000014 .word 0x00000014
Disassembly of section .comment:
0000000000000000 <.comment>:
0: 43434700 .inst 0x43434700 ; undefined
4: 4728203a .inst 0x4728203a ; undefined
8: 2029554e .inst 0x2029554e ; undefined
c: 2e392e34 uqsub v20.8b, v17.8b, v25.8b
10: 30322078 adr x24, 6441d <main+0x6441d>
14: 31303531 adds w17, w9, #0xc0d
18: 28203332 stnp w18, w12, [x25,#-256]
1c: 72657270 .inst 0x72657270 ; undefined
20: 61656c65 .inst 0x61656c65 ; undefined
24: 00296573 .inst 0x00296573 ; NYI
(5)
static int x;
static int y = 10;
int z;
int w = 20;
int main()
{
int s = 200;
x = 100;
s=s+x;
s=s+y;
z=100;
s=s+z;
s=s+w;
return 0;
}
hehezhou@buildsrv-165:~/workspace/test/test1$ aarch64-linux-android-objdump -D main.o
main.o: file format elf64-littleaarch64
Disassembly of section .text:
0000000000000000 <main>:
0: d10043ff sub sp, sp, #0x10
4: 52801900 mov w0, #0xc8 // #200
8: b9000fe0 str w0, [sp,#12]
c: 90000000 adrp x0, 0 <main>
10: 91000000 add x0, x0, #0x0
14: 52800c81 mov w1, #0x64 // #100
18: b9000001 str w1, [x0]
1c: 90000000 adrp x0, 0 <main>
20: 91000000 add x0, x0, #0x0
24: b9400000 ldr w0, [x0]
28: b9400fe1 ldr w1, [sp,#12]
2c: 0b000020 add w0, w1, w0
30: b9000fe0 str w0, [sp,#12]
34: 90000000 adrp x0, 0 <main>
38: 91000000 add x0, x0, #0x0
3c: b9400000 ldr w0, [x0]
40: b9400fe1 ldr w1, [sp,#12]
44: 0b000020 add w0, w1, w0
48: b9000fe0 str w0, [sp,#12]
4c: 90000000 adrp x0, 4 <main+0x4>
50: f9400000 ldr x0, [x0]
54: 52800c81 mov w1, #0x64 // #100
58: b9000001 str w1, [x0]
5c: 90000000 adrp x0, 4 <main+0x4>
60: f9400000 ldr x0, [x0]
64: b9400000 ldr w0, [x0]
68: b9400fe1 ldr w1, [sp,#12]
6c: 0b000020 add w0, w1, w0
70: b9000fe0 str w0, [sp,#12]
74: 90000000 adrp x0, 4 <main+0x4>
78: f9400000 ldr x0, [x0]
7c: b9400000 ldr w0, [x0]
80: b9400fe1 ldr w1, [sp,#12]
84: 0b000020 add w0, w1, w0
88: b9000fe0 str w0, [sp,#12]
8c: 52800000 mov w0, #0x0 // #0
90: 910043ff add sp, sp, #0x10
94: d65f03c0 ret
Disassembly of section .data:
0000000000000000 <y>:
0: 0000000a .word 0x0000000a
0000000000000004 <w>:
4: 00000014 .word 0x00000014
Disassembly of section .bss:
0000000000000000 <x>:
0: 00000000 .word 0x00000000
Disassembly of section .comment:
0000000000000000 <.comment>:
0: 43434700 .inst 0x43434700 ; undefined
4: 4728203a .inst 0x4728203a ; undefined
8: 2029554e .inst 0x2029554e ; undefined
c: 2e392e34 uqsub v20.8b, v17.8b, v25.8b
10: 30322078 adr x24, 6441d <w+0x64419>
14: 31303531 adds w17, w9, #0xc0d
18: 28203332 stnp w18, w12, [x25,#-256]
1c: 72657270 .inst 0x72657270 ; undefined
20: 61656c65 .inst 0x61656c65 ; undefined
24: 00296573 .inst 0x00296573 ; NYI
![](http://assets.processon.com/chart_image/604719347d9c082c92e419de.png)
相关文章
- C语言 - 删除数组中的指定元素(Delete)
- C语言-5月17日-求m到n的和
- C语言|递归|青蛙跳台阶和汉诺塔问题
- 【C/C++开发】值得学习的C语言开源项目
- 值得学习的C语言开源项目
- C语言学习笔记 (008) - C语言字符串操作总结大全(超详细)(转)
- Redis学习之路(008)- Redis C语言客户端库hiredis文档翻译
- C语言:基于 DFS 和 BFS 遍历的算法来判别顶点 i 和顶点 j (i≠j)之间是否有路径算法
- C语言中volatile关键字的作用
- 杭电OJ第11页2050~2054算法题(C语言)
- 2021-12-05青少年软件编程(C语言)等级考试试卷(五级)解析
- 【C】新手C语言学习(2)
- 【C】C语言实现图书管理系统
- Linux·C语言高级编程·volatile关键字解析
- 《C语言编写 学生成绩管理系统》
- linux下的C语言开发(线程互斥)
- C语言程序设计基础|精挑细选
- C语言里的左移和右移运算
- C语言学习笔记——指针章节
- C语言学习笔记——操作符与表达式章节
- C语言学习入门之操作符详解(上)
- C语言学习入门之函数详解【上】
- 李洪强漫谈iOS开发[C语言-036]-C语言前四天学习小结
- 【零基础学习iOS开发】【02-C语言】11-函数的声明和定义
- 李洪强iOS开发之【零基础学习iOS开发】【02-C语言】08-基本运算
- 李洪强iOS开发之零基础学习iOS开发【02-C语言】03-关键字、标识符、注释
- 李洪强iOS开发之【零基础学习iOS开发】【02-C语言】02-第一个C语言程序
- 初学者值得一看:什么是编程/C语言,编程学习建议,编程解疑与误区注意
- C语言--存储类别和链接
- C语言 HTTP上传文件-利用libcurl库上传文件