Most Tiny8 instructions name an address, and the CPU reads the operand from memory. An immediate operand is different: the value is inside the instruction word itself. LDI k (load immediate) puts the number k straight into the ACC.
The course builds LDI as an extension, using the spare opcode 7, so 7k means LDI k. Adding it follows the usual recipe:
- RTN: after fetch and decode, E1:
ACC ← IR[3:0], with four 0s added on top to make 8 bits. Z loads with the ACC. - Datapath: there's no path from IR[3:0] to the ACC, so the ACC's mux gets a third input. A 3-input mux needs a 2-bit select, so
ACCsrcbecomes two bits. - Control: one execute step, so LDI goes from E1 straight back to F1.
LdACCgains an "E1 and LDI" term.
LDI takes 5 cycles, one fewer than LOAD, and saves storing small constants in memory. The cost: k is only 4 bits, so it can only load 0 to 15.