zoukankan      html  css  js  c++  java
  • arm程序的反汇编程序

    这是汇编源文件:
    MCU:S3C2440(arm920T)
    代码实现点亮个led小灯
    .text
    .global _start
    _start:
            ldr r0,=0x56000010        @GPBCON
            mov r1,#0x00000400        @
            str r1,[r0]                @GPB5_out=01
           
            ldr r0,=0x56000014        @GPBDAT
            mov r1,#0x0
            str r1,[r0]                @GPBDAT[5]=0,len_off
    main_loop:
            b        main_loop
    
    反汇编文件:
    led_on.bin:     file format binary
    Disassembly of section .data:
    00000000 <.data>:
       0:        e59f0014         ldr        r0, [pc, #20]        ; 0x1c
       4:        e3a01b01         mov        r1, #1024        ; 0x400
       8:        e5801000         str        r1, [r0]
       c:        e59f000c         ldr        r0, [pc, #12]        ; 0x20
      10:        e3a01000         mov        r1, #0        ; 0x0
      14:        e5801000         str        r1, [r0]
      18:        eafffffe         b        0x18
      1c:        56000010         undefined
      20:        56000014         undefined
    
    接下来让我们分析下这小小的反汇编程序吧!
       0:        e59f0014         ldr        r0, [pc, #20]        ; 0x1c
    这条指令就是把内存单元 pc+20 的值load 到r0 中,而根据ARM 架构指南所讲,pc 的值读取得时候是当前指令的地址 +8 ,
    所以就是把地址28 (也就是16进制的1c)的值load 到r0中,r0 现在变成了0x56000010.
       4:        e3a01b01         mov        r1, #1024        ; 0x400
    这条指令是把1024(ARM汇编At&T语法要在立即数前加#), 也即是16进制的0x400 移到r1中。
       8:        e5801000         str        r1, [r0]
    这个就是通过str 指令把r1内容存到r0 寄存器所指向的内存单元。 也就是把1024 存到0x56000000 中。
       c:        e59f000c         ldr        r0, [pc, #12]        ; 0x20
      10:        e3a01000         mov        r1, #0        ; 0x0
      14:        e5801000         str        r1, [r0]
    这三条指令一样的道理
      18:        eafffffe         b        0x18
    这个是死循环
      1c:        56000010         undefined
      20:        56000014         undefined
    这两行不是指令,而是数据。
  • 相关阅读:
    hdu2328 Corporate Identity
    hdu1238 Substrings
    hdu4300 Clairewd’s message
    hdu3336 Count the string
    hdu2597 Simpsons’ Hidden Talents
    poj3080 Blue Jeans
    poj2752 Seek the Name, Seek the Fame
    poj2406 Power Strings
    hust1010 The Minimum Length
    hdu1358 Period
  • 原文地址:https://www.cnblogs.com/liulipeng/p/3367830.html
Copyright © 2011-2022 走看看