You are on page 1of 29

Experiment 3 - To count the number of odd and even nos,

ones and zeros and to find maximum and minimum in an


array and to convert packed and unpacked BCDs

Q1.
AIM: To find even and odd number count in a given array of data.

THEORY:
RCR is the command used to rotate bits of byte/word towards the right, i.e. LSB
to CF and CF to MSB.
RCL is the command used to rotate bits of byte/word towards the left, i.e, MSB to
CF and CF to LSB.
JC is used to jump if carry flag CF = 1
JNC is used to jump if no carry flag (CF = 0)

CODE:
OUTPUT:
CALCULATION:
Given array - 22,33,44,55
No of odd numbers = 2 (33,55)
No of even numbers = 2 (22,44)
Output = DX =0202
DH -> odd count = 02
DL -> even count = 02
Hence, verified.

Q2.
AIM: To count the number of ones and zeros in a given data.

THEORY:
RCR is the command used to rotate bits of byte/word towards the right, i.e. LSB
to CF and CF to MSB.
RCL is the command used to rotate bits of byte/word towards the left, i.e, MSB to
CF and CF to LSB.
JC is used to jump if carry flag CF = 1
JNC is used to jump if no carry flag (CF = 0)

CODE:
OUTPUT:
CALCULATION:
Input = 2323 = 0010 0011 0010 0011
No of ones = 6
No of zeros = 10
Output = BX = (A)16 = (10)10
DX = 6
Hence, proved.

Q3.
AIM: To find the maximum and minimum number in a given array of data.

THEORY:
CMP Destination, Source is used to compare two numbers

CODE:
OUTPUT:
CALCULATION:
Input/ GIven array = 22,33,44,55
Minimum = 22
Maximum = 55
Output AX = 55
DX = 22
Hence, Verified.
Q4.
AIM: To perform conversion of packed BCD to unpacked BCD and vice-versa.

THEORY:
Conversion is done by using AND, F0H for upper nibble and by using AND,0FH
for lower nibble

CODE:
OUTPUT:
CALCULATION:

Input = 23 (Packed)
Output = AX = 0203 (Unpacked)

Input = 0203 (Unpacked)


Output = AL = 23 (Packed)
Hence, Verified.

You might also like