Purpose
Gain familiarity with MIPS ISA control structures and the $hi and $lo registers.
Tasks
Use the following registers to store the values of these variables:
$a0 a
$a1 b
$s0 c
$s1 x
$s2 y
Variables initialization
1.a = 0x8000;#MIPS instruction:ori $a0, $0, 0x8000 2.b = 0x00A9;
3.c = 1974;
Arithmetic computation
x = a * a;
store the value of x to memory location at address 0x20;
y = x * b;
store the value of y to memory location at address 0x24; 8.y = y >> 16;
9.c = (c + y / c) / 2;
10. store the value of c to memory location at address 0x2C;
While loop
11. while(c >= 1665){
12.c = (c + y / c) / 2;
13. }
14. c = c << 8;15. store the value of c to memory location at 0x30;Use no more than 28 real MIPS instructions.Assemble your MIPS assembly code and single-step execute through all instructions. After the execution of each instruction, verify the contents of the relevant registers. Record the execution results using the test log table on page 3 of the assignment, and note the value at the following memory addresses when the program execution has completed:0x20 0x23;0x24 0x27;0x28 0x2b;0x2c 0x2f;0x30 0x33;Write a MIPS assembly program to calculate the factorial of a given integer n. The factorial of n is defined asn! = n*(n-1)**1 Note that 0! = 1.Algorithm for computing factorial:1. INPUT n = 5; //given number n 2. f = 1;while (n > 1)
{
f = f * n; n = n 1;
}
OUTPUT f; //factorial f = n!
Requirements:
Input number n = 5, to be stored in memory location at address 0x00.
The assembly program shall contain no more than 11 real MIPS instructions.
You must use the algorithm shown above.
3.
4.
5.The factorial of 5 must be written to the memory location at address 0x10.
Assemble the MIPS assembly code, single-step execute through each instruction and verify the contents of the relevant registers after each instructions execution. Record the execution results using the test log table on page 4, and indicate the value at the following memory addresses when the entire program is executed:
0x00 0x03;
0x10 0x13;
Reviews
There are no reviews yet.