Question

In: Computer Science

I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...

I have to do the following MIPS coding assignment.

Question 1

Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction):

  1. Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction
  2. Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction
  3. Performs the bitwise AND operation on the operands stored in register 13 and 17 and stores the result in register 8
  4. Performs an immediate bitwise OR operation on the value stored in register 8 and the hexidecimal equivalent of 33310and store the result in register 9

Hint: You should only need to add 4 lines of assembly language to the starter program (one for each listed instruction above)

Question 2

  1. Place 410 into register $t0
  2. Perform an add of register $t0 and 3216 and store result to register $t1
  3. Subtract register $t1 from $t0 and store the result in register $t3
  4. Complement the bits of register $t3 and store result in register $t3
  5. Put the result of register $t3 into register $t4
  6. Left shift the value in register $t4 by 4 and place result in register $t3

Hint: Be sure to end your program properly

Solutions

Expert Solution

Geetings!!

Q1.

Code:

.text
main:

ori $13,$0,237      #bitwise or operation for loading 237 into register 13
ori $17,$0,1834   #bitwise or operarion for loading 1834 into register 17
and $8,$13,$17   #bitwise and operation on contents of registers 13 and 17 and store the result into register 8
ori $9,$8,333        #bitwise or operaiton on the value stored at register 8 with 333 and store the result to register 9

li $2,10                 #load parameter for terminating the execution using system calls
syscall          #make system call

Output screenshots:

After ori $13,$0,237

After ori $17,$0,1834

After and $8,$13,$17

After ori $9,$8,333

Q2.

Code:

.text
main:
li $t0,4       #load 4 to t0
addi $t1,$t0,0x32   #add 0x32 to 4 and store the result in t1
sub $t3,$t0,$t1       #subtract t1 from t0 and store the result in t3
xori $t3,$t3,0xFFFFFFFF   #invert all the bits of t3 and store the result in t3
move $t4,$t3          #copy the answer of t3 to t4
sll $t3,$t4,4          #shift left the content of t4 by 4 bits and store the result in t3

li $v0,10
syscall

Output screenshots:

After li $t0,4

After addi $t1,$t0,0x32

After sub $t3,$t0,$t1   

After xori $t3,$t3,0xFFFFFFFF

After move $t4,$t3

After sll $t3,$t4,4

Hope this helps


Related Solutions

Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
How do I write a program in MIPS that will change all the characters in a...
How do I write a program in MIPS that will change all the characters in a string into lowercase. For instance: string: " CANBERRA AUSTRALIA" Output: "canberra australia"
Assembly Language Coding Using MARS (MIPS) 1)Write a program that prints your name in a Triangle....
Assembly Language Coding Using MARS (MIPS) 1)Write a program that prints your name in a Triangle. (NAME = John Doe) 2)Write a Program that intializes X to 10, Y to 20 and Z to -50, adds X and Y and Z and prints the following the value of each variable, for example value of x is 10 as well as the result of the addition.
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays the sum and the difference. In the .data section, define two variables num1 and num2 both words. Initialize num1 to 92413 10 and num2 to D4B 16 (use 0xD4B to initialize, Note that D4B is a hexadecimal number). Your main procedure/function should load the values of num1 and num2 into two temporary registers, and display them on the console window. Then add the values...
How can I write a simple MIPS program to print out the following elements of an...
How can I write a simple MIPS program to print out the following elements of an array of the size of 10: 5,10,15,20,25,30,35,40,45,50
For this assignment, you are required to write a MIPS program that reads its own instructions...
For this assignment, you are required to write a MIPS program that reads its own instructions and counts the number of occurrences of each type of instruction (R-type, I-type, or J-type). To accomplish this task, your program should execute the following steps: First, your program should load the address of its first instruction (0x400000) into a register, and initialize three separate instruction class counters to zero. Next, your program should enter a loop that reads each instruction from memory. For...
For Project 2, write a program for MIPS that performs the following steps. It 1. Receives...
For Project 2, write a program for MIPS that performs the following steps. It 1. Receives a string of upper- and/or lowercase letters from keyboard (user types the letters on the SPIM console window). 2. Stores ASCII codes of the letters in stack. 3. Stop receiving letters when ? is typed by the user. 4. Converts uppercase letters to their lowercase letters and vice versa, and prints the converted string on the SPIM console window. Assume only valid inputs are...
Programming assignment 4 : C++ Write a program to do the following: 1.Define a structure to...
Programming assignment 4 : C++ Write a program to do the following: 1.Define a structure to store a date, which includes day(int), month(int), and year(int). 2.Define a structure to store an address, which includes address(house number and street)(string), city(string), state(string), zip code (string). 3.Define a class to store the following information about a student. It should include private member variables: name(string), ID (int), date of birth (the first structure), address (the second structure), total credit earned (int), and GPA (double)....
I need specific codes for this C program assignment. Thank you! C program question: Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT