Question

write a program immediate.asm that adds the number 5 to a constant called first1. Note that...

write a program immediate.asm that adds the number 5 to a constant called first1. Note that this arithmetic must take place in a register.
Save the source file as imm.s
0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data
first1 : .word 10 #storing the constant 10 to first1 variable
msg1 : .asciiz "first1 = "
msg2 : .asciiz "\nAfter adding 5 to First1: "


   .text
   .globl main
main:
#copy value in first1 to $t0
lw $t0,first1
#print the string in variable in msg1
li $v0,4 #print string syscall is v0 = 4
la $a0,msg1 #copy address of msg1 to $a0
syscall

#print the value in first1
li $v0,1 #print integer syscall is v0 = 1
move $a0,$t0 #copy value in $t0 to $a0
syscall

#copy value 5 to $t1
li $t1,5
#add $t0 and $t1.Result stores in $t0
add $t0,$t0,$t1
  
#print the string in variable in msg
li $v0,4 #print string syscall is v0 = 4
la $a0,msg2 #copy address of msg2 to $a0
syscall

#print the result after adding 5 to first1
li $v0,1 #print integer syscall is v0 = 1
move $a0,$t0 #copy value in $t0 to $a0
syscall


li $v0,10 #$v0 == 10 terminate the program # 1cycle
syscall #executes the above operation #3 cycles



Add a comment
Know the answer?
Add Answer to:
write a program immediate.asm that adds the number 5 to a constant called first1. Note that...
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
ADVERTISEMENT