ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2021-06-21 14:55:35  阅读:231  来源: 互联网

标签:assembly undefined int sp C语言 inst w0 x0 ARM


(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

标签:assembly,undefined,int,sp,C语言,inst,w0,x0,ARM
来源: https://blog.51cto.com/u_15278218/2930976

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有