KEMBAR78
8085 Assembly Language Programs | PDF | Pointer (Computer Programming) | Assembly Language
0% found this document useful (0 votes)
6 views6 pages

8085 Assembly Language Programs

Uploaded by

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

8085 Assembly Language Programs

Uploaded by

parsomariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

8085 Assembly Language Programs & Explanation

1. Statement: Write assembly language program with proper comments for


the following:

A block of data consisting of 256 bytes is stored in memory starting at 3000H.


This block is to be shifted (relocated) in memory from 3050H onwards. Do not shift
the block or part of the block anywhere else in the memory.

Source Program:

Two blocks (3000 - 30FF and 3050 - 314F) are overlapping. Therefore it
is necessary to transfer last byte first and first byte last.

MVI C, FFH : Initialize counter


LX I H, 30FFH : Initialize source memory pointer 3l4FH
LXI D, 314FH : Initialize destination memory pointer
BACK: MOV A, M : Get byte from source memory block
STAX D : Store byte in the destination memory
block
DCX H : Decrement source memory pointer
DCX D : Decrement destination memory
pointer DCR C : Decrement counter
JNZ BACK : If counter 0 repeat
HLT : Stop execution

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

3. Statement: Find the largest number in a block of data. The length of the
block is in memory location 2200H and the block itself starts from memory
location 2201H.
Store the maximum number in memory location 2300H. Assume that the numbers
in the block are all 8 bit unsigned binary numbers.

Sample problem

(2200H) = 04
(2201H) = 34H
(2202H) = A9H
(2203H) = 78H
(2204H) =56H
Result = (2202H) = A9H

Source program

LDA 2200H
MOV C, A : Initialize counter
XRA A : Maximum = Minimum possible value =
0 LXI H, 2201H : Initialize pointer
BACK: CMP M : Is number> maximum
JNC SKIP : Yes, replace maximum
MOV A, M
SKIP: INX H
DCR C
JNZ BACK
STA 2300H : Store maximum number
HLT : Terminate program
execution

4. Statement: Write a program to count number of l's in the contents of


D register and store the count in the B register.

Source program:

MVI B, 00H
MVI C, 08H
MOV A, D
BACK: RAR
JNC SKIP
INR B
SKIP: DCR C
JNZ BACK
HLT

1. 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 = 10H
4202H = 45H
4203H = 33H
4204H = 22H
Result = 10 +41 + 30 + 12 = H
4300H = H

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

b. Sample

problem 4200H =

04H
420lH = 9AH
4202H = 52H
4203H = 89H
4204H = 3EH
Result = 9AH + 52H + 89H + 3EH = H
4300H = B3H Lower byte
4301H = 0lH Higher byte

Source program:
LDA 4200H
MOV C, A : Initialize counter
LXI H, 4201H : Initialize pointer
SUB A :Sum low = 0
MOV B, A : Sum high = 0
BACK: ADD M : Sum = sum +
data JNC SKIP
INR B : Add carry to MSB of
SUM SKIP: INX H : Increment pointer
DCR C : Decrement counter
JNZ BACK : Check if counter 0 repeat
STA 4300H : Store lower
byte MOV A, B
STA 4301H : Store higher byte
HLT :Terminate program execution

5.

6. Statement: 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
can ignore carries and store the sum at memory location 2210H
Sample 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
7. Statement: Calculate the sum of series of odd 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 16-bit. Store the sum
at memory locations 2300H and 2301H.

Sample problem:

2200H = 4H
2201H= 9AH
2202H= 52H
2203H= 89H
2204H= 3FH
Result = 89H + 3FH = C8H
2300H= H Lower byte
2301H = H Higher byte

Source program

LDA 2200H
MOV C, A : Initialize counter
LXI H, 2201H : Initialize pointer
MVI E, 00 : Sum low = 0
MOV D, E : Sum high = 0
BACK: MOV A, M : Get the
number
ANI 0lH : Mask Bit 1 to Bit7
JZ SKIP : Don't add if number is even
MOV A, E : Get the lower byte of
sum ADD M : Sum = sum + data
MOV E, A : Store result in E
register JNC SKIP
INR D : Add carry to MSB of
SUM SKIP: INX H : Increment pointer
DCR C : Decrement

JNZ BACK

MOV A, E

STA 2300H

MOV A, D

STA 2301H
HLT

You might also like