Datasheet

Section 2 CPU
Rev.7.00 Dec. 24, 2008 Page 70 of 698
REJ09B0074-0700
P17 P16 P15 P14 P13 P12 P11 P10
I/O Output Output Output Output Input Input Input Input
P1DDR 1 1 1 1 0 0 0 0
RAM0 1 1 1 1 0 0 0 0
To change pin 14 from an output pin to an input pin, the value of bit 4 in P1DDR must be changed
from 1 to 0 (H'F0 to H'E0). Here the BCLR instruction will be used to clear bit 4 in P1DDR to 0.
BCLR #4, @RAM0
P17 P16 P15 P14 P13 P12 P11 P10
I/O Output Output Output Output Input Input Input Input
P1DDR 1 1 1 1 0 0 0 0
RAM0 1 1 1
0 0 0 0 0
Since RAM0 is a read/write area of memory, performing the above bit manipulation using the
BCLR instruction causes only bit 4 in RAM0 to be cleared to 0. The value of RAM0 is then
written to P1DDR.
MOV.B @RAM0, R0L
MOV.B R0L, @P1DDR
P17 P16 P15 P14 P13 P12 P11 P10
I/O Output Output Output
Input Input Input Input Input
P1DDR 1 1 1 0 0 0 0 0
RAM0 1 1 1
0 0 0 0 0
By using the above procedure to access registers containing write-only bits, it is possible to create
programs that are not dependent on the type of instructions used.