edited by
20,867 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 _________.
edited by

4 Answers

Best answer
115 votes
115 votes

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
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

29 votes
29 votes
5 answers
1
22 votes
22 votes
2 answers
4
Kathleen asked Oct 4, 2014
4,687 views
State True or False with one line explanationExpanding opcode instruction formats are commonly employed in RISC. (Reduced Instruction Set Computers) machines.