Chapter
3.
Instruction
Set
The operand must specify one
of
the registers A through
E,
H or
L.
Th~
instruction subtracts one from the
contents
of
the specified register
..
Cycles:
States:
Addressing:
Flags:
Decrement Memory
Orcade
DCR
5
(4
on 8085)
register
Z,S,P,AC
Operand
M
This instruction subtracts one from the contents
of
the memory location addressed
by
the
Hand
L registers.
M
is
a symbol
ic
reference to the
Hand
L registers.
Cycles:
States:
Addressing:
Flags:
Example:
o
3
10
O~
register indirect
Z,S,P,AC
The
DCR
instruction
is
frequently used to control multi-byte operations such
as
moving a number
of
characters
from one area
of
memory to another:
MVI
B,5H
LXI
H,260H
LXI
D,900H
LOOP:
MOV
A,M
STAX
D
DCX
D
DCX
M
DCR
B
jNZ
LOOP
;SET CONTROL COUNTER
;LOAD
H,&L
WITH
SOURCE ADDR
;LOAD
D&E
WITH
DESTINATION ADDR
;LOAD
BYTE
TO
BE
MOVED
;STORE
BYTE
;DECREMENT DESTINATION ADDRESS
;DECREMENT SOURCE ADDRESS
;DECREMENT CONTROL COUNTER
;REPEAT LOOP UNTIL COUNTER=O
This example also illustrates
an
efficient programming technique. Notice that the control counter
is
decremented
to zero rather than incremented until the desired count
is
reached. This technique avoids the need for a compare
instruction and therefore conserves both memory and execution time.
3-21