Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MIPS Assembly: For these programming exercises, use only those instructions that

ID: 3817419 • Letter: M

Question

MIPS Assembly:

For these programming exercises, use only those instructions that have been discussed so far in these notes:

Put the bit pattern 0x55555555 in register $1. (Do this with three instructions.)

Now shift the pattern left one position into register $2 (leave $1 unchanged).

Put the the bit-wise OR of $1 and $2 into register $3. Put the the bit-wise AND of $1 and $2 into register $4. Put the the bit-wise XOR of $1 and $2 into register $5.

Examine the results.

and andi nor or ori sll srl xor xori

Explanation / Answer

.data
msg0: .asciiz "value after performing shift operation"
msg1: .asciiz "value after performing OR operation"
msg2: .asciiz "value after performing AND operation"
msg3: .asciiz "value after performing XOR operation"

.text
.globl main

main:
li $t1,0x55555555   #loading 0x55555555 into register $t0
move $t2,$t1       #moving content of $t0 to $t2      
sll $t2,$t2,$t1       #left shift operation on $t2
or $t3,$t2,$t1       #or operation on $t1 and $t2
and $t4,$t2,$t1       #and operation on $t1 and $t2
xor $t5,$t2,$t1       #xor operation on $t1 and $t2
  
li $v0,4       #printing msg msg0
la $a0,msg0
syscall

li $v0,1       #printing the value of $t2 register
move $a0,$t2
syscall

li $v0,4       #printing msg msg1
la $a0,msg1
syscall

li $v0,1       #printing the value of $t3 register      
move $a0,$t3
syscall

li $v0,4       #printing msg msg2
la $a0,msg2
syscall
  
li $v0,1       #printing the value of $t4 register
move $a0,$t4
syscall

li $v0,4       #printing msg msg3
la $a0,msg3
syscall

li $v0,1       #printing the value of $t5 register
move $a0,$t5
syscall

li $v0,10       #to exit
syscall

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote