how to get program counter (PC)

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

how to get program counter (PC)

4,599件の閲覧回数
mikoran
Contributor II
can u help me how to get the value of the program counter?
 
        TFR PC, D
        STD u16pc
 
but it didnt work.
 
tnx.
ラベル(1)
5 返答(返信)

1,880件の閲覧回数
CrasyCat
Specialist III
Hello
 
PC is not a valid operator for the TFR instruction according to the HCS12 core reference manual.
 
Are you using CodeWarrior and programming in assembler?
 
Then I would write the following in your assembly source file:
            LDX #*
 
CrasyCat
0 件の賞賛
返信

1,880件の閲覧回数
mikoran
Contributor II
yes i am using codewarrior but using C. i just add that inline assembly code..
0 件の賞賛
返信

1,880件の閲覧回数
CrasyCat
Specialist III
Hello
 
  I am not sure you can do that in inline assembly.
  May ask you why you need to load the PC in a register?
 
   What are you trying to achieve here?
 
CrasyCat
0 件の賞賛
返信

1,880件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
I'm wondering just as CrazyCat why you want to retrieve the PC, do you really need it?

If you do need it, see below for one way how to do it.
This snippet gets the PC as it is at the STX instruction, just after the LEAX.

Daniel

Code:
unsigned int pcVar;void test(void) {  __asm {    LEAX 0,PC;    STX pcVar;  }}

 

1,880件の閲覧回数
mikoran
Contributor II
ok tnx a lot.
I need to retrieve PC for later debugging purposes. I have this module that would record the details during RAM fault
0 件の賞賛
返信