Skip to content
Tactiverge
  1. Stage 1
  2. Stage 2
  3. Stage 3
  4. Stage 4
  5. Stage 5
  6. Stage 6
  7. Stage 7
  8. Stage 8
  9. Stage 9
  10. Stage 10
  11. Stage 11
  12. Stage 12 (this one)
  13. Stage 13
  14. Stage 14
  15. Stage 15

Explanation

An instruction is just a number in memory. In Bench-8 every instruction is two bytes: the top four bits of the first byte are the opcode (16 possible instructions) and the second byte is the operand, a number or an address.

The decoder turns the opcode into control signals: which register loads, what the ALU does, whether memory is read or written, whether the program counter jumps. Change the opcode and different wires light up.

Feed the decoder an instruction

Byte 1 = 0x40: opcode 4 (top four bits)

Byte 2 = operand 16

ADD 16

A ← A + M[16]. Add the byte at a to A (8-bit wraparound, C = carry out).

  • ● ADDR←OPR
  • ● MEM_RD
  • ○ MEM_WR
  • ● ALU_ADD
  • ○ ALU_SUB
  • ○ ALU_AND
  • ○ ALU_OR
  • ○ ALU_XOR
  • ○ ALU_NOT
  • ○ ALU_PASS
  • ● A_LOAD
  • ● FLAGS_LOAD
  • ○ PC_LOAD
  • ○ PC_LOAD_IF_Z
  • ○ PC_LOAD_IF_C
  • ○ IN_RD
  • ○ OUT_WR
  • ○ HALT

ADD: lines ADDR←OPR, MEM_RD, ALU_ADD, A_LOAD, FLAGS_LOAD

Check yourself

Marked instantly in your browser. Use the interactive above to work it out.

  1. 1. How many different opcodes fit in 4 bits?
  2. 2. Bench-8 byte 0x42 is followed by 0x10. What does it do?