Bit Manipulation Flashcards
operand instruction for logical and
AND
operand instruction for logical or
ORR
operand instruction for logical not
MVN
operand instruction for logical exclusive or
EOR
what instruction can be used to set
AND
what does set mean
change to 1
what does clear mean
change to 0
uses for bit manipulation
working with floats]
writing code that controls hardware eg turn on/off LEDS
if you have X AND 0 what will this result in
0
if you have X AND 1 what will this result in
X
if we want to clear bits in positions 3 and 4, what do we do
use AND
with a mask which contains all 1s and only 0s in the positions we want to clear
what does the BIC function do
clears with the mask we have already defined
if we want to set bits in positions 3 and 4, what do we do
use ORR
with a mask which contains all 0s and only 1s in the positions we want to set
if you have X OR 1 what will this result in
1
if you have X OR 0 what will this result in
0
what function can be used to invert certain bits
EOR
if we want to invert bits in positions 3 and 4, what do we do
use EOR,
with a mask with 1s in the positions we want to invert and 0s everywhere else
how can bit manipulation be used for difference between upper and lower case letters
only difference between upper and lower case letters is the 6th bit (because 0x20 difference)
we can convert to upper case by clearing 6th bit
we can convert to lower case by setting 6th bit
what instruction is used for a logical shift left
LSL
when a 32 bit is shifted to the left where does the MSB go
discarded
when a 32 but is shifted to the left what does the LSB change to
0
by how many bit positions can you shift
from 0 to 31
Logical shift left is the same as
Multiplying by 2n.
An effective way to perform multiplication by powers of 2
what instruction is used for logical shift right
LSR