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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started