[ARM-assembly]-C语言和汇编对比学习

267 篇文章 378 订阅

快速链接:
.
👉👉👉 个人博客笔记导读目录(全部) 👈👈👈

在这里插入图片描述

(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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Arm精选

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值