Question

Fill in the following program with the appropriate assembly to produce the results of the module...

Fill in the following program with the appropriate assembly to produce the results of the
module described. Using MARS.

====== T A S K =======

# Program performs the following mathematical operation:
# f = (g + h) - (j - 12)
# where: g = 12, h = 3, j = 27
#
# --Global Variables:
# * print = Print out message - "f = "
# ******************** Math Operations ******************** #
.data # GLOBAL VARIABLES go in the data segment
.text # All instructions go in the text segment
# ***Begin the Main Program***
main:
# f = $s0
# f = (g + h) - (j - 12)
# g = 12 -> g = $t0
# h = 3 -> h = $t1
# j = 27 -> j = $t2
# $t3 = (j - 12)
# $t4 = (g + h)
# f = $t4 - $t3
# print out "f = " and $s0
# ** terminate program **
li $v0, 10
syscall
# ***End the Main Program***

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

# Program performs the following mathematical operation:
# f = (g + h) - (j - 12)
# where: g = 12, h = 3, j = 27
#
# --Global Variables:
# * print = Print out message - "f = "
# ******************** Math Operations ******************** #
.data # GLOBAL VARIABLES go in the data segment
prompt: .asciiz "\nf = "
g : .word 12
h : .word 3
j : .word 27

.text # All instructions go in the text segment
# ***Begin the Main Program***
main:
# f = $s0
# f = (g + h) - (j - 12)
# g = 12 -> g = $t0
lw $t0,g #load g

# h = 3 -> h = $t1
lw $t1,h #load h

# j = 27 -> j = $t2
lw $t2,j #load j

sub $t3,$t2,12 # $t3 = (j - 12)

add $t4,$t0,$t1# $t4 = (g + h)

# f = $t4 - $t3
sub $s0,$t4,$t3

# print out "f = " and $s0
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,1
move $a0,$s0
syscall
# ** terminate program **
li $v0, 10
syscall
# ***End the Main Program***

output:

Add a comment
Know the answer?
Add Answer to:
Fill in the following program with the appropriate assembly to produce the results of the module...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT