Assignment Solution Week2
Assignment Solution Week2
Assignment Solution Week2
5. Which of the following are true for n-bit sign number representation?
a. The minimum and maximum number that can be represented in
sign magnitude is – (2n-1 - 1) and + (2n-1 - 1)
b. The minimum and maximum number that can be represented in
one’s complement is – 2n-1 and + (2n-1 - 1)
c. The minimum and maximum number that can be represented in
two’s complement is – 2n-1 and + (2n-1 - 1)
d. None of the above
Solution: ((a) and (c)) Follows from the definition of sign magnitude, 1’s
complement and 2’s complement representations. For 1’s complement,
the smallest number is – (2n-1 - 1) .
10. Consider a processor with 64 registers and an instruction set of size 12.
Each instruction has 5 distinct fields, namely opcode, two-source register
identifiers, one destination register identifier, and a 12-bit immediate
value. Each instruction must be stored in memory in a byte-aligned
fashion (i.e. from an address that is a multiple of 4). If a program has 100
instructions, the amount of memory consumed by the program is 800
bytes.
Solution: Each instruction has 5 distinct fields:
Opcode, Register1, Register2, Register3, 12-bit immediate value
Total instructions = 12; hence it requires 4 bits
Total registers = 64; hence 6 bits are required to specify the register.
Immediate value = 12-bits
Total length of an instruction: 4 + 6 + 6 + 6 + 12 = 34 bits, i.e. slightly
more than 4 bytes.
Hence each instruction will require 8 bytes to make it byte aligned. Hence
800 bytes will be required.
11. For a computer based on 3-address instruction formats, each address field
is used to specify which of the following?
(S1) A memory operand
(S2) A processor register
(S3) An implied accumulator register
a. Either S1 or S2
b. Either S2 or S3
c. Only S2 and S3
d. All of S1, S2 and S3
Solution: (a) An address can specify either a memory operand or a
processor register. We do not refer to an implied operand by an address.
12. Which of the following statements are false for MIPS 32 register set?
a. Register R0 always contains the value 0.
b. Any register other than R0 can be used for register indirect
addressing.
c. Any register other than R0 can be used to hold the return address
for function calls.
d. R31 is a special register used as stack pointer.
Solution: ((c) and (d)) Only R31 can be used to store the return address.
There is no specific register designated as the stack pointer.
13. The MIPS code for A = B+C where B is loaded in register $S2 and C is
loaded in register $S3 is
a. ADD $S1, $S2, $S3
b. ADDI $S3, $S2, $S1
c. ADD $S3, $S2, $S1
d. None of the above
Solution: (a) The content of registers $S2 and $S3 are added and stored in
register $S1.
14. In MIPS32, to fetch a 32-bit word from memory in a single cycle, the word
has to be stored from memory location:
a. 0018H
b. 0019H
c. 001AH
d. 001BH
Solution: (a) For fetching a word in a single cycle it should be fetched from
a memory location which is multiple of 4; and hence here it will be 0018H.