[go: up one dir, main page]

0% found this document useful (0 votes)
39 views11 pages

8085 Program List With Explanation

The document provides a series of 8085 assembly language programs that demonstrate various operations such as storing data, exchanging memory contents, performing arithmetic operations, and manipulating BCD numbers. Each program includes a statement of the task, sample data, and the corresponding source code. The document serves as a comprehensive guide for learning and implementing assembly language programming for the 8085 microprocessor.

Uploaded by

digitaldodo31
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)
39 views11 pages

8085 Program List With Explanation

The document provides a series of 8085 assembly language programs that demonstrate various operations such as storing data, exchanging memory contents, performing arithmetic operations, and manipulating BCD numbers. Each program includes a statement of the task, sample data, and the corresponding source code. The document serves as a comprehensive guide for learning and implementing assembly language programming for the 8085 microprocessor.

Uploaded by

digitaldodo31
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
You are on page 1/ 11

8085 Assembly Language Programs & Explanations

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

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


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

Program 2:

LXI H : Load HL with 4000H


MVI M : Store 32H in memory location pointed by HL register pair
(4000H)
HLT : Terminate program execution

2. 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

3. Statement: Subtract the contents of memory location 4001H from the memory
location 2000H and place the result in memory location 4002H.

Program - 4: Subtract two 8-bit numbers

Sample problem:

(4000H) = 51H
(4001H) = 19H
Result = 51H - 19H = 38H

Source program:

LXI H, 4000H : HL points 4000H


MOV A, M : Get first operand
INX H : HL points 4001H
SUB M : Subtract second operand
INX H : HL points 4002H
MOV M, A : Store result at 4002H.
HLT : Terminate program execution
4. Statement: Add the 16-bit number in memory locations 4000H and 4001H to
the 16-bit number in memory locations 4002H and 4003H. The most significant
eight bits of the two numbers to be added are in memory locations 4001H and
4003H. Store the result in memory locations 4004H and 4005H with the most
significant byte in memory location 4005H.

Sample problem:

(4000H) = 15H
(4001H) = 1CH
(4002H) = B7H
(4003H) = 5AH
Result = 1C15 + 5AB7H = 76CCH
(4004H) = CCH
(4005H) = 76H

Source Program 1:
LHLD 4000H : Get first I6-bit number in HL
XCHG : Save first I6-bit number in DE
LHLD 4002H : Get second I6-bit number in HL
MOV A, E : Get lower byte of the first number
ADD L : Add lower byte of the second number
MOV L, A : Store result in L register
MOV A, D : Get higher byte of the first number
ADC H : Add higher byte of the second number with CARRY
MOV H, A : Store result in H register
SHLD 4004H : Store I6-bit result in memory locations 4004H and
4005H.
HLT : Terminate program execution

5. Statement: Subtract the 16-bit number in memory locations 4002H and 4003H
from the 16-bit number in memory locations 4000H and 4001H. The most
significant eight bits of the two numbers are in memory locations 4001H and 4003H.
Store the result in memory locations 4004H and 4005H with the most significant
byte in memory location 4005H.

Sample problem

(4000H) = 19H
(400IH) = 6AH
(4004H) = I5H (4003H) = 5CH
Result = 6A19H - 5C15H = OE04H
(4004H) = 04H
(4005H) = OEH

Source program:
LHLD 4000H : Get first 16-bit number in HL
XCHG : Save first 16-bit number in DE
LHLD 4002H : Get second 16-bit number in HL
MOV A, E : Get lower byte of the first number
SUB L : Subtract lower byte of the second number
MOV L, A : Store the result in L register
MOV A, D : Get higher byte of the first number
SBB H : Subtract higher byte of second number with borrow
MOV H, A : Store l6-bit result in memory locations 4004H and
4005H.
SHLD 4004H : Store l6-bit result in memory locations 4004H and
4005H.
HLT : Terminate program execution

6. Statement: Find the l's complement of the number stored at memory location
4400H and store the complemented number at memory location 4300H.

Sample problem:

(4400H) = 55H

Result = (4300B) = AAB


Source program:

LDA 4400B : Get the number


CMA : Complement number
STA 4300H : Store the result
HLT : Terminate program execution

7. Statement: Find the 2's complement of the number stored at memory location
4200H and store the complemented number at memory location 4300H.

Sample problem:
(4200H) = 55H
Result = (4300H) = AAH + 1 = ABH

Source program:

LDA 4200H : Get the number


CMA : Complement the number
ADI, 01 H : Add one in the number
STA 4300H : Store the result
HLT : Terminate program execution

8. Statement: Pack the two unpacked BCD numbers stored in memory locations
4200H and 4201H and store result in memory location 4300H. Assume the least
significant digit is stored at 4200H.

Sample problem:
(4200H) = 04
(4201H) = 09
Result = (4300H) = 94

Source program

LDA 4201H : Get the Most significant BCD digit


RLC
RLC
RLC
RLC : Adjust the position of the second digit (09 is changed to
90)

ANI FOH : Make least significant BCD digit zero


MOV C, A : store the partial result
LDA 4200H : Get the lower BCD digit
ADD C : Add lower BCD digit
STA 4300H : Store the result
HLT : Terminate program execution

9. Statement: Two digit BCD number is stored in memory location 4200H.


Unpack the BCD number and store the two digits in memory locations 4300H and
4301H such that memory location 4300H will have lower BCD digit.

