Question

Assembly language (MIPS) Let register $8 be x and register $9 be y. Write a program...

Assembly language (MIPS)

Let register $8 be x and register $9 be y. Write a program to evaluate:

Z = 3x - 5y+5

Leave the result in register $10. Inspect the register after running the program to check that the program works. Run the program several times, initialize x and y to different values for each run.

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

.data

x: .word 10

y: .word 2

msg: .asciiz "z = "

.text

main:

  

#load value 3 to $t0

li $2,3

#load value 5 to $t1

li $3,5

#load x value to $t8

lw $8,x

#load y value to $t9

lw $9,y

#multiply $2 and $8,result stores in $10

# 3*x

mul $10,$2,$8

# 5*y

mul $5,$9,$3

#subtract $10 and $5,result stores in $10

# 3x - 5y

sub $10,$10,$5

#add $10 and $3,result stores in $10

# z = 3x - 5y + 5

add $10,$10,$3

#print msg1

li $v0,4 #print string syscall value is 4

la $a0,msg #load address of msg to $a0

syscall

#print z value

li $v0,1 #print integer syscall value is 1

move $a0,$10 #load z value to $a0

syscall

#terminate the program

li $v0, 10

syscall

For x = 4 and y = 5

For x = 10 ,y = 2

For x = 15,y = 6

Add a comment
Know the answer?
Add Answer to:
Assembly language (MIPS) Let register $8 be x and register $9 be y. Write a program...
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
Active Questions
ADVERTISEMENT