STORE a (Tiny8 opcode 2) writes the accumulator into memory word a: M[a] ← ACC. The ACC keeps its value.
Its execute steps:
- E1
MDR ← ACC: the MDR's mux picks the ACC (MDRsrc= 1), andLdMDR= 1. - E2
M[MAR] ← MDR:Write= 1. The MAR already holds a.
The write can't happen in E1, because the MDR only receives the ACC's value at E1's edge. So STORE takes 6 cycles, like LOAD.
Two things STORE doesn't do:
- It doesn't change the ACC.
- It doesn't change the zero flag, even if the stored value is 0. Z still reflects the last LOAD, ADD or SUB.
Because program and data share memory, a STORE can overwrite an instruction. That's self modifying code.