2008-01-08 07:42 PM
Getting the PC(Program counter) register?
2008-01-08 01:47 AM
Hi,
Again another message. I would like to know if it is possible to get the PC register thanks to assembler commands. Below, what i have done:Code:
unsigned char cNbOctet = 0; asm { LD A,PCL; LD cNbOctet, A; } But my compiler detect one error: Label Adressing Not Supported. Why? According to the st7 datasheet, pc is a 16-bit register containing the address of the next instruction to be executed by the CPU. It is made of two 8-bit registers PCL (Program Counter Low which is the LSB) and PCH (Program Counter High which is the MSB). Thanks for your help. Nicolas2008-01-08 07:10 PM
Nicolas,
there is no assembler instruction to read the program counter register value (of course, the jump or call instructions change its value, but this is not what you ask). To have the program counter value, one have to use a subroutine call which pushes on the stack the return address (i.e. the program counter of the next istruction to execute when the subroutine ends). If you know this, in the subroutine code you can use the following instructions: POP X ; X = PCH POP A ; A = PCL PUSH A ; Restore the stack content PUSH X RET When the above subroutine returns, the pair {X,A} holds the program counter of the first instruction after the subroutine call. I hope I was helpful... Regards, EtaPhi PS: what do you plan to do with the program counter? Perhaps there is a simpler way to obtain what you need...2008-01-08 07:42 PM
EtaPhi,
Thanks for your reply. In fact, i would like to get the PC register so as to verify its actual value. To debug a problem, I would check if my PC is not corrupted inside a while operation. But i feel that is not the best way... Regards, Nicolas