Ravi
Ravi

Reputation: 622

How does program counter in 8085 actually work?

I have been reading about Program Counter of 8085. This material here states that the function of the program counter is to point to the memory address from which the next byte is to be fetched. When a byte (machine code) is being fetched, the program counter is incremented by one to point to the next memory location. My question is how does it handle the condition if instruction size varies. Suppose the current instruction is of 3 bytes then PC should point to current address+3. How does PC knows the size of the current instruction? I am new to 8085, any help would be appreciated. Thanks

Upvotes: 0

Views: 1586

Answers (1)

The material you reference doesn't really say anything about that issue specifically - all it says is that the PC is incremented when a byte is fetched, which is correct (it doesn't say that there couldn't be multiple bytes to an instruction).

In general, a CPU will increment the program counter to point to the next instruction.

More precisely, during the instruction decoding phase, the CPU will read as many bytes as are needed for the instruction and increment the PC accordingly.

Upvotes: 2

Related Questions