简体   繁体   English

ATmega8不支持JMP指令

[英]ATmega8 doesn't support JMP instruction

现在我正在编写从内存中间开始的bootloader,但在完成之后我需要去主应用程序,想要尝试jmp 0x00 ,但是我的芯片不支持jmp ,我应该如何启动主应用程序?

I would use RJMP : 我会用RJMP

Relative jump to an address within PC - 2K +1 and PC + 2K (words). 相对跳转到PC内的地址 - 2K +1和PC + 2K(字)。 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 . 顺便说一下,还有其他一些跳转指令(RJMP,IJMP,RCALL,ICALL,CALL,RET,RETI等)。请参阅此相关讨论

Well take a look into RET instruction. 那么看看RET指令。 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. 这应该有效,因为在进入任何功能时你会推送当前位置,而RET会让你回去。

As far as I remember ATmege8 has 16-bit address line, but if I'm not right you may need more push 0x00 据我记得ATmege8有16位地址线,但如果我不对你可能需要更多push 0x00

why not simply use IJMP? 为什么不简单地使用IJMP?

set Z to 0x00 and use IJMP. 将Z设置为0x00并使用IJMP。 may be faster than 2xpush and ret 可能比2xpush和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) 应该是4个周期和3个指令字(6字节程序存储器)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM