Simple Data Transfer Program in 8085 Microprocessor

In the article, there are few examples of data transfer program in 8085 microprocessor in assembly language programming (ALP). You need to learn the instruction set of 8085 in detail before programming.

One program can be performed in multiple ways. Here they are mentioned as Program 1, Program 2 … Comments in each program is written after semicolon (;).

Data Transfer Program in 8085

Store the Data in 8085 Microprocessor

Store the data byte 50H into memory location 2000H.

 

Program 1:

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

STA 2000H      ; Copy accumulator contents at memory location 2000H

HLT                  ; Terminate program execution.

 

Program 2:

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

LXI H, 2000H   ; Load HL register pair with value(data) 2000H

MOV M, A          ; Copy accumulator contents in memory location pointed by HL                                    register pair (2000H)

HLT                  ; Terminate program execution.

Program 3:

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

LXI B, 2000H    ; Load BC register pair with value(data) 2000H

STAX B             ; Copy the accumulator contents in memory address indicated by                                 BC pair

HLT                  ; Terminate program execution.

Sample Example:

(2000H) = F3H (or mostly 00H by default)

Result= (2000H)=50H

Copy the contents of memory location 1000H to register C.

 

Program:

LDA 1000H      ; Get the contents of memory location 1000H into accumulator

MOV C, A        ; Copy the accumulator into register C

HLT                  ; Terminate program execution.

 

Sample Example:

(1000H) = 25H

Result= (C)=25H

Copy the contents of register B to memory location 1000H.

 

Program:

MOV A, B        ; Copy the accumulator into register C

STA 1000H      ; Get the contents of memory location 1000H into accumulator

HLT                  ; Terminate program execution.

 

Sample Example:

(B) = 4AH

Result= (1000H)=4AH

Exchange the contents in 8085 Microprocessor

Exchange the contents of memory locations 2000H and 2001H.

 

Program 1:

LDA 2000H      ; Get the contents of memory location 2000H into accumulator

MOV B, A        ; Save the contents into B register

LDA 2001H      ; Get the contents of memory location 2001H into accumulator

STA 2000H      ; Store the contents of accumulator at address 2000H

MOV A, B        ; Get the saved contents back into A register

STA 2001H      ; Store the contents of accumulator at address 2001H

HLT                  ; Terminate program execution.

 

Program 2:

LXI H, 2000H   ; Initialize HL register pair as a pointer to memory location 2000H

LXI D, 2001H   ; Initialize DE register pair as a pointer to memory location 2001H

MOV B, M       ; Get the contents of memory location 2000H into B register

LDAX D            ; Get the contents of memory location 2001H into A register

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 2001

HLT                  ; Terminate program execution.

 

Program 3:

LXI B, 2000H    ; Initialize BC register pair as a pointer to memory location 2000H

LDAX B            ; Get the contents of memory location 2000H into accumulator

MOV D, A        ; Copy accumulator into register D

INX B               ; increment the content of BC register by 1 (BC=2001)

LDAX B            ; Load accumulator with content of memory indicated by BC register

DCX B              ; Decrement the content of BC register by 1 (BC=2000)

STAX B              ; Copy the contents of accumulator to address indicated by BC                                      register pair

INX B               ; increment the content of BC register by 1 (BC=2001)

MOV A, D        ; Copy the register D into accumulator

STAX B             ; Store the contents of accumulator into memory location 2001

HLT                  ; Terminate program execution

 

Program 4:

LXI B, 2000H    ; Initialize BC register pair as a pointer to memory location 2000H

LDAX B            ; Get the contents of memory location 2000H into accumulator

MOV D, A        ; Copy accumulator into register D

INX B               ; Increment the content of BC register by 1 (BC=2001)

LDAX B            ; Load accumulator with content of memory indicated by BC                                          register

MOV E, A         ; Copy accumulator to register E

MOV A, D        ; Copy register D to accumulator

STAX B             ; Store the contents of accumulator into memory location 2001

DCX B              ; Decrement the content of BC register by 1 (BC=2000)

MOV A, E         ; Copy register E to accumulator

STAX B             ; Store the contents of accumulator into memory location 2000

HLT                  ; Terminate program execution

 

Sample Example:

(2000H) = 55H

(2001H)= 44H

Result= (2000H)=44H and (2001H)=55H

Recent posts

1 thought on “Simple Data Transfer Program in 8085 Microprocessor”

Leave a Comment

Your email address will not be published. Required fields are marked *