0

The CALL instruction, requires 5 machine cycles, namely, OPCODE-FETCH, MEMORY READ, MEMORY READ, MEMORY WRITE, MEMORY WRITE. The OPCODE-FETCH cycle of CALL has 6 T-states to take care of the decrements of the Stack Pointer.

RET instruction requires, 3 machine cycles, OPCODE-FETCH, MEMORY READ, MEMORY READ, even here, the microprocessor's got to increment the stack pointer twice, as before, to pop. But, the OPCODE-FETCH cycle only has 4 T-states, Why is that?

I've got a vague idea, as to why; in CALL and PUSH the SP has to be decremented first, unlike RET or POP. This first decrement alone is taken care in the last two T-states of FETCH cycle. But why would that require two T-states. Again, I'm really not sure about this. Kindly help.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Documentation to explain what's happening in each T cycle isn't easy to find. But incrementing/decrementing the stack pointer isn't the only thing going on. My guess is that CALL is special because the value of the PC needs end up on the stack _and_ also be reset to the branch address. It's likely the extra states are there because those operations share a bus and so must be sequential. For RET, the value from the stack just goes to the PC. It's a simpler operation. – Gene Nov 06 '19 at 05:23
  • @Gene Yeah, I agree, I also, couldn't find anything. "value of the PC needs end up on the stack" Isn't that why `CALL` two separate machine cycles ? – Aravindh Vasu Nov 06 '19 at 05:44
  • `ret` is shorter, right? Just a single-byte opcode instead of also taking an immediate displacement, same as in 8086? Or do the "memory read" machine cycles account for fetching the operand? – Peter Cordes Nov 06 '19 at 06:02
  • @PeterCordes Yeah, it's is shorter, sorry I haven't learnt 8086 yet. I don't understand the last sentence, It has 2 Memory Reads to place the data pointed SP in PC right? – Aravindh Vasu Nov 06 '19 at 06:10
  • Sorry, I meant the memory read cycles for `call 16-bit-target`. That's part of decoding to fetch the target address after seeing the `call` opcode I assume. Other than that `call` doesn't need to read memory. – Peter Cordes Nov 06 '19 at 06:13
  • You might consider asking this on https://retrocomputing.stackexchange.com/ – Erik Eidt Nov 06 '19 at 15:43
  • this is a duplicate and already answered [here](https://electronics.stackexchange.com/questions/466032/8085-why-ret-doesnt-require-a-6-t-states-fetch-cycle) – codeR Jun 18 '21 at 08:02

0 Answers0