in CO and Architecture edited by
20,907 views
67 votes
67 votes
Consider a processor with $64$ registers and an instruction set of size twelve. Each instruction has five distinct fields, namely, opcode, two source register identifiers, one destination register identifier, and twelve-bit immediate value. Each instruction must be stored in memory in a byte-aligned fashion. If a program has $100$ instructions, the amount of memory (in bytes) consumed by the program text is _________.
in CO and Architecture edited by
20.9k views

1 comment

If instead of byte aligned it tells that it is bit aligned,then what will be the programe size??@neelesh_007
0
0

4 Answers

115 votes
115 votes
Best answer

Answer: 500 bytes

Number of registers $= 64$

Number of bits to address register $=\left \lceil \log_{2}64 \right \rceil= 6-\text{bits}$

Number of Instructions $= 12$

Opcode size $=\left \lceil \log_{2}12 \right \rceil = 4$

\begin{array}{|c|c|c|c|} \hline \text {Opcode$(4)$} &  \text{ reg1$(6)$}& \text{reg2$(6)$} & \text{reg3$(6)$} & \text{Immediate$(12)$}  \\\hline \end{array}

 

Total bits per instruction $= 34$

Total bytes per instruction $= 4.25$

Due to byte alignment we cannot store $4.25 \text{ bytes},$ without wasting $0.75\;\text{ bytes.}$

So, total bytes per instruction $= 5$

Total number of instructions $= 100$

Total size $=$ Number of instructions $\times$ Size of an instruction

$\qquad =100\times 5= 500 \text{ bytes}$

edited by

4 Comments

@neelesh_007 

 

34 is the number of bits which is required for single instruction and to store it in the computer it should be stored in the byte alignment fashion that is why we  have divided  by 8 to convert into bytes.

If you have confusion please refer alignment concepts

0
0

If question just says it is byte addressable then we take 34 bits = 5 byte or 34 bits = 4.25 byte ??

0
0

@sanjaysharmarose if not said also you need to consider Byte Addressable

0
0
16 votes
16 votes
Each instruction needs 34 bits. Question is asking for byte alignment, so, every instruction will need 40 bits (5 bytes).

So, total 5B x 100 = 500 Bytes will be needed.
5 votes
5 votes

Here is a similar answer but a brief description of byte aligned memory

Number of registers =64

Number of bits to address register =⌈log264⌉=6 bits

Number of Instructions =12

Opcode size =⌈log212⌉=4

So,

opcode, sreg1, sreg2, dreg, #immediate = 4, 6, 6, 6, 12

Just to shed some light on how the 34 bits will be stored in the memory.

In a byte-aligned fashion, an instruction is stored byte by byte, such as :

----> 1st Byte

----> 2nd Byte

----> 3rd Byte

----> 4th Byte

----> remaining 2 bits of the instruction (it will occupy the whole byte space)

So finally the total bytes required by 100 instructions = (5 x 100) = 500 Bytes

3 votes
3 votes

Answer : 500

No. of bits to address 64 registers = ⌈log2 64⌉ = 6

No. of instructions = 12

No. of bits in opcode = ⌈log2 12⌉ = 4

4 (opcode) 6   (src. reg1) 6    (src. reg2) 6 (dest.reg) 12   (imm.)

 

No. of bits required = 4 + (3*6) +12 = 34 bits

No. of bytes required = $\frac{34}{8}$ = 4.25 Bytes

We can't use 4.25 Bytes because memory is in Byte alligned . so , you have to complete each Bytes  .

So, take ⌈4.25⌉ = 5 Bytes

Amount of memory (in bytes) consumed by the program text of 100 instructions = 5 * 100 = 500 Bytes

 

 

edited by
Answer:

Related questions