Microprocessor Lab: Counting Odd/Even Numbers and Sorting Arrays, Exercises of Microprocessors

Two microprocessor lab programs for counting odd and even numbers and sorting arrays in ascending order. The first program uses a loop to count the number of odd and even numbers in a memory location, while the second program sorts an array in ascending order using a repeat-until loop. These programs can be useful for students studying microprocessor programming and digital electronics.

Typology: Exercises

2020/2021

Uploaded on 02/10/2021

nikhil-balasubramanian
nikhil-balasubramanian 🇮🇳

5

(1)

4 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Ex.no – 2 Microprocessor Lab
1805103 Nikhil
1.Count number of odd/even numbers
Program:
LHLD 0000H
MOV C,L
MVI B,00H
LXI H,0001H
LOOP:MOV A,M
ANI 01H
JNZ ODD
INR B
ODD:INX H
DCR C
JNZ LOOP
MOV A,B
STA 0020H
LHLD 0020H
MOV C,H
LDA 0000H
SUB B
STA 0021H
HLT
Output:
pf3

Partial preview of the text

Download Microprocessor Lab: Counting Odd/Even Numbers and Sorting Arrays and more Exercises Microprocessors in PDF only on Docsity!

Ex.no – 2 Microprocessor Lab

1805103 Nikhil

1.Count number of odd/even numbers

Program:

LHLD 0000H

MOV C,L

MVI B,00H

LXI H,0001H

LOOP:MOV A,M

ANI 01H

JNZ ODD

INR B

ODD:INX H

DCR C

JNZ LOOP

MOV A,B

STA 0020H

LHLD 0020H

MOV C,H

LDA 0000H

SUB B

STA 0021H

HLT

Output:

2.Sort array in ascending order

Program:

REPEAT:MVI D,05H

LXI H,0000H

MOV B,M

DCR B

INX H

BACK:MOV A,M

INX H

CMP M

JC INORDER

MOV C,M

MOV M,A

DCX H

MOV M,C

INX H

DCR D

INORDER:DCR B

JNZ BACK

HLT

MOV A,D

CPI 05H

JNZ REPEAT

Output: