2

In the Intel 8085 microprocessor, precisely at what point (t state) does the program counter get updated? Is it just after t1 (i.e., just when the current address in the PC is placed on the address bus) or at t3, when the instruction fetch is being done?

Also, when a hlt instruction is encountered, what happens to the state of the program counter? Does it get incremented or does it contain the address of the current hlt instruction?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847

2 Answers2

1

Similar question has been asked at this.

Usually in the first clock cycle the current value of the PC is loaded into the address buffer, and next 2 clock cycles fetches the instruction opcode at that address.

During this time the 16-bit PC is updated by the incrementer while the opcode is being fetched into the IR. So PC is already incremented before the 8085 can even decode and realize that the instruction is HLT.

codeR
  • 165
  • 1
  • 1
  • 13
1

HLT works as a "wait for next interrupt" instruction. If you want to halt forever, you have to put HLT in a loop, or disable interrupts. So the saved interrupt-return address that's software visible inside the interrupt is the byte after HLT.

This is what happens on 8086 / x86, and 8080 is asm source compatible. Also, having the interrupt return address point at HLT would mean it would run again after an interrupt handler returned normally. Using it as anything other than a "only run interrupt handlers from now on" would mean that all your interrupt handlers would have to check what the saved PC was pointing to, and if so increment it before return. Instead, to get that behaviour you put HLT in a loop at the one place you want that.

As codeR explains, PC has already been incremented before HLT sleeps, not at the last moment when waking up to handle an interrupt.

codeR
  • 165
  • 1
  • 1
  • 13
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • This provides the intution behind the choice that, `PC` needs to be incremented before an instruction is decoded and excuted. – codeR Jun 25 '21 at 15:13