Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. If yes, then why?

Answered: 1 week ago

Question

6. How would you design your ideal position?

Answered: 1 week ago