The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+25 votes
A machine has a $32-bit$ architecture, with $1-word$ long instructions. It has $64$ registers, each of which is $32$ bits long. It needs to support $45$ instructions, which have an immediate operand in addition to two register operands. Assuming that the immediate operand is an unsigned integer, the maximum value of the immediate operand is ____________
asked in CO & Architecture by Veteran (96.1k points)
edited by | 5k views

what do 1-word long instructions mean?

one word instruction means .. the size of instruction is one word i.e. 32 bit.

3 Answers

+51 votes
Best answer
$64$ registers means $6$ bits $(\lceil \log_2 64 \rceil = 6)$ for a register operand. So, $2$ registers operand requires $12$ bits. Now, $45$ instructions require another $6$ bits for opcode $(\lceil \log_2 45 \rceil = 6)$. So, totally $18$ bits. So, we have $32 - 18 = 14$ bits left for the immediate operand. So, the max value will be $2^{14} - 1 = 16383$ (as the operand is unsigned we do not need a sign bit and with $14$ bits we can represent from 0 to $2^{14} -1$)
answered by Veteran (406k points)
edited by
Mode Opcode Operand

Assuming this is the Instruction format why is mode bit not used ?
as in 
1 bit for Mode 
then 6 bit for Opcode 
12 for Operand 
and then 13 the Operand ?


why do we need a mode bit?
TO specify the mode as in immediate mode.
Is this Concept of mine wrong ?
we don't need it and opcode can tell it.
I know this is silly but still, why 2 fields for operands are required when for immediate addressing mode we require only 1for  opcode 1 field for register and 1 field for the immediate operand i.e. for example

Mov R ,#25h

Or else if we consider only register mode then format is like

Mov A,R

???? It appears to me as if u have combined both this modes .please correct me if i am wrong
@Arjun Sir: They never mentioned that the word size was 32bit wide, how did you get the max length of one instruction ?


It needs to support 45 instructions, which have an immediate operand in addition to two register operands


32-bit architecture, with 1-word long instructions

We dont need any mode bit. This simple instruction would look like below -

Opcode(6bit), Reg_Operand1(6bit), Reg_Operand2(6bit), Immediate Operand(14 bit)

sir if we had to show sing bit then it would be (213-1 ) ,(-1 because we represent instr 0 to 31), is im thinking correct?  ,

yes, but we also need to know how signed number is represented then (sign-magnitude, 2's complement etc)
Mr. @Arjun please tell me what does this line "...It needs to support 45 instructions which have an immediate operand..." mean? Does it mean:

that the processor supports 45 different kinds of instructions and each instruction has one immediate operand,

or there are 45 instructions inside a single opcode? (never heard of it, but idk if that can happen),

or is the instruction 45 bits long,

 or something else?
@habedo007 it means there are 45 different kinds of instruction but to even refer any one of them we need 6 bits.
Why we are taking log on the number of registers to get the size of each register?

 It has 64 registers, each of which is 32 bits long

what that $32$ bits long means? Is it mean instruction size $32$ bits or register size 32 bits? 

Hi! After we have allocated 12 bits for registers, we are left with 20 bits and we need to represent 45 opcodes and unsigned int with them. Why can't we we say the answer is pow(2,20) - 45? Can opcode and int. Not share the bits?

It will be very helpful if someone clarifies this.

@subho16 I have the same confusion. In @Arjun sir used as many bits as possible, we can do the same here and increase the range. Why was this not done? Is it because it is not clear how the value of the immediate will be interpreted?

Another example:

Each of the $45$ instructions must support $n$ bit immediate operand -- it must be able to use all immediate operand variants from $0$ to $2^n-1.$ Now when we use $6$ bits for $45$ opcodes, we are losing some encodings -- but even if we use them can we increase the range of the immediate operand?

but even if we use them can we increase the range of the immediate operand?

Thanks, I got it. Even if we were to use the lost encodings, not every opcode would be able to use the range increased above 2^n -1.

Here is one such encoding that uses expanded opcode:

0-5 : first register operand

6-11: second register operand

Bits after 11:

  1. For the first 32 opcodes: 6 bits needed ( the format is 0 _ _ _ _ _ ), 14 bits left for immediate value
  2. For the next 8 opcodes:  5 bits needed (1 0 _ _ _ ), 15 bits for immediate value
  3. For next 4 opcodes: 5 bits needed (1 1 0 _ _ ), 15 bits for immediate value
  4. For the last opcode : 3 bits needed (1 1 1), 17 bits immediate value.

So for just one opcode we will get immediate value range of 0 to 2^17-1.

Clearly, not every opcode gets equal range of immediate value. The question never said that all opcodes need equal range for immediate value, but I think it is valid to assume that immediate operands should have same range across all opcodes if nothing else is specified. is this correct?

+3 votes
Instruction 32 bit = (6+6+6+14) bit 
⌈log45⌉=6 bit opcode R1 ⌈log64⌉=6 bit R2 ⌈log64⌉=6 bit remaining 14 bit oprand

It needs to support 45 instructions,   means types of instruction supported is of45 

answered by Active (1.1k points)
how to know operand are 6 bit means register are 64 bit so what are relation between register and operand size .?

Instruction size if of 32 bits.

according to given information here we have 2 different types oprands and one opcode.

so first find register mode oprand bits, how -> given total 64 rigesters, take log(64)=6

now find opcode field bits, how -> given 45 types of instructions, take ceil{log(45)}=6

now find  immediate operand field bits, how -> total bits- other field bits

                                                                  = 32 - (6+6+6)    (2 times 6 bcz two register oprands given)

                                                                   = 14

*note: base of log is 2.

@mint why here we left other remaining bits for 45 instrustions means from 2^6=64

45 will b in use so some will left ...why we not use them ?
0 votes

1 Word = 32 bits

Each instruction has 32 bits

To support 45 instructions, opcode must contain 6-bits

Register operand1 requires 6 bits, since the total registers
are 64.

Register operand 2 also requires 6 bits.

14-bits are left over for immediate Operand Using 14-bits,
we can give maximum 16383,

Since 2^14=16384(from 0 to 16383) 

answered by Loyal (9.3k points)

Regina Phalange

if the immediate operand is a signed integer, then the maximum value of the immediate operand is....?? 

-2n-1  to (2n-1 -1)....???? 


(-2n-1 -1)  to (2n-1 -1)....???


-2n-1  to (2n-1 -1)

okk.. :) means we use 2's complement here to represent signed integer...
yes, as per my knowledge but i m not 100% sure, can you tag someone who can verify it?

let me make u 100% sure.. :) I just go through this fact right now and sharing with you also...

  1. Unsigned: It consist only positive value i.e 0 to 255.

  2. Signed: It consist both negative and positive values but in different formats like

    • -1 to -128
    • 0 to +127

And this all explanation is about 8 bit number system.


Thank You :)

signed = -(-2n-1 -1)  to (2n-1 -1).

2's complement = 2n-1  to (2n-1 -1)

1's complement = (-2n-1 -1)  to (2n-1 -1).

unsigned = (0)  to (2n -1).

Had it been 2-word long instruction ,the instruction length would be 64-bit long ?


@HeadShot Yes. Then the no. of bits for operand would increase.


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,541 questions
54,094 answers
71,001 users