Renesas H8/300 Series Programming Manual page 23

Table of Contents

Advertisement

Notes on Bit Manipulation Instructions: BSET, BCLR, BNOT, BST, and BIST are read-
modify-write instructions. They read a byte of data, modify one bit in the byte, then write the
byte back. Care is required when these instructions are applied to registers with write-only
bits and to the I/O port registers.
Sequence
Operation
1 Read
Read one data byte at the specified address
2 Modify
Modify one bit in the data byte
3 Write
Write the modified data byte back to the specified address
Example 1: BCLR is executed to clear bit 0 in the port 4 data direction register (P4DDR)
under the following conditions.
P4
:
Input pin, Low, MOS pull-up transistor on
7
P4
:
Input pin, High, MOS pull-up transistor off
6
P4
– P4
:
Output pins, Low
5
0
The intended purpose of this BCLR instruction is to switch P4
Before Execution of BCLR Instruction
P4
Input/output
Input
Pin state
Low
DDR
0
DR
1
Pull-up
On
Execution of BCLR Instruction
BCLR
#0
@P4DDR
After Execution of BCLR Instruction
P4
Input/output
Output Output Output Output Output Output Output Input
Pin state
Low
DDR
1
DR
1
Pull-up
Off
P4
P4
7
6
5
Input
Output Output Output Output Output Output
High
Low
0
1
0
0
Off
Off
;clear bit 0 in data direction register
P4
P4
7
6
5
High
Low
1
1
0
0
Off
Off
0
P4
P4
P4
4
3
Low
Low
Low
1
1
1
0
0
0
Off
Off
Off
P4
P4
P4
4
3
Low
Low
Low
1
1
1
0
0
0
Off
Off
Off
17
from output to input.
P4
P4
2
1
Low
Low
1
1
0
0
Off
Off
P4
P4
2
1
Low
High
1
0
0
0
Off
Off
0
0

Advertisement

Table of Contents
loading

Table of Contents