# A processor has 32 registers, uses 16-bit immediates, and has 56 instr

#### jay2

##### Distinguished
Hi guys, I'm a uni student doing a course, I've got 3 Q's about ISA, opcodes and Bit

A processor has 32 registers, uses 16-bit immediates, and has 56 instructions
(corresponding to 56 operation codes) in its ISA. In the instruction set, there are four types of instructions as listed below:
• Type A: takes one source register, uses one destination register;
• Type B: takes two source registers, uses one destination register;
• Type C: takes one source register, one immediate, uses one destination register;
• Type D: takes one immediate, uses one destination register.

Assume that the ISA requires that all instructions be a multiple of 8 bits (1 byte) in length, and the operation codes (opcodes) are of fixed length (i.e., the ISA does not use shorter opcodes for some instructions and longer opcodes for others).

Answer the following questions and write down the calculation steps involved.

a) How many bits do we need to use to encode the opcodes? (8 marks)

b) How many bytes do we need to use to encode the Type-B instruction? (10 marks)

c) How many bytes do we need to use to encode the Type-C instruction? (12 marks)

#### traken

##### Distinguished
32 registers requires 5 bits (0-31). 56 opcodes requires 6 bits (0-63).

Type A: 6 bits opcode, 5 bits register, 5 bits register = 16 bits or 2 bytes.
Type B: 6 bits opcode, 5 bits register, 5 bits register, 5 bits register = 21bits rounded up to 24bits or 3 bytes.
Type C: 6 bits opcode, 5 bits register, 16 bit immediate, 5 bits register = 32 bits or 4 bytes
Type D: 6 bits opcode, 16 bits immediate, 5 bits register = 27bits rounded up to 32 bits or 4 bytes

Well... that was fun.

Thanks dude.

#### strangestranger

##### Splendid
You'll never learn stuff if you don't do it yourself.

#### jay2

##### Distinguished
I plan to leave the course, I don't like it.

#### cjl

##### Splendid
That's pretty hard to do unless your university is MUCH more lax with drop deadlines than any I'm familiar with.

#### jay2

##### Distinguished
Yeah, I got 5 weeks and we're going to do workshops on it all, but I've got 4 other assigments on the go, I'm quite computer savvy so planning to 'blast through' them all.

#### jay2

##### Distinguished
Ok, I can't edit, I was going to say there's only 3 questions.

#### jsc

##### Champion

You mean, we are going to 'blast through' them all.

This is the second homework question that you have asked us to do.

G

#### Guest

##### Guest
can anyone explain the answers to the question? I can't get my head around it. even though i read plenty of chapters on ISA.