0% found this document useful (0 votes)
8 views

Lab Report 4

Uploaded by

Captain Jk
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lab Report 4

Uploaded by

Captain Jk
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Department of Computer Science

Pak-Austria Fachhochschule: Institute of Applied Sciences


and Technology, Haripur, Pakistan

COMP- 261L Computer Arithmetic and Assembly


Language Lab

Lab Report: 04

Class: COMP-261L
Name: Jamal Ahmed Khan
Registration No.: B20F0358CS022
Semester: 3rd
Submitted to: Sir Rafiullah

__________________
Instructor Signature
Lab No. 04
Arithmetic Instructions

Software Required:
EMU8086 Software

Objectives

After completing this lab, you should be able to:

 Understand the working Logical instructions.


 Understand the use the Logical Instructions by Implementing them.

Lab Tasks:

Lab Task 01:


Write an assembly language program that counts the number of ‘1’s in a byte residing in BH
register. Store the counted number in AL register.
Code:
.model small
.stack 100h
.data
.code
main proc
mov bh,10011011b
mov cx,8 ;counter for rotating 8 times
mov bl,0 ;register that store no of 1's
here:
shr bh,1 ;shift right bh reg
jnc noadd
inc bl ;if cf=1, bl is incremented
noadd:
loop here

mov al,bl ;mov bl into al


main endp
endp main
Output:

Lab Task 02:


Write an assembly language program that counts the number of ‘0’s in a byte residing in BL
register. Store the counted number in AL register.
Output:
.model small
.stack 100h
.data

.code
main proc
mov bl,10011010b ;storing value in bl register
mov cx,8 ;value of counter is 8,loop will run 8 times
mov bh,0 ;bh register count the number by 0's
here:
shr bl,1 ;shift right bl register by 1
jc noadd ;increament bh register if cf is zero otherwise jump to noadd<lebel>
inc bh

noadd:
loop here
mov al,bh ;move value of bh in al
main endp
endp main

output:

Lab Task 03:


Write an assembly language program that sets (1) the rightmost 5 bits of DI without changing the
remaining bits of DI. Save the results in SI.

Code:
.model small
.stack 100h
.data

.code
main proc
mov di,1001010110101010b
mov ax,0000000000011111b

or di,ax
mov si,di ;move di value into si
main endp
endp main
output:

Results & Observations:


In this lab we learn about the working of logical instruction. We learn about
AND ,OR,XOR,NOT instruction .we also learn about the use of logical instruction by
implementing them. We also learn about RCL,ROL,RCR,ROR and also learn about SHR,SHL
and SAR instruction.

You might also like