Samsung S3C8275X User Manual page 168

8-bit cmos microcontrollers
Table of Contents

Advertisement

INSTRUCTION SET
DA
— Decimal Adjust
DA
(Continued)
Example:
Given: Working register R0 contains the value 15 (BCD), working register R1 contains
27 (BCD), and address 27H contains 46 (BCD):
ADD
DA
If addition is performed using the BCD values 15 and 27, the result should be 42. The sum is
incorrect, however, when the binary representations are added in the destination location using
standard binary arithmetic:
+ 0 0 1 0
The DA instruction adjusts this result so that the correct BCD representation is obtained:
+ 0 0 0 0
Assuming the same values given above, the statements
SUB
DA
leave the value 31 (BCD) in address 27H (@R1).
6-34
R1,R0
;
R1
;
0 0 0 1
0 1 0 1
0 1 1 1
0 0 1 1
1 1 0 0 =
0 0 1 1
1 1 0 0
0 1 1 0
0 1 0 0
0 0 1 0 =
C ← "0", H ← "0", Bits 4–7 = 3, bits 0–3 = 1
27H,R0 ;
@R1 ← 31–0
@R1
;
S3C8275X/F8275X/C8278X/F8278X/C8274X/F8274X
C ← "0", H ← "0", Bits 4–7 = 3, bits 0–3 = C, R1 ← 3CH
R1 ← 3CH + 06
15
27
3CH
42

Advertisement

Table of Contents
loading

This manual is also suitable for:

F8275xF8274xC8278xC8274xF8278x

Table of Contents