I have a instruction: ADD [BX][SI] + 5FFDH, EABFH
and I want to know how it operates exactly on 8086 microprocessors. I've realized that this instruction ADD [BX][SI] + 5FFDH, EABFH
, works in this manner:
BX + SI
BX + SI
goes to ALU's input.5FFDH
pop from instruction queue and goes to ALU's input.BX + SI + 5FFDH
.BX + SI + 5FFDH
goes to memory through address bus.BX + SI + 5FFDH
's value comes from memory and goes to ALU's input.EABFH
pop from instruction queue and goes to ALU's input.[BX + SI + 5FFDH] + EABFH
calculates by ALU.So my question is on step 13. How microprocessor knows that memory address (BX + SI + 5FFDH
) to send [BX + SI + 5FFDH] + EABFH
's value to memory according to empty instruction queue and we cannot calculate BX + SI + 5FFDH
again.
8086 almost certainly has some internal tmp storage that its microcode can use to store the result of address calculation for RMW instructions. It's not exactly pipelined the way MIPS was! (But IIRC, you're right that it used the ALU for address calculation, not having a dedicated AGU).
In theory nothing's stopping it from re-calculating the address, but keeping around the address is much more sensible than keeping around the original instruction bytes.
Keep in mind that 8086 was driven by microcode, kind of like an interpreter that implements x86 using its internal resources. So the temporary storage would just be like a register other than the architectural registers that are visible to 8086 instructions.
In this case, one might imagine that there was some circuitry for data accesses to send addresses to the bus interface unit, competing with code-fetch. It's totally plausible that some address register in the data side of things could simply hold the last data address that was used, even if code-fetch reads from a different address in between.
If you're really curious about full details, see if http://www.righto.com/2020/08/reverse-engineering-8086s.html (Ken Shirriff's blog) has gotten to how microcode handles memory-destination ALU instructions.
BTW, you forgot the DS segment-base address as part of the address calculation.