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.
Based on http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_RJMP.html , the rjmp
command should change the PC register relatively. But my code below are jumping to the exact address (in this case to ldi temp, low(RAMEND)
command with address 0x00)
.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
I've tried to change the rjmp
command to jmp
but the atmega8515 doesn't support that command
I don't know if this because of the configuration or something. I'm using AVR Studio 4 for build and run my program. Can anybody explain about it?
This is expected. For the convenience of assembly language programmers, the rjmp
operation takes an absolute address instead of a relative one. The absolute address will be converted to a relative one when it actually compiles the binary machine code, and you'll get an error if the address is too far away to jump to.
By the way, you can use the $
symbol in your operands. It is the address of the current instruction. So something like rjmp $+2
would jump to two bytes past the next instruction.