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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
2,969件の閲覧回数
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 解決策
1,445件の閲覧回数
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 返答(返信)
1,445件の閲覧回数
kef
Specialist I
What you have in memory at 0x7FFA?
0 件の賞賛
返信
1,445件の閲覧回数
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 件の賞賛
返信
1,446件の閲覧回数
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 件の賞賛
返信
1,445件の閲覧回数
MicroTang
Contributor III
You are right! (0x7ffe)=0x0000. It seems my code has some problem.
 
Thanks for your help!
0 件の賞賛
返信