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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
2,087 Views
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
Labels (1)
0 Kudos
1 Solution
563 Views
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?
 

View solution in original post

0 Kudos
4 Replies
563 Views
kef
Specialist I
What you have in memory at 0x7FFA?
0 Kudos
563 Views
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 Kudos
564 Views
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 Kudos
563 Views
MicroTang
Contributor III
You are right! (0x7ffe)=0x0000. It seems my code has some problem.
 
Thanks for your help!
0 Kudos