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

Examples in 8085 Programming

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

Examples in 8085 Programming

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

This document was prepared by Doyin Ajayi of Mathematical Sciences Department and is not for sale.

Study the following programs…

1. Statement: Exchange the contents of memory locations 2000H and 4000H

Program 1:

LDA 2000H ; Get the contents of memory location 2000H into accumulator
MOV B, A ; Save the contents into B register
LDA 4000H ; Get the contents of memory location 4000Hinto accumulator
STA 2000H ; Store the contents of accumulator at address 2000H
MOV A, B ; Get the saved contents back into A register
STA 4000H ; Store the contents of accumulator at address 4000H

2. Statement: Store the data byte 32H into memory location 4000H.

Program:

MVI A, 32H ; Store 32H in the accumulator


STA 4000H ; Copy accumulator contents at address 4000H
HLT ; Terminate program execution

3. Sample problem

(4000H) = 14H

(4001H) = 89H

Result = 14H + 89H = 9DH

Source program

LXI H 4000H ; HL points 4000H


MOV A, M ; Get first operand
INX H ; HL points 4001H
ADD M ; Add second operand
INX H ; HL points 4002H
MOV M, A ; Store result at 4002H
HLT ; Terminate program execution

4. Write an assembly program to add two numbers


Program
MVI D, 8BH
MVI C, 6FH
MOV A, C
ADD D

1
This document was prepared by Doyin Ajayi of Mathematical Sciences Department and is not for sale.

OUT PORT1
HLT
5. Write an assembly program to find greatest between two numbers
Program
MVI B, 30H
MVI C, 40H
MOV A, B
CMP C
JZ EQU
JC GRT
OUT PORT1
HLT

EQU: MVI A, 01H


OUT PORT1
HLT

GRT: MOV A, C
OUT PORT1
HLT

JZ means Jump if Zero

JC means Jump on Carry

You might also like