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

Using MARS write a MIPS assembly language that prompts for the first integer by

ID: 3663581 • Letter: U

Question

Using MARS write a MIPS assembly language that prompts for the first integer by displaying "Give me an integer: ";then reads the first integer into a memory location labeled 'int1', prompts for the second integer by displaying "Give me another integer: ";then reads the seconds integer into a memory location labeled 'int2', calculates the sum of the two integers then prints out the string "The sum of these two integers is: ", and the sum of int1 and int2. E.g. "The sum of these two integrals is: 100"if the first integer was 99 and the second one was 1.

Explanation / Answer

.data

prompt1: .asciiz " Give me an integer: "

prompt2: .asciiz "Enter the second integer please:"

result: .asciiz "The sum of these two integers is: "

.text

main:

#t0- to hold first integer

#t1- to hold second integer

#t2- used to hold the sum of t$1 and t$2

#first Number

li $v0, 4 #syscall to print string

la $a0, prompt1 #address of string to print

syscall

li $v0, 5 #syscall to read an integer

syscall

move $t0, $v0 #move the number to read into $t0

#second number

li $v0, 4

la $a0, prompt2

syscall

li $v0, 5

syscall

move $t1, $v0

add $t2, $t1, $t0 #compute the sum

#print out sum of $t2

li $v0, 4 #load syscal print int into $v0

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

li, $v0, 1

la, $a0, result

syscall

Done:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote