Bahadir Selcuk

Flag Clearing methods with codewarrior

Discussion created by Bahadir Selcuk on Nov 9, 2007
Latest reply on Nov 9, 2007 by kef
I am trying to use PIT module in MC9S12XDT512. I found S12PIT24B4CV1 document about it. But I couldn't understand that how to do flag clearing (without BSET) by codewarrior. When I looked at disassambled code I see that always BSET instructions for clear commands. Is there any way for clearing flag with MOV instruction (but without writing assembly).


13.5.3 Flag Clearing

A flag is cleared by writing a one to the flag bit. Always use store or move instructions to write a one in

certain bit positions. Do not use the BSET instructions. Do not use any C-constructs that compile to BSET

instructions. “BSET flag_register, #mask” must not be used for flag clearing because BSET is a

read-modify-write instruction which writes back the “bit-wise or” of the flag_register and the mask into

the flag_register. BSET would clear all flag bits that were set, independent from the mask.

For example, to clear flag bit 0 use: MOVB #$01,PITTF.