2017-05-22 13 views
0

Relative jump to an address within PC - 2K +1 and PC + 2K (words). In the assembler, labels are used instead of relative operands. For AVR microcontrollers with program memory not exceeding 4K words (8K bytes) this instruction can address the entire memory from every address location.AVR(ATmega8515的)RJMP不跳相对

基于http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_RJMP.html,在rjmp命令应相对改变PC寄存器。但低于我的代码是跳跃的确切地址(在这种情况下,与地址为0x00 ldi temp, low(RAMEND)命令)

.include "m8515def.inc" 

.def temp = r16 


STACK_INIT: 
    ; init stack pointer 
    ldi temp, low(RAMEND) 
    out SPL, temp 
    ldi temp, high(RAMEND) 
    out SPH, temp 

TES: 
    rjmp 0x00 

END: 
    rjmp END 

我试图改变rjmp命令jmp但ATmega8515的不支持该命令

我不知道这是因为配置什么的。我正在使用AVR Studio 4构建并运行我的程序。有人可以解释一下吗?

回答

1

这是预期的。为了方便汇编语言程序员,rjmp操作采用绝对地址而不是相对地址。当它实际编译二进制机器码时,绝对地址将被转换为相对地址,如果地址太远而无法跳转,则会出现错误。

顺便说一句,您可以在您的操作数中使用$符号。这是当前指令的地址。所以像rjmp $+2这样的东西会跳到下一条指令后的两个字节。

+0

这是发生在所有汇编语言还是只是AVR具体? 'rjmp $ + 2'给了我'错误:语法错误,意外$ undefined' –

+0

我无法对所有汇编语言做任何绝对声明。 –