edited by
21,578 views
68 votes
68 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

14.0k
views
5 answers
29 votes
Akash Kanase asked Feb 12, 2016
14,001 views
A processor has $40$ distinct instruction and $24$ general purpose registers. A $32$-bit instruction word has an opcode, two registers operands and ... operand. The number of bits available for the immediate operand field is_______.
18.9k
views
6 answers
49 votes
go_editor asked Sep 26, 2014
18,904 views
A machine has a $32\text{-bit}$ architecture, with $1\text{-word}$ long instructions. It has $64$ registers, each of which is $32$ ... immediate operand is an unsigned integer, the maximum value of the immediate operand is ____________
13.5k
views
4 answers
44 votes
Kathleen asked Sep 12, 2014
13,477 views
In an $11$-bit computer instruction format, the size of address field is $4$-bits. The computer uses expanding OP code technique and has $5$ ... one-address instructions. The number of zero-address instructions it can support is ________
4.9k
views
2 answers
22 votes
Kathleen asked Oct 4, 2014
4,945 views
State True or False with one line explanationExpanding opcode instruction formats are commonly employed in RISC. (Reduced Instruction Set Computers) machines.