Microprocessor 8085 Appendix A: Explanation
Microprocessor 8085 Appendix A: Explanation
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
Step V
Step VI
Step VII :
Decrement count.
Step VIII :
Step IX
Step X
Step XI
Stop.
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
STAX D
INX
; Increment source
; memory pointer
DCX D
; Decrement destination
; memory pointer
DCR C
; Decrement counter
JNZ
; If counter 0 repeat
HLT
BACK
Flowchart 31