| ??? 02/16/01 23:52 Read: times |
#9413 - RE: program counter |
The program counter if read by an opcode would merely be the address of the opcode. Since that is constant, what would be the point?
Maybe a more useful peice of information to do whatever you intend is to read the stack for the return address from which a call was made. There are a lot of clever constructs that extract the return address and manipulate it. Tell us what you are attempting to accomplish. However, there is use some manipulations with the program counter (PC). Most common is the assemble use of the variable $. This is used as a substitution for the address that would be in the PC at the location of the $ symbol. This is often used for generating self-adjusting data blocks or equate statements. For example, the following code sets up a set of reserved ram variables beginning at t_lst. The initialization routine clears the contents and must know how many bytes to clear out. I could equate a constant and attempt to remember it everytime I add a new byte to the list, or as I've done here, I let the assembler figure out the count so I can add or delete list members as I develop code without the burden of changing the count: t_lst: t_buz: ds 1 t_led: ds 1 t_iic: ds 1 t_cnt equ $-t_lst The last line does the count equate by subtracting the PC address value next available when the $ appear. It subtracts that address from the address of t_lst and in the example above, sets the equate to 3. This is a safe way of ensuring the block gets properly initialized even though I may change or reorder the contents of the list until I've got the code complete. Another PC related function of the 8051 is the MOVC A,@A+PC instruction. Its a nice opcode for reducing the time to load values from a table in that it saves you loading DPTR or Ri to oint to the table. Its worth looking into. aka j |
| Topic | Author | Date |
| program counter | 01/01/70 00:00 | |
| RE: program counter | 01/01/70 00:00 | |
| RE: program counter | 01/01/70 00:00 | |
| RE: program counter | 01/01/70 00:00 | |
| TABLE LOOK-UP METHEOD | 01/01/70 00:00 | |
| TABLE LOOK-UP METHEOD | 01/01/70 00:00 | |
| TABLE LOOK-UP METHEOD | 01/01/70 00:00 | |
More than 64KB Prog Memory ?? | 01/01/70 00:00 |



