0% found this document useful (0 votes)
3 views4 pages

8085 Microprocessor Programs for Numbers

The document provides assembly language programs for the 8085 microprocessor to find the largest and smallest of two numbers stored in memory. Part A details the steps to compare two numbers and store the larger one, while Part B outlines the process for finding and storing the smaller number. Each part includes memory addresses, mnemonics, and execution examples.

Uploaded by

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

8085 Microprocessor Programs for Numbers

The document provides assembly language programs for the 8085 microprocessor to find the largest and smallest of two numbers stored in memory. Part A details the steps to compare two numbers and store the larger one, while Part B outlines the process for finding and storing the smaller number. Each part includes memory addresses, mnemonics, and execution examples.

Uploaded by

hemugowda0502
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Microprocessor 8085 1

Computer Architecture

Program 3:
a). Write a program to find the largest of two numbers.
b). Write a program to find the smallest of two numbers

Part A: To Find Largest of Two Numbers

Program:

Memory Machine
Mnemonics Operands Comments
Address Code

Load 16 bit memory address of 1st number


2000 LXI H, 3500
into HL register pair.

2001

2002

Move 1st number into Accumulator from


2003 MOV A, M
memory

Increment the HL pair register to get 2nd


2004 INX H
number.
Compare 1st number in Accumulator with
2005 CMP M 2nd number in Memory. Is 2nd number > 1st
number ?
Jump to specified memory address if No
2006 JNC 200A
Carry when larger number is in Accumulator

2007

2008

Otherwise move the second number as


2009 MOV A, M Larger number into Accumulator from
Memory
Store the larger number into specified
200A STA 3503
memory address

Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re
Microprocessor 8085 2
Computer Architecture

200B

200C

200D HLT Stop the program execution

Execution:

Example:

Memory Address Input Output


1st Number 3500 98 -
2nd Number 3501 87 -
Larger number 3503 - 98

Try Yourself

Memory Address Input Output


1st Number 3500 -
2nd Number 3501 -
Larger number 3503 -

Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re
Microprocessor 8085 3
Computer Architecture

Part B: To Find Smallest of Two Numbers

Program:

Memory Machine
Mnemonics Operands Comments
Address Code

Load 16 bit memory address of 1st number


2000 LXI H, 3500
into HL register pair.

2001

2002

Move 1st number into Accumulator from


2003 MOV A, M
memory

Increment the HL pair register to get 2nd


2004 INX H
number.
Compare 1st number in Accumulator with
2005 CMP M 2nd number in Memory. Is 2nd number < 1st
number ?
Jump to specified memory address if there
2006 JC 200A is Carry when smaller number is in
Accumulator

2007

2008

Otherwise move the second number as


2009 MOV A, M smaller number into Accumulator from
Memory
Store the smaller number into specified
200A STA 3503
memory address

200B

200C

200D HLT Stop the program execution

Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re
Microprocessor 8085 4
Computer Architecture

Execution:

Example:

Memory Address Input Output


1st Number 3500 98 -
2nd Number 3501 87 -
Larger number 3503 - 87

Try Yourself

Memory Address Input Output


1st Number 3500 -
2nd Number 3501 -
Larger number 3503 -

Bac he lor of Co mp uter Ap pl ica tions I Se mes ter V E I T Deg ree C ol leg e , Ban ga lo re

You might also like