Question: A. Run the mars program 3 times with different inputs and report the result (and corresponding inputs). Looking at the code, what does this program

A. Run the mars program 3 times with different inputs and report the result (and corresponding inputs). Looking at the code, what does this program do? (write some C code that could compile to this)

b. Modify the problem to find the minimum of two array values and write the value back to a third array location. The minimum of two numbers, x and y, can be given by:

(,) = ( + ( ))/2 To find the abs in MIPS, you may use the abs $t0, $t1 pseudo-instruction (sets $t0 to abs($t1)). All three indices should be entered by the user. For this assignment you may assume that the user inputs correct values. Provide three test cases (inputs and observed output) showing your code works and describe how you verified correctness.

MIPS code:

.data str1: .asciiz "Please enter a number: " .align 2 vals: .word 25 1 4 10 381 42 100 60 0 12 25 .text .globl main

main: # Start program addi $s1, $zero, 0 # s1 is ouput value inputs: # Request some user input: li $v0, 4 la $a0, str1 syscall # Read some user input: li $v0, 5 syscall

sll $s0, $v0, 5

# Request some user input: li $v0, 4 la $a0, str1 syscall # Read some user input: li $v0, 5 syscall

sll $v0, $v0, 2 # Usually you would let the assembler to the heavy lifting by using: la $s1, vals lui $s1, 0x1001 addiu $s1, $s1, 24 addu $s1, $s1, $v0 lw $s1, 0($s1) addu $s1, $s0, $s1

# Print output li $v0, 1 addi $a0, $s1, 0 syscall # Exit program li $v0, 10 syscall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!