English
Language : 

HD64F3048F16 Datasheet, PDF (81/903 Pages) Renesas Technology Corp – Old Company Name in Catalogs and Other Documents
Section 2 CPU
2.6.5 Notes on Use of Bit Manipulation Instructions
The BSET, BCLR, BNOT, BST, and BIST instructions read a byte of data, modify a bit in the
byte, then write the byte back. Care is required when these instructions are used to access registers
with write-only bits, or to access ports.
The BCLR instruction can be used to clear flags in the internal I/O registers. In an interrupt-
handling routine, for example, if it is known that the flag is set to 1, it is not necessary to read the
flag ahead of time.
Step
1
2
3
Read
Bit manipulation
Write
Description
Read data (byte unit) at the specified address
Modify the specified bit in the read data
Write the modified data (byte unit) to the specified address
In the following example, a BCLR instruction is executed on the data direction register (DDR) of
port 4.
P47 and P46 are set as input pins, and are inputting low-level and high-level signals, respectively.
P45 to P40 are set as output pins, and are in the low-level output state.
In this example, the BCLR instruction is used to make P40 an input port.
Before Execution of BCLR Instruction
Input/output
DDR
DR
P47
Input
0
1
P46
Input
0
0
P45
Output
1
0
P44
Output
1
0
P43
Output
1
0
P42
Output
1
0
P41
Output
1
0
P40
Output
1
0
Execution of BCLR Instruction
BCLR #0, @P4DDR ; Execute BCLR instruction on DDR
Rev. 3.00 Sep 27, 2006 page 53 of 872
REJ09B0325-0300