ARM Technical Support Knowledge Articles

READING THE PROGRAM COUNTER

Applies to: A51 Macro Assembler

Answer


Information in this article applies to:


QUESTION

How can I get the address currently in the program counter?

ANSWER

The 8051 has no direct way to read the program counter. However, there are several tricks you can use to get the contents of the program counter. Note that the address in the program counter is a 16-bit value. And, the program counter changes while executing code to get its address.

Method 1

       MOV DPTR,$

At this point, DPTR contains the address of the MOV DPTR instruction.

Method 2

       LCALL here
here:
       POP DPH
       POP DPL

At this point, DPTR contains the address of the here label.

MORE INFORMATION

Article last edited on: 2007-01-08 15:41:49

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential