Page 153 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 153
Unit 10: Programming Techniques with Additional Instructions
(b) Bit Do becomes D, Notes
(c) CY flag is modified according to bit Do
RAR Rotate Accumulator right through carry
(a) Each bit is shifted right to the adjacent position
(b) Do bit becomes carry bit
(c) Carry bit is shifted into D
7
Example: If contents of Accumulator are 24H then rotate left by one bit and rotate right by
one bit.
Solution: The solution to, above stated problem is as follows:
Binary value of 24H = 0 010 010 0 (a) Rotate 24H by 1-bit right
0001 0010=12H
This is equivalent to dividing by 2 (b) Rotate 24H by 1-bit left
0100 1000=48H
This is equivalent to multiplying by 2.
Give the code for rotated instruction with example.
10.4.2 Compare
Compare instructions compares a data byte or register/memory contents with the contents of the
Accumulator by subtracting the data byte from contents of A denoted by (A). It indicates whether
the data byte is greater than equal to ≥ or less than equal to (5) by modifying the flags. The
contents of Accumulator are not modified. These are two types of compare operations listed in
Table 10.7.
Table 10.7: List of Compare Operations.
Opcode Operands Description
CMP R/M Compare register or memory contents with contents of
Accumulator
(a) It is a 1-byte instruction.
(b) If (A) <(R/M), CY is set and zero flag is reset
(c) If (A) _(R/M), zero flag is set, CY flag is reset
(d) If (A) >(R/M), CY and zero flag are reset
(e) If memory is operand, its address is specified
by (HL)
(f) No contents are modified
(g) All remaining flags i.e., S, P, AC are affected
according to the result of subtraction.
Contd. ...
LOVELY PROFESSIONAL UNIVERSITY 147