Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3 (Coding Question: submit your MIPS program). Write a program in the MIPS assem

ID: 3912245 • Letter: 3

Question

3 (Coding Question: submit your MIPS program). Write a program in the MIPS assembly language that reads the integers 4, -4, 64679, and -64679, and loads them into registers Ss0 to Ss3 respectively, and then performs the following operations. Do not change values in saved registers Ss0 to Ss3. (20 pts) a. Print each above integers b. Add Ss2 and Ss3, and print the result; c. Perform logical "OR" on constant 4 and Ss3, and print the result; d. Shift Ss3 one bit left, and then print the result; 4 (Coding Question: submit your MIPS program). Implement a MIPS assembly program that processes two integer arrays of size 20 : Raw and Fresh. The Raw array is initialized with the values (2, 17, 28, 20, 6, 51, 20, 48, 12, 54, 3, 31, 15, 22, 46, 72, 41, 39, 30, 55). The values for Fresh array wil1 be read in (note: add proper prompt for reading data.) All elements of Fresh will be stored in memory The program will output (i.e. display) the sum of two largest integers and the sum of two smallest integers of Raw and store the sum of two largest integers and the sum of two smallest integers of Fresh in memory locations right after where the last element of Fresh is stored. Test the program once and enter the Fresh array's data of your choice. (40 pts) Submission Instruction for 3 and 4s: You must run the assembly program using the SPIM simulator. Please zip the following files * The assembly programs (using file extension.asm) Readme.tct (for each of the problems, you should explain how to run your program. Also, you need to provide the output in console window and the log in message window, after the programfinishes executing) and turn your zip file in blackboarad.

Explanation / Answer

# assembly1.asm-- Program

# Registers used:

# $s0 - used to hold the first number.

# $s1 - used to hold the second number.

# $s2 - used to hold the third number.

# $s3 -used to hold the fourth number.

# $v0 - syscall parameter and return value.

# $a0 - syscall parameter.

# $t0-$t4-Copy of integers in $s0-$s4

# $t5- Holds the sum of $s2 and $s3

# $t6-holds the value of constant 4

# $t7-holds bitwise shift result.

main:

## Get first number from user, put into $s0.

li $s0, 5 # load syscall read_int into $s0.

syscall # make the syscall.

move $s0, $v0 # move the number read into

## Get 2nd number from user, put into $s0.

li $s1, 5 # load syscall read_int into $s1.

syscall # make the syscall.

move $s1, $v0 # move the number read into $t1.

## Get third number from user, put into $s0.

li $s2, 5 # load syscall read_int into $s2.

syscall # make the syscall.

move $s2, $v0 # move the number read into $t2.

## Get fourth number from user, put into $s0.

li $s3, 5 # load syscall read_int into $s3.

syscall # make the syscall.

move $s3, $v0 # move the number read into $t3.

## Print out $t0.

move $a0,$t0 # move the number to print into $a0.

li $v0, 1 # load syscall print_int into $v0.

syscall # make the syscall.

## Print out $t1.

move $a0,$t1 # move the number to print into $a0.

li $v0, 1 # load syscall print_int into $v0.

syscall # make the syscall.

## Print out $t2.

move $a0,$t2 # move the number to print into $a0.

li $v0, 1 # load syscall print_int into $v0.

syscall # make the syscall.

## Print out $t3.

move $a0,$t3 # move the number to print into $a0.

li $v0, 1 # load syscall print_int into $v0.

syscall # make the syscall.

## $s2 and $s3 addition

add $t5, $t2, $t3 # compute the sum.

## Print out $t5.

move $a0, $t5 # move the number to print into $a0.

li $v0, 1 # load syscall print_int into $v0.

syscall # make the syscall.

## constant 4 & $s3 Logical OR operation

li $t6,4

or $t6, $t2, $t3

## Print out $t6(Prints the OR operation results).

move $a0, $t6 # move the number to print into $a0.

li $v0, 1 # load syscall print_int into $v0.

syscall # make the syscall.

## Shift $s3 one bit left, and then print result.

sll $t7,$s3,1 # $t7 gets the bits in $s3

# shifted left logical

# by 1 position,

li $v0, 10 # syscall code 10 is for exit