Binary codes for instructions - give binary codes of the


Problem 1- MIPS Arithmetics

Perform the following arithmetic operations by giving MIPS code:
1. a = b + c
2. a = b - c + d
3. a = 8 · b
4. a = (2 + b) · 4

Please assume that a is in register $t0, b in register $s0, c is in register $s1 and d is in $s2.. Keep in mind that you do not know the mul operation yet.

Problem 2- Binary codes for instructions

Give binary codes of the MIPS instructions for the operations 1 and 2 of the previous problems.

Problem 3- Memory access in MIPS

Suppose you write the following C code:

B[5] = A[2] + A[3]

1. Please write down the MIPS assembler code for this code. Assume that the address of base of A is stored in $s0, the base of B is stored in $s1.

Problem 4- Memory access using a variable index

Suppose you write the following C code:

B[x] = A[x + 2] + A[x + 3]

1. Please write down the MIPS assembler code for this code. Assume that the address of base of A is stored in $s0, the base of B is stored in $s1 and the value of x in $t0

Problem 5- MIPS Instruction format I (1 point)

The register instruction format for the instruction addi uses 6 bits for the opcode, 5 bits for the first register, 5 bits for the second register. and 16 bits for the constant value that is to be added. A detailed analysis of machine code has revealed that not more than 12 registers are needed for the processor and therefore it has been decided to reduce the number of general purpose registers
to 16.

How and why could the instruction format for the addi instruction be changed?

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Binary codes for instructions - give binary codes of the
Reference No:- TGS01189729

Now Priced at $30 (50% Discount)

Recommended (97%)

Rated (4.9/5)