5 bitwise operators (binary), 6 bitwise operators (unary), Bitwise operators (binary) – Motorola HC12 User Manual

Page 151: Bitwise operators (unary)

Advertising
background image

Assembler Syntax

Operators

MCUez HC12 Assembler

User’s Manual

MOTOROLA

Assembler Syntax

151

7.7.5 Bitwise Operators (Binary)

Syntax:

Bitwise AND: <operand> & <operand>

Bitwise OR: <operand> | <operand>

Bitwise XOR: <operand> ^ <operand>

Description:

The & (ampersand) operator performs an AND between the
two operands at the bit level.

The | (vertical bar) operator performs an OR between the two
operands at the bit level.

The ^ (caret) operator performs an XOR between the two
operands at the bit level.

The operands can be any expression evaluating to an absolute
expression.

Example:

$E & 3 ; = $2 (%1110 & %0011 = %0010)

$E | 3 ; = $F (%1110 | %0011 = %1111)

$E ^ 3 ; = $D (%1110 ^ %0011 = %1101)

7.7.6 Bitwise Operators (Unary)

Syntax:

One’s complement: ~<operand>

Description:

The ~ (tilde) operator evaluates the one’s complement of the
operand.

The operand can be any expression evaluating to an absolute
expression.

Example:

~$C ; = $FFFFFFF3 (~%00000000 00000000 00000000 00001100

=%11111111 11111111 11111111 11110011)

Advertising