Questions tagged [program-counter]

The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR), the instruction counter, or just part of the instruction sequencer, is a processor register that indicates where a computer is in its program sequence.

The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR), the instruction counter, or just part of the instruction sequencer, is a processor register that indicates where a computer is in its program sequence.

105 questions
52
votes
2 answers

Program Counter and Instruction Register

Program counter holds the address of the instruction that should be executed next, while instruction register holds the actual instruction to be executed. wouldn't one of them be enough? And what is the length of each one of these registers?…
Benyamin Noori
  • 860
  • 1
  • 8
  • 24
36
votes
7 answers

Reading program counter directly

Can the program counter on Intel CPUs can be read directly (that is without 'tricks') in kernel mode or some other mode?
Liran Orevi
  • 4,755
  • 7
  • 47
  • 64
30
votes
4 answers

Why isn't the instruction pointer a normal register usable with MOV or ADD?

The Wikipedia article about x86 assembly says that "the IP register cannot be accessed by the programmer directly." Directly means with instructions like mov and add, the same way we can read and write EAX. Why not? What is the reason behind this?…
user142019
20
votes
1 answer

Instruction Pointer vs Program Counter?

Is there any basic difference between instruction pointer and program counter? I believe they both refer to the same thing, the eip/rip register, although with the research i have done so far it is not very clear in my mind.
17
votes
2 answers

MIPS - JAL confusion: $ra = PC+4 or PC+8?

I'm having trouble understanding how the instruction jal works in the MIPS processor. My two questions are: a) What is the value stored in R31 after "jal": PC+4 or PC+8? b) If it's really PC+8, what happens to the instruction at PC+4? Is it executed…
ReimannCL
  • 171
  • 1
  • 1
  • 4
14
votes
2 answers

What is the difference between Stack Pointer and Program Counter?

As we always know the procedure of executing task by a microprocessor is just executing binary instructions from memory one by one and there is a program counter which holds the address of the next instruction. So this is how processor executes it's…
Naasif
  • 495
  • 2
  • 6
  • 13
11
votes
2 answers

x86 Program Counter abstracted from microarchitecture?

I'm reading the book The RISC-V Reader: An Open Architecture Atlas. The authors, to explain the isolation of an ISA (Instruction Set Architecture) from a particular implementation (i.e., microarchitecture) wrote: The temptation for an architect is…
JFMR
  • 23,265
  • 4
  • 52
  • 76
9
votes
2 answers

How is code stored and executed on the C++ abstract machine?

In the first book I read about C++, it went a little bit into the details of how code is actually executed on a machine (it mentioned the program counter, the call stack, return addresses, and such). I found it really fascinating to get to know how…
9
votes
4 answers

Does Program Counter hold current address or the address of the next instruction?

Being a beginner and self-learner, I am learning assembly and currently reading the chapter 3 of the book, The C Companion by Allen Hollub. I can't understand the description of Program Counter or PC he describes in an imaginary demo machine with…
Bishnu
  • 177
  • 1
  • 10
7
votes
3 answers

how to get current PC register value on MIPS arch?

I'd like to do backtrace on MIPS. Then, I face one problem: how do I get the current PC register value, since it doesn't belong to 32 normal registers.. Thanks for your suggestion..
Randy
  • 97
  • 1
  • 8
6
votes
3 answers

Move the Program Counter in Delphi Debugging

In Visual Studio, when you're debugging with breakpoints you can change which line of code will be next to execute by dragging the execution cursor to another line; this lets you skip IF statements and the like. I was idly wondering if there was a…
Kieran
  • 718
  • 1
  • 16
  • 33
6
votes
5 answers

ARM Cortex M3 How do I determine the program counter value before a hard fault?

I have an embedded project using a STM32F103 (ARM Cortex M3), it is getting a occasionally getting hard fault in release mode. As part of recovery, I would like to retrieve the PC value from before the hard fault and store it for later debugging in…
JeffV
  • 52,985
  • 32
  • 103
  • 124
5
votes
2 answers

Is it possible to modify or access Program counter?

While reading about Program counter i came to know to that The Program Counter is special in that there is no way to directly modify its value. Is there any indirect way to access/modify the content of Program Counter?
Amit Singh Tomar
  • 8,380
  • 27
  • 120
  • 199
5
votes
2 answers

Understanding the ADR instruction in ARM, and adding an offset to that

I was looking at the assembler output of my code and need help with below instructions. 0x00000fe8: e28fc000 .... ADR r12,{pc}+8 ; 0xff0 0x00000fec: e28cca08 .... ADD r12,r12,#8, 20 ; #0x8000 From my…
MS.
  • 881
  • 2
  • 9
  • 23
5
votes
3 answers

what does PC have to do with load or link address?

Link address is the address where execution of a program takes place, while load address is the address in memory where the program is actually placed. Now i'm confused what is the value in program counter? is it the load address or is it the link…
1
2 3 4 5 6 7