2024 Bitwise Operators
2024 Bitwise Operators
Vs.
In the descriptions below x represents ONE BIT, 0 and 1 represent bit values and ~x represents
the complementary value of the value bit x. The descriptive sequences below exemplify the
mode of action of the AND, OR and XOR operations AT THE BIT LEVEL as the MECHANISM of
action, regardless of whether the respective operation is triggered at the source code level by
the respective OPERATOR or by the corresponding INSTRUCTION.
| - bitwise OR operator x OR 0 = x ; x OR x = x
OR – instruction x OR 1 = 1 ; x OR ~x = 1
In C - !0 = 1 (0 = false, anything different from 0 = TRUE, but a predefined function will set
TRUE =1)
~ 1’s Complement: mov al, ~0 => mov AL, 0ffh (bitwise operator !)
(because a 0 in asm is a binary ZERO represented on 8, 16, 32 or 64 bits the logical BITWISE
negation – 1’s complement - will issue a binary 8 of 1’s, 16 of 1’s, 32 of 1’s or 64 of 1’s… )
a d?....
b d?...
Mov eax, ![a] - because [a] is not something computable/determinable at assembly time, this
instruction will issue a syntax error ! – (expression syntax error)
Mov eax, [!a] - ! can only be applied to SCALAR values !! (a = pointer data type ≠ scalar !)
aa equ 2
mov ah, !aa ; AH=0