Sample problem

(4200H) = 58
Result = (4300H) = 08 and
(4301H) = 05
Source program

LDA 4200H : Get the packed BCD number


ANI FOH : Mask lower nibble
RRC
RRC
RRC
RRC : Adjust higher BCD digit as a lower digit
STA 4301H : Store the partial result
LDA 4200H : .Get the original BCD number
ANI OFH : Mask higher nibble
STA 4201H : Store the result
HLT : Terminate program execution

10. Statement: Write a set of instructions to alter the contents of flag register in
8085.

PUSH PSW : Save flags on stack


POP H : Retrieve flags in 'L'
MOV A, L : Flags in accumulator
CMA : Complement accumulator
MOV L, A : Accumulator in 'L'

PUSH H : Save on stack


POP PSW : Back to flag register
HLT :Terminate program execution

11. Statement: Calculate the sum of series of numbers. The length of the series
is in memory location 4200H and the series begins from memory location
4201H.
a. Consider the sum to be 8 bit number. So, ignore carries. Store the sum at memory
location 4300H.
b. Consider the sum to be 16 bit number. Store the sum at memory locations 4300H
and 4301H

a. Sample problem

4200H = 04H
4201H = 01H
4202H = 02H
4203H = 03H
4204H = 04H

Source program:

LDA 4200H
MOV C, A : Initialize counter
SUB A : sum = 0
LXI H, 420lH : Initialize pointer
BACK: ADD M : SUM = SUM + data
INX H : increment pointer
DCR C : Decrement counter
JNZ BACK : if counter 0 repeat
STA 4300H : Store sum
HLT : Terminate program execution.
12.Write a program to count number of 1’s in given data (2000) and
store the result in memory location 3000H.

LDA 2000H :Load No. In Acc.

MVI B,00 :B as counter with initial value 00H


MVI C,08 :C as ac counter for looping
BACK:RLC : Rotate the content of Accumulator without carry
JNC NEXT : if bit is not 1 go to next
INR B : if bit is 1 increment counter B
NEXT : DCR C : Decrement counter C
JNZ BACK : if C is not zero jump to BACK
MOV A,B : move the result from B to A
STA 3000 : Store the result in 3000H
HLT

13.16 bytes of data are stored in memory location at 2500H to


250FH.Transfer the entire block of data to new memory location starting
at 3500H.

1. LXI H,2500H: Initialize source memory pointer


2. LXI D,3500H: Initialize Destination memory pointer
3. MVI B.10H: Counter to count 16 byte of data
4. MOV A,M: Get data from Source address
5. STAX D: store the data in destination Address
6. INX H
7. INX D
8. DCR B
9. JNZ 4.
10.HLT

14.Multiply two 8-bit numbers stored in memory locations 2200H and


2201H by repetitive addition and store the result in memory locations
2300H and 2301H.

Sample problem:

(2200H) = 03H
(2201H) = B2H
Result = B2H + B2H + B2H = 216H
= 216H
(2300H) = 16H
(2301H) = 02H

Source program

LDA 2200H
MOV E, A
MVI D, 00 : Get the first number in DE register pair
LDA 2201H
MOV C, A : Initialize counter
LX I H, 0000 H : Result = 0
BACK: DAD D : Result = result + first number
DCR C : Decrement count
JNZ BACK : If count 0 repeat
SHLD 2300H : Store result
HLT : Terminate program execution

15.Write a program for finding the largest number in a given series.

LDA 9000H //Load the length of series


MOV C,A//initialize c as counter
MVI A,00H//initialize Max=0
LXI H,9001H//initialize the memory pointer
Loop: CMP M//check if data from the series >max
JNC Next//if not jump next
MOV A,M//If it is, replace Max with the data from the series

Next: INX H
DCR C
JNZ Loop
STA 9100H
HLT

16. Write an assembly language program in 8085 microprocessor to check


whether the 8 bit number which is stored at memory location 2050 is even or
odd. If even, store 22 at memory location 3050 otherwise store 11 at memory
location 3050.
Example

Program –
MEMORY ADDRESS MNEMONICS COMMENT
2000 LDA 2050 A <- M[2050]
2003 ANI 01 A <- A (AND) 01
2005 JZ 200D Jump if ZF = 1
2008 MVI A 11 A <- 11
200A JMP 200F Jump to memory location
200D MVI A 22 A <- 22
200F STA 3050 M[3050] <- A
2012 HLT END

17. Calculate the sum of series of even numbers from the list of numbers. The
length of the list is in memory location 2200H and the series itself begins from
memory location 2201H. Assume the sum to be 8 bit number so you canignore
carries and store the sum at memory location 2Sample problem:

2200H= 4H
2201H= 20H
2202H= l5H
2203H= l3H
2204H= 22H
Result 22l0H= 20 + 22 = 42H
= 42H
Source program:

LDA 2200H
MOV C, A : Initialize counter
MVI B, 00H : sum = 0
LXI H, 2201H : Initialize pointer
BACK: MOV A, M : Get the number
ANI 0lH : Mask Bit l to Bit7
JNZ SKIP : Don't add if number is ODD
MOV A, B : Get the sum
ADD M : SUM = SUM + data
MOV B, A : Store result in B register
SKIP: INX H : increment pointer
DCR C : Decrement counter
JNZ BACK : if counter 0 repeat
STA 2210H : store sum
HLT : Terminate program execution

You might also like