Question: Using either Qtspim or MARS simulator: 1. Modify this code to be able to get the difference of the two numbers as well as the

Using either Qtspim or MARS simulator:

1. Modify this code to be able to get the difference of the two numbers as well as the sum.

Turn in the source code, the assembly, and the output of both programs.

## The example is available below:

# Simple input/output in MIIPS assembly

# Start .text segment (program code)

.text

.globl main

main:

# Print string msg1

li $v0,4 # print_string syscall code = 4

la $a0, msg1 # load the address of msg

syscall

# Get input A from user and save

li $v0,5 # read_int syscall code = 5

syscall

move $t0,$v0 # syscall results returned in $v0

# Print string msg2

li $v0,4 # print_string syscall code = 4

la $a0, msg2 # load the address of msg2

syscall

# Get input B from user and save

li $v0,5 # read_int syscall code = 5

syscall

move $t1,$v0 # syscall results returned in $v0

# Math!

add $t0, $t0, $t1 # A = A + B

# Print string msg3

li $v0, 4

la $a0, msg3

syscall

# Print sum

li $v0,1 # print_int syscall code = 1

move $a0, $t0 # int to print must be loaded into $a0

syscall

# Print

li $v0,4 # print_string syscall code = 4

la $a0, newline

syscall

li $v0,10 # exit

syscall

# Start .data segment (data!)

.data

msg1: .asciiz "Enter A: "

msg2: .asciiz "Enter B: "

msg3: .asciiz "A + B = "

newline: .asciiz "

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 Programming Questions!