List of Exp Microprocessor Upto Week 3 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

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, 4000H ; 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


4000H into 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

HLT ; Terminate program execution.


Program 2:

LXI H 2000H ; Initialize HL register pair as a pointer


to memory location 2000H.

LXI D 4000H ; Initialize DE register pair as a pointer


to memory location 4000H.

MOV B, M ; Get the contents of memory location


2000H into B register.

LDAX D ; Get the contents of memory location


4000H into accumulator.

MOV M, A ; Store the contents of A register into


memory location 2000H.

MOV A, B ; Copy the contents of B register into


accumulator.

STAX D ; Store the contents of A register into


memory location 4000H.

HLT ; Terminate program execution.


3. Sample problem to add two numbers.

(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. Subtract the contents of memory location 4001H from the memory
location 4000H and place the result in memory location 4002H.

Program:
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

You might also like