Question

Now I'm writing bootloader which starts in the middle of memory, but after it finishes I need to go to the main app, thought to try jmp 0x00, however my chip doesn't support jmp, how should I start main app?

Was it helpful?

Solution 2

Well take a look into RET instruction. It returns to previous location, so you can try:

push 0x00
push 0x00
ret

This should work because while entering into any function you push your current location, and RET makes you go back.

As far as I remember ATmege8 has 16-bit address line, but if I'm not right you may need more push 0x00

OTHER TIPS

I would use RJMP:

Relative jump to an address within PC - 2K +1 and PC + 2K (words). In the assembler, labels are used instead of relative operands.

For example:

entry:
   rjmp reset
   .org 512
reset:
    rjmp foo 
   .org 3072
foo:
   rjmp entry

By the way, there are several other jump instructions (RJMP, IJMP, RCALL, ICALL, CALL, RET, RETI etc.) See this relevant discussion.

why not simply use IJMP?

set Z to 0x00 and use IJMP. may be faster than 2xpush and ret

EOR R30, R30  ; clear ZL
EOR R31, R31  ; clear ZH
IJMP          ; set PC to Z

should be 4 cycles and 3 instruction words (6 Bytes program memory)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top