Download Print this page

ZiLOG Z80 Handbook page 173

Hide thumbs Also See for Z80:

Advertisement

RLD
4 BITS
7 4 3 0 7 4 3 -1 0
A
MEMORY OPERAND
POINTED TO BY HL
4BITS 4BITS
RRD
UNAFFECTED
4BITS
7 4 3 . 0 7 4 3 0
A
4BITS 4BITS
Fig. 12-4. RLD , RRD action.
MEMORY OPERAND
POINTED TO BY HL
traction of 30H and the resulting bed digits were rotated into the
location pointed to by HL. At the end of the loop, the HL pointer
was incremented by one and the IX by two; HL is the pointer to
the next storage location, while IX points to the current ASCII char-
acter to be processed. The loop has five iterations to process five sets
of two characters at a time.
7
BEFORE BCDAXB
ASCII CHARACTER 0
AFTER BCDAXB
BCD DIGIT 0 BCD DIGIT 1
2
3
4
5
6
7
8
9
Fig. 12-5. ASCII to bcd conversion.
As a further example of the use of the 4-bit rotates, let us convert
the opposite way, going from packed bed digits in INBUF through
INBUF+4 into ASCII characters representing the digits 0 through
9. Here, we must go backwards through the buffer as we are filling
two bytes of ASCII data with each packed byte of two bed digits.
IX will hold the address of the next location to be used for storage
in the buffer, while HL will point to the current pair of bed digits.
As two bed digits will be processed at a time, five iterations will take
place. The first two bed digits are picked up from INBUF+4 and
stored in INBUF+9 and INBUF+8. The conversion will continue
until the digits at INBUF are accessed and the ASCII characters that
result are stored at INBUF+1 and INBUF as shown in Fig. 12-6.
182

Advertisement

loading
Need help?

Need help?

Do you have a question about the Z80 and is the answer not in the manual?

Questions and answers