Electronic – 8085; Why RET doesn’t require a 6 T-states Fetch cycle

8085assemblymicrocontrollermicroprocessor

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.

Best Answer

It would be insightful to analyse CALL instruction once more before talking about RET instruction.

CALL INSTRUCTION IN 8085

As you stated, it consists of: Opcode Fetch, Memory Read, Memory Read, Memory Write, Memory Write

8085 follows decrement and push methodology while pushing to stack.

Opcode Fetch in 8085 is typically 4 T states. However for CALL instruction, it takes 2 additional T states. It is because - After the fetch and decode, the stack pointer has to be decremented ahead of the first Memory Write cycle that will store the current PC's MSB to the stack.

During the first Memory Write, the value is pushed and the stack pointer is decremented again by the processor. This is done in parallel, so that next Memory Write cycle can begin immediately without losing additional T states. In the second Memory Write, PC's LSB is pushed to the stack, but the stack pointer need not be decremented as there are no further writes coming.

Memory Read cycle is where the branching address is stored in WZ internal registers.

Each Memory Write is 3 T states and each Memory Read is 3 T states as well.

So total T states = 4 + 2 + 3 + 3 + 3 + 3 = 18

RET INSTRUCTION IN 8085

It consists of: Opcode Fetch, Memory Read, Memory Read

Again, Opcode Fetch is 4 T states. However 8085 follows pop and increment methodology while popping from stack. The stack pointer is already pointing to the LSB of the return address, so there is no need to increment the pointer beforehand.

During the first Memory Read, the pointed value is read, and the stack pointer is incremented by the processor as well in parallel. During the next Memory Read, the MSB of the return address is read and the stack pointer is again incremented in parallel.

So total T states = 4 + 3 + 3 = 10

So in RET, there are no additional T states needed after Opcode Fetch unlike in CALL.