English
Language : 

HD6473032F16 Datasheet, PDF (73/847 Pages) Renesas Technology Corp – Hardware Manual Renesas 16-Bit Single-Chip Microcomputer H8 Family/H8/300H Series
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 on-chip 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
After Execution of BCLR Instruction
Input/output
DDR
DR
P47
Output
1
1
P46
Output
1
0
P45
Output
1
0
P44
Output
1
0
P43
Output
1
0
P42
Output
1
0
P41
Output
1
0
P40
Input
0
0
Rev. 3.00 Mar 21, 2006 page 43 of 814
REJ09B0302-0300