AVR-编译后为零跳转地址

时间:2019-06-15 21:04:31

标签: assembly arduino avr disassembly objdump

我的操作系统:Ubuntu 16.04 avr_as:v2.25 AVR芯片:ATmega328p 板:Arduino UNO R3

程序源:

#include <avr/io.h>

.ORG 0x0000
        RJMP    init

init:
        LDI             R16, 0xFF
        OUT             0x3d, R16
        LDI             R16, 0x08
        OUT             0x3e, R16

        LDI             R20, 0xFF
        LDI             R21, 0x00
        OUT             0x04, R20

main:
        OUT     0x05, R20
        RCALL   dalay_1sec

        OUT     0x05, R21
        RCALL   dalay_1sec

        RJMP    main

dalay_1sec:
        LDI             R19, 0x30
        LDI             R18, 0x4D
        LDI             R17, 0x00

delay_1sec_loop:
        SUBI            R17, 1
        SBCI            R18, 0
        SBCI            R19, 0
        BRCC            delay_1sec_loop

        RET

反汇编代码:

$ avr-as -mmcu=atmega328p app.s -o app.elf
$ avr-objdump -D app.elf 

app.elf:     elf32-avr

 .text:
00000000 <init-0x2>:
   0:   00 c0           rjmp    .+0         ; 0x2 <init>
00000002 <init>:
   2:   0f ef           ldi r16, 0xFF   ; 255
   4:   0d bf           out 0x3d, r16   ; 61
   6:   08 e0           ldi r16, 0x08   ; 8
   8:   0e bf           out 0x3e, r16   ; 62
   a:   4f ef           ldi r20, 0xFF   ; 255
   c:   50 e0           ldi r21, 0x00   ; 0
   e:   44 b9           out 0x04, r20   ; 4
00000010 <main>:
  10:   45 b9           out 0x05, r20   ; 5
  12:   00 d0           rcall   .+0         ; 0x14 <main+0x4>
  14:   55 b9           out 0x05, r21   ; 5
  16:   00 d0           rcall   .+0         ; 0x18 <main+0x8>
  18:   00 c0           rjmp    .+0         ; 0x1a <dalay_1sec>
0000001a <dalay_1sec>:
  1a:   30 e3           ldi r19, 0x30   ; 48
  1c:   2d e4           ldi r18, 0x4D   ; 77
  1e:   10 e0           ldi r17, 0x00   ; 0
00000020 <delay_1sec_loop>:
  20:   11 50           subi    r17, 0x01   ; 1
  22:   20 40           sbci    r18, 0x00   ; 0
  24:   30 40           sbci    r19, 0x00   ; 0
  26:   00 f4           brcc    .+0         ; 0x28 
<delay_1sec_loop+0x8>
  28:   08 95           ret

因此所有要跳转的地址都转换为+0

对于RJMP,BRCC。

如何解决?

0 个答案:

没有答案