World's most popular travel blog for travel bloggers.

# [Solved]: Counting the number of instructions in an instruction set

, ,
Problem Detail:

An imaginary processor has the following hardware specification:

• 8bit data bus
• 32 × 8bit general purpose registers e.g. `S0``S1F`

Briefly describe what bit fields are required within an instruction to encode the following functionality:

1. 56 different instructions
2. Register addressing e.g. `ADD S0, S1`, add the contents of register `S1` to register `S0`, store the result in register `S0`.
3. Immediate addressing e.g. `ADDI S0, 10`, add the constant 10 (base 16) to register `S0`, store the result in register `S0`.
4. Absolute addressing e.g. `ADDA S0, 100`, add the data stored in external memory address 100 (base 16) to register `S0`, store the result in register `S0`
5. If the processor uses a fixed length instruction format, briefly describe how many bits are required to represent an instruction and the bit fields used.

For (1), I know it's \$\log_2 56\$ round up to 6 bits but for (2), I know the answer is 6bits+5bits+5bits, but I can't figure out why.

#### Answered By : Ran G.

An "add" instruction (e.g., ADD S0 S1B) must have 3 parts of information:

1. which instruction to do ("ADD")
2. Which is the input register (S0)
3. Which is the output register (S1B)

How many bits does each part take? Well, you correctly answered that the first part is 6 bit. Can you see why the second and third parts take 5 bits each?

For the other parts of the question, try to split to the information the instruction must have, and analyze the amount of bits each part takes, under the definitions of the specific machine in use.