0% found this document useful (0 votes)
26 views3 pages

Lab No: 08

This document contains MIPS assembly code for several programs that perform bitwise operations like AND, OR, and XOR on user-input integers. The code prints messages to prompt for input, performs the bitwise operations using masks, prints output messages, and exits. It includes programs for AND, OR, and XOR operations as well as two lab tasks that combine multiple operations.

Uploaded by

amir khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Lab No: 08

This document contains MIPS assembly code for several programs that perform bitwise operations like AND, OR, and XOR on user-input integers. The code prints messages to prompt for input, performs the bitwise operations using masks, prints output messages, and exits. It includes programs for AND, OR, and XOR operations as well as two lab tasks that combine multiple operations.

Uploaded by

amir khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB NO: 08

PROGRAM: 01

.data
input:.asciiz "enter any integer ="
result:.asciiz "result is="
#############CODE SEGMENT###############
.text
.globl main
main:
li $t0,0xffffffff #mask
la $a0,input #print input message
li $v0,4
syscall
li $v0,5 #user input
syscall
move $t1,$v0
and $t2,$t1,$t0
la $a0,result #print message
li $v0,4
syscall
move $a0,$t2
li $v0,1 #print output
syscall
li $v0,10
syscall

Program # 02
.data
input:.asciiz "enter any integer ="
result:.asciiz "result is="
#############CODE SEGMENT###############
.text
.globl main
main:
li $t0,0x00000000 #mask
la $a0,input #print input message
li $v0,4
syscall
li $v0,5 #user input
syscall
move $t1,$v0
and $t2,$t1,$t0
la $a0,result #print message
li $v0,4
syscall
move $a0,$t2
li $v0,1 #print output
syscall
li $v0,10
syscall

PROGRAM 03
.data
input:.asciiz "enter any integer ="
result:.asciiz "result is="
#############CODE SEGMENT###############
.text
.globl main
main:
li $t0,0xffffffff #mask
la $a0,input #print input message
li $v0,4
syscall
li $v0,5 #user input
syscall
move $t1,$v0
or $t2,$t1,$t0
la $a0,result #print message
li $v0,4
syscall
move $a0,$t2
li $v0,1 #print output
syscall
li $v0,10
syscall

LAB TASK
.data
input:.asciiz "enter any integer ="
result:.asciiz "result is="
#############CODE SEGMENT###############
.text
.globl main
main:
li $t0,0x00000000 #mask 0
la $a0,input #print input message
li $v0,4
syscall
li $v0,5 #user input
syscall
move $t1,$v0
and $t2,$t1,$t0
li $t3,0xffffffff #mask 1
xor $t4,$t1,$t3
and $t5,$t4,$t3
xor $t6,$t5,$t2
la $a0,result
li $v0,4
syscall
move $a0,$t6
li $v0,1 #print result
syscall
li $v0,10
syscall

2nd task
.data
input:.asciiz "enter any integer ="
result:.asciiz "result is="
#############CODE SEGMENT###############
.text
.globl main
main:
li $t0,0x00000000 #mask 0
la $a0,input #print input message
li $v0,4
syscall
li $v0,5 #user input
syscall
move $t1,$v0
or $t2,$t1,$t0
li $t3,0xffffffff #mask 1
xor $t4,$t1,$t3
or $t5,$t4,$t3
xor $t6,$t5,$t2
la $a0,result
li $v0,4
syscall
move $a0,$t6
li $v0,1 #print result
syscall
li $v0,10
syscall

You might also like