Question

1) Perform the following operation using MIPS assembly: a) Perform C= A+B-D where A=0x4 & B=0x4...

1) Perform the following operation using MIPS assembly:

a) Perform C= A+B-D where A=0x4 & B=0x4 & D = 0x10 (choose the registers

b)

           if (I == J)

I ++;

else

J--;

c)

if (a > 0)

b = a + 10;

else

b = a - 10;

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

A,

copy to code:

.text
#set 4 to t0
addi $t0, $zero , 0x4
#set 4 to t1
addi $t1, $zero , 0x4
#set 10 to t2 10 equivalent to 16 in decimal
addi $t2, $zero , 0x10
#add t0 and t1
add $t3, $t0,$t1
#sub t3 by t2
sub $t3,$t3,$t2
#print message
li $v0,1
move $a0,$t3
syscall

code snippet:

Edit Execute addThreeNumber.asm . text #set 4 to t0 addi $t0, Šzero , 0x4 #set 4 to ti addi $tl, $zero, 0x4 #set 10 to t2 10output:

Data Segment Address Value (+0) Value (+4) 0x10010000 0x10010020 0x10010040 0x10010060 0x10010080 0x100100a0 0x100100c0 0x100

b

copy to code;

.data
newline: .asciiz "\n"
ais : .asciiz "a = "
bis : .asciiz "b = "
.text
addi $t1,$zero,9 #t1 store value of a set to -3
addi $t2,$zero,9 #t1 store value of a set to -3
seq $t3,$t1,$t2 #set is equal to t3
beqz $t3,Else #check if equal zero go to zero
addi $t1,$t1,1 #if part
j endIf #jump to end if
Else :
subi $t2,$t2,1 #else part
endIf:

#print message
li $v0,4
la $a0,ais #it will print a =
syscall

li $v0,1
move $a0,$t1 #print a value
syscall

li $v0,4
la $a0,newline #it will print b =
syscall

li $v0,4
la $a0,bis #it will print new line
syscall

li $v0,1
move $a0,$t2 #it will print b value
syscall

code snippet;

Edit Execute I addThreeNumber.asm ifleself.asm is equal.asm* data newline: .asciiz ais : .asciiz a= bis : .ascii z b =

output:

0x00400008 0x012a5823 subu $11,$9,$10 | 0x0040000c| 0x34010001|ori $1, $0,0x0 00 00001 0x00400010 0x0161582b sltu $11,$11,$1

c

copy to code:

.text
addi $t1,$zero,-3 #t1 store value of a set to -3
sgt $t3,$t1,0 #set greater than zero to t3
beqz $t3,Else #check if equal zero go to zero
addi $t2,$t1,10 #if part
j endIf #jump to end if
Else :
subi $t2,$t1,10 #else part
endIf:


#print message
li $v0,1
move $a0,$t2
syscall

code snippet.

Edit Execute addThreeNumber.asm ifieself.asm .text addi $t1,$zero,-3 #tl store value of a set to -3 sgt $t3 $t1 #set greateroutput:

Edit Execute Text Ser Source □ | 0x00400000| 0x2009fffdaddi $9, $0,0xfffffffd | 2: addi $t1,$zero,-3 #tl store value of a set

Add a comment
Know the answer?
Add Answer to:
1) Perform the following operation using MIPS assembly: a) Perform C= A+B-D where A=0x4 & B=0x4...
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