YEAR 2 CO1 WEEK 6 BITWISE MANIPULATION Flashcards
What is BitWise Manipulation used for?
Used for quickly doubling and halving
Encryption and decryption
Setting/resetting flags
Graphics Manipulation
Compression algorithms
How does Logical (Unsigned) Shift Left Work?
All digits are moved to the left.
Most significant bit (MSB) removed and a 0 added in place of Least Significant bit (LSB)
How does Logical(Unsigned) Right Shift?
Digits all moved to the right.
LSB removed and a 0 added in place of MSB.
How does Circular Shift Work?
With circular right shift, LSB copied into MSB. Everything else shifted to the right.
With circular left shift, MSB copied to LSB. Everything shifted to the left.
How does Arithmetic(Signed) Right Shift?
All digits moved to the right except the MSB that stays in the same place to preserve negativity or positivety of the number. MSB then copied to the right of it. LSB is removed.
How does Arithmetic(Signed) Left Shift?
All digits moved to left except MSB stays in same order to preserve negativety and positivety of number.
Describe Masking?
Allows you to check the value of a particular bit in binary number. Used because not possible to read and write those bits individually.
Describe AND Masking.
If wanted to find value of 5th bit of an 8th bit binary number
Mask uses 0s for each bit value except the position of bit you want to check in the binary number.
Logical AND operation then performed on the two numbers and would result in a 1 If both are 1s or else a 0.
Describe OR Masking.
If MASK bit is false, then value written to A is the same as it was.
If MASK bit true, then value of A is set (forced to be true)
Describe XOR Masking.
If the MASK bit is FALSE, then value written to A the same as what was already there.
If MASK bit is TRUE, then value written to A is the opposite of what was already there.