17
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 port control register 4 (PCR4) under the
following conditions.
P47:
Input pin, Low
P46:
Input pin, High
P45 - P40:
Output pins, Low
The intended purpose of this BCLR instruction is to switch P40 from output to input.
Before Execution of BCLR Instruction
P47
P46
P45
P44
P43
P42
P41
P40
Input/output
Input
Input
Output
Output
Output
Output
Output
Output
Pin state
Low
High
Low
Low
Low
Low
Low
Low
PCR4
0
0
1
1
1
1
1
1
PDR4
1
0
0
0
0
0
0
0
Execution of BCLR Instruction
BCLR
#0 @PCR4
;clear bit 0 in PCR4
After Execution of BCLR Instruction
P47
P46
P45
P44
P43
P42
P41
P40
Input/output
Output
Output
Output
Output
Output
Output
Output
Input
Pin state
Low
High
Low
Low
Low
Low
Low
High
PCR4
1
1
1
1
1
1
1
0
PDR4
1
0
0
0
0
0
0
0
Summary of Contents for H8/300L Series
Page 1: ...H8 300L Series Programming Manual ...
Page 6: ...iv ...
Page 8: ...2 ...
Page 11: ......
Page 14: ......
Page 46: ......
Page 48: ......
Page 60: ......
Page 83: ......
Page 116: ......
Page 150: ...144 ...
Page 151: ......
Page 156: ...150 ...