In: Computer Science
I have to do the following MIPS coding assignment.
Question 1
Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction):
Hint: You should only need to add 4 lines of assembly language to the starter program (one for each listed instruction above)
Question 2
Hint: Be sure to end your program properly
Geetings!!
Q1.
Code:
.text
main:
ori $13,$0,237 #bitwise or operation
for loading 237 into register 13
ori $17,$0,1834 #bitwise or operarion for loading 1834
into register 17
and $8,$13,$17 #bitwise and operation on contents of
registers 13 and 17 and store the result into register 8
ori $9,$8,333 #bitwise or operaiton
on the value stored at register 8 with 333 and store the result to
register 9
li $2,10
#load parameter for terminating the execution using system
calls
syscall #make system
call
Output screenshots:
After ori $13,$0,237
After ori $17,$0,1834
After and $8,$13,$17
After ori $9,$8,333
Q2.
Code:
.text
main:
li $t0,4 #load 4 to t0
addi $t1,$t0,0x32 #add 0x32 to 4 and store the result
in t1
sub $t3,$t0,$t1 #subtract t1 from t0
and store the result in t3
xori $t3,$t3,0xFFFFFFFF #invert all the bits of t3 and
store the result in t3
move $t4,$t3 #copy the
answer of t3 to t4
sll $t3,$t4,4 #shift
left the content of t4 by 4 bits and store the result in t3
li $v0,10
syscall
Output screenshots:
After li $t0,4
After addi $t1,$t0,0x32
After sub $t3,$t0,$t1
After xori $t3,$t3,0xFFFFFFFF
After move $t4,$t3
After sll $t3,$t4,4
Hope this helps