What is (PC) after JSR is executed? - MC9S12XEP100

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

What is (PC) after JSR is executed? - MC9S12XEP100

跳至解决方案
2,097 次查看
MicroTang
Contributor III
Let's assume current (PC)=0xF0BC, and current instruction is JSR [0x8F3E, PC]. After this instruction is excuted, what is (PC)?
 
According to Reference Manual, (PC) = ((0xF0BC+0x8F3E)) = (0x17FFA). Accually, PC is set to 0x0000. Could you please tell me what is happened?
 
The micro is MC9S12XEP100.
 
Thanks!
 
 
Added p/n to subject.


Message Edited by NLFSJ on 2008-10-23 03:28 PM
标签 (1)
0 项奖励
1 解答
573 次查看
kef
Specialist I
Correction, sorry. It should jump not to the word address stored at current PC + offset in [], but to the word address stored at current PC + sizeof of this instruction + offset in []. In other words ,pc relative addressing is relative not to the start of instruction with ,pc , but to the start of next instruction. The size of instruction in your case is 4. So the address taken is at 0xF0BC + 4 + 0x8F3E = 7ffe. So what's at 7ffe?
 

在原帖中查看解决方案

0 项奖励
4 回复数
573 次查看
kef
Specialist I
What you have in memory at 0x7FFA?
0 项奖励
573 次查看
MicroTang
Contributor III
Thanks for your reply.
 
(0x7FFA) = 0xE080. Does it means the CF (1) is ignored and (PC) should be 0xE080? But why PC is set to 0x0000?
0 项奖励
574 次查看
kef
Specialist I
Correction, sorry. It should jump not to the word address stored at current PC + offset in [], but to the word address stored at current PC + sizeof of this instruction + offset in []. In other words ,pc relative addressing is relative not to the start of instruction with ,pc , but to the start of next instruction. The size of instruction in your case is 4. So the address taken is at 0xF0BC + 4 + 0x8F3E = 7ffe. So what's at 7ffe?
 
0 项奖励
573 次查看
MicroTang
Contributor III
You are right! (0x7ffe)=0x0000. It seems my code has some problem.
 
Thanks for your help!
0 项奖励