Lab Report3
Lab Report3
LAB # 03
Fall 2023
Class Section: C
Submitted to:
Dr.Bilal Habib
10,19, 2023
Marks
Criteria Excellent Average Nill Obtained
1. Objectives of Lab All objectives of Objectives of Objectives of lab
lab are properly lab are partially are not
covered [Marks covered shown
10] [Marks 0]
[Marks 5]
4. Procedure All the instructions are Some steps are steps are totally
written with proper missing [Marks missing [Marks
procedure 10] 0]
[Marks 20]
Document Tasks:
CODE:
.text #first no taken from the user and saved to $t0
main: la $a0,msg3
li $v0,4 syscall
la $a0,msg1 li $v0,4
syscall la $a0,newline
li $v0,4 syscall
la $a0,newline li $v0,5
syscall syscall
move $t0,$v0
li $v0,4 li $v0,1
syscall syscall
li $v0,4 j end
la $a0,newline
syscall multiplication:
syscall li $v0,4
division:
li $v0,4 la $a0,msg7
la $a0,msg4 syscall
syscall li $v0,1
syscall j end
j end
end:
subtraction: li $v0 , 10
li $v0,4
la $a0,msg5 .data
syscall
msg1: .asciiz "Enter the first no : " msg4: .asciiz "The Sum is : "
msg2: .asciiz "Enter the operation: " msg5: .asciiz "The Difference is : "
msg3: .asciiz "Enter the Second no : " msg6: .asciiz "The product is : "
OUTPUT:
Task NO : 2 : Write a program that’s show the bit position of a number is 0 or 1. (Hint if
number is 5
it is represented by 0101 show the 4th bit position is 0, similarly if the user enters 9 then the
binary equivalent is 1001. In this case the 4th bit position is 1).
CODE
.text la $a0,msg1
main: li $v0,4
li $v0,4 la $a0,newline
syscall li $v0 , 4
syscall syscall
syscall
li $v0, 4
OUTPUT:
Task No 3: Now toggle the bit find in the previous task if the bit is 1 set it to 0 if it is 0 then
set it to
1.
CODE:
.text .globl main
main: la $a0,msg2
li $v0,4 syscall
la $a0,msg1
syscall li $v0 , 1
la $a0,newline syscall
syscall
li $v0,5 li $v0 , 10
syscall syscall
move $t0,$v0
li $v0,4
OUTPUT:
CODE:
.text main:
la $a0, msg1
syscall j end
#check if no is odd
li $v0, 5 odd:
syscall li $v0, 4
syscall
.data
OUTPUT:
Task No 5:
Show that shifting left of an even number by 1 position is a multiplication by 2 and
shifting right of an even number by 1 position is a division by 2. (Hint: Use sll and srl).
CODE:
.text syscall
main: li $v0, 4
li $v0, 5 li $v0, 1
syscall syscall
#shift left
li $v0, 10
li $v0, 4 syscall
la $a0, msg2
syscall .data
OUTPUT: