KS57C2308/P2308/C2316/P2316 SAM47 INSTRUCTION SET
5-65
LDB Load Bit
LDB (Continued)
Examples: 1. The carry flag is set and the data value at input pin P1.0 is logic zero. The following instruction
clears the carry flag to logic zero.
LDB C,P1.0
2. The P1 address is FF1H and the L register contains the value 9H (1001B). The address
(memb.7–2) is 111100B and (L.3–2) is 10B. The resulting address is 11110010B or FF2H and
P2 is addressed. The bit value (L.1–0) is specified as 01B (bit 1).
LD L,#9H
LDB C,P1.@L ;P1.@L specifies P2.1 and C P2.1
3. The H register contains the value 2H and FLAG = 20H.3. The address for H is 0010B and for
FLAG(3–0) the address is 0000B. The resulting address is 00100000B or 20H. The bit value is
3. Therefore, @H+FLAG = 20H.3.
FLAG EQU 20H.3
LD H,#2H
LDB C,@H+FLAG ;C FLAG (20H.3)
4. The following instruction sequence sets the carry flag and the loads the "1" data value to the
output pin P2.0, setting it to output mode:
SCF ;C "1"
LDB P2.0,C ;P2.0 "1"
5. The P1 address is FF1H and L = 9H (1001B). The address (memb.7–2) is 111100B and (L.3–
2) is 10B. The resulting address, 11110010B specifies P2. The bit value (L.1–0) is specified as
01B (bit 1). Therefore, P1.@L = P2.1.
SCF ;C "1"
LD L,#9H
LDB P1.@L,C ;P1.@L specifies P2.1
;P2.1 "1"
6. In this example, H = 2H and FLAG = 20H.3 and the address 20H is specified. Since the bit
value is 3, @H+FLAG = 20H.3:
FLAG EQU 20H.3
RCF ;C "0"
LD H,#2H
LDB @H+FLAG,C ;FLAG(20H.3) "0"
NOTE: Port pin names used in examples 4 and 5 may vary with different SAM47 devices.