Search code examples
instruction-setmicroprocessors

8 Register Machine with 4 2-operand instructions in 8-bit format


I'm studying Microprocessors and interfacing at uni and I've come across a very difficult question to get my head around.

"Can you design an 8-bit instruction format that cal allow 4 2-operand instructions for a machine with 8 registers"

I'm not 100% sure what it's asking, a point in the right direction would be greatly appreciated.

Note: The course is based around learning assembler on an AVR board (if it helps).


Solution

  • It's basically asking whether you can encode any of four different instructions, each with two register operands, into 8 bits (per instruction).

    The answer would be yes. Simply count the number of possible operations: 4 instructions * 8 possible first registers * 8 possible second registers = 256; you can represent 256 possible values with 8 bits, so it must be possible to encode each of the 256 possible operations as a single 8-bit value.