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

Microprocessor 8085 Appendix A: Explanation

This document describes an algorithm to reverse the order of bytes in a block of memory. It initializes pointers to the source and destination blocks. It then copies bytes from the end of the source block to the beginning of the destination block, decrementing the source pointer and incrementing the destination pointer each time. This process repeats until all bytes have been transferred in reverse order from the source to destination block.

Uploaded by

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

Microprocessor 8085 Appendix A: Explanation

This document describes an algorithm to reverse the order of bytes in a block of memory. It initializes pointers to the source and destination blocks. It then copies bytes from the end of the source block to the beginning of the destination block, decrementing the source pointer and incrementing the destination pointer each time. This process repeats until all bytes have been transferred in reverse order from the source to destination block.

Uploaded by

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

Microprocessor 8085

Appendix A

Explanation :

We have a source block and a destination block. The source block contains N bytes. For
example : Let N = 10. We have to reverse this 10 bytes of data and transfer them to destination
block.
A pointer will be initialized to point to source block and another pointer to point the destination
block. The count of number of bytes is loaded in the C register.
We will add the count to source memory pointer, so that the source memory pointer will point to the
last location. Then, we will copy the contents of this location to destination.
Decrement the counter. Decrement Source memory pointer to point to (N 1)th block.
Increment destination pointer to point to the next location.
Repeat the process till all the contents are transferred to destination block in reverse manner. Store
the result.

Algorithm :

Step I

Initialize pointer to starting location of source and destination pointer to starting location
of destination block.

Step II

Initialize C = count.

Step III

Source pointer = Source pointer + (count 1), i.e. Source pointer points to last element
in source block.

Step IV

Load A = contents of element where Source pointer is pointing.

Step V

Transfer contents of A to destination location.

Step VI

Decrement Source pointer.

Step VII :

Decrement count.

Step VIII :

Increment Destination pointer to next location.

Step IX

Check if count = 0 ? If not, go to step IV.

Step X

Display transferred contents.

Step XI

Stop.

Flowchart : Refer flowchart 31.

Microprocessor 8085

Appendix A

Program :
Instruction
MVI

C, 0AH

LXI

H, D000 H

Comment
; Initialize counter
; Initialize source memory
; pointer

LXI

D, D100 H

; Initialize destination
; memory pointer

BACK: MOV A, M

; Get byte from source


; memory block

STAX D

; Store byte in the destination


; memory block

INX

; Increment source
; memory pointer

DCX D

; Decrement destination
; memory pointer

DCR C

; Decrement counter

JNZ

; If counter 0 repeat

HLT

BACK

; Terminate program execution

Flowchart 31

You might also like