代码之家  ›  专栏  ›  技术社区  ›  Matthew Murdoch

如何在Windows上获取Arduino草图的汇编语言列表?

  •  13
  • Matthew Murdoch  · 技术社区  · 15 年前

    我想能够看到我的阿尔杜诺草图汇编语言列表。我怎样才能做到这一点?

    更新: 我在Windows机器上运行Arduino软件。

    4 回复  |  直到 10 年前
        1
  •  13
  •   Greg Hewgill    15 年前

    一种方法是使用 avr-objdump .elf 由生成创建的文件。例如,在OS X上,我可以这样做:

    $ cd ~/arduino-0015/examples/Digital/Blink/applet
    $ avr-objdump -d Blink.elf
    

    (显然,您在Windows上的路径可能不同。)这将生成代码的反汇编,其中的一部分将类似于这样:

    0000013a <main>:
     13a:   0e 94 3e 01     call    0x27c <init>
     13e:   0e 94 97 00     call    0x12e <setup>
     142:   0e 94 80 00     call    0x100 <loop>
     146:   fd cf           rjmp    .-6             ; 0x142 <main+0x8>
    
        2
  •  6
  •   Magnus Hoff    15 年前

    如果您使用的是Linux,您可以按照 this tutorial on how to compile for the Arduino without the IDE .

    一旦您这样做了,就可以通过运行带有-s标志的gcc来获得程序集列表。

        3
  •  3
  •   Matthew Murdoch    15 年前

    以下(hacky)步骤将在Windows上提供Arduino草图和相关库的汇编语言列表:

    1. 下载(并重命名) Arduino Windows command line batch files 进入包含草图的目录 .pde 文件)
    2. 按照上述链接页中的指定设置所需的环境变量
    3. 添加 -S abuild_gcc_opts 变量在 abuild.bat (第158行)
    4. abuild -r -c <pde_filename>
    5. 希望得到以下警告和错误,您可以忽略这些警告和错误:

      ... warning: #warning "This file has been moved to <util/delay.h>."

      .\obj\<pde_filename>.cpp.o: file format not recognized: treating as linker script

      .\obj\<pde_filename>.cpp.o:1: syntax error

    汇编语言列表可以在 .o 在创建的 obj 目录。例如,草图本身的列表位于 obj\<pde_filename>.cpp.o

        4
  •  0
  •   Marco linux    10 年前

    -s(not s)标志也显示C代码。也称为混合列表:

    linux:(.arduino/preferences.txt:delete_target_folder=false)

    $ cd /tmp/buildxxxx.tmp
    $ avr-objdump -dS Blink.cpp.elf
    
    int main(void)
    {
        init();
     2f4:   8a df           rcall   .-236       ; 0x20a <init>
    ...