Homework 2 — MIPS Assembly Language Programming I will provide a set of macros to help with the system calls in this project. You may use any defined pseudoinstructions that are known to the MARS simulator. Each part should be in a separate file and should be named as question1.asm, question2.asm, etc. Your name should be given in a comment or comments at the top of each assembly language file.
1. Write an MIPS assembly language program that will perform the following assignment statement and output the value of R to the console. R = B * B – 4 * A * C; You are to assume that A, B, C, and R are variables, A, B, and C hold valid values, all variables and values are integers, and that you do not need to consider overflow. A skeleton for the program is given below: # your name should be here… .data
A: .word 4
B: .word 6
C: .word 2
R: .word 0
.text
start:
exit:
li $a0, 10
syscall
2. Write a MIPS assembly language program that will implement the following if statement. Again, all variables are integers. Assume variables are initialized. Output should be done to the console using system calls. if (a != b) {
value = c / (a – b);
} else {
value = 0;
}
cout << value;
3. Implement the following for loop using MIPS assembly language.
int i, j, k, temp;
j = 1;
k = 1;
for ( i = 0; i < 10; i++) {
cout << j << endl;
temp = j;
j = j + k;
k = temp;
} You may choose to store i, j, k and temp either in registers or in memory locations. Note: endl goes to a new line. You will need to output a string with a carriage return linefeed to do this.
endl: .asciiz ”/10/13 ​” 4. Write a MIPS assembly language program to input 3 integers and output the maximum
value and the minimum value to the console.
5. Write a MIPS assembly language program with a subroutine that takes 4 arguments for A, B, C, and X and computes the result of
A * X * X + B * X + C And returns the value to the calling program. Your main program must call the subprogram supplying it with 4 values for A, B, C, and X and output the result to the console.

Open chat
Lets chat on via WhatsApp
Hello, Welcome to our WhatsApp support. Reply to this message to start a chat.