Section 1: Key Terms & Definitions
What is a “Shift” in binary terms?
Moving the bits stored in a register a given number of places within the register.
Define “Monitoring” versus “Control.”
Monitoring is to automatically take readings from a device.
Control is to take readings and then use that data to adjust the device. Uses feedback.
What is a “Mask” in bit manipulation?
A number used with logical operators (AND, OR, XOR) to identify, remove, or set a single bit or a group of bits in an address or register.
Section 2: Types of Binary Shifts
What happens in a “Logical Shift”?
Bits shifted out of the register are replaced with zeros.
What is the defining characteristic of an Arithmetic Shift?
Detail what happens for left and right Arithmetic Shifts.
The sign of the number is preserved.
For left shifts:
1. The leftmost bit is shifted out, and a 0 is introduced on the rightmost end.
2. This multiplies the binary number by 2 (for each shift) or overflow occurs.
For right shifts:
1. The rightmost bit is shifted out and the leftmost bit is preserved to maintain the sign of the number. This means that the leftmost bit is duplicated.
2. This divides the binary number by 2 (for each shift), keeping the sign intact, underflow may occur.
How does a “Cyclic Shift” differ from other shifts?
No bits are lost; bits shifted out of one end are introduced at the opposite end of the register.
Section 3: Mathematical Effects of Shifts
What is the mathematical effect of a Left Shift?
It effectively multiplies the binary number by 2 for each place shifted (unless overflow occurs).
What is the mathematical effect of a Right Shift?
It effectively divides the binary number by 2 for each place shifted (underflow may occur).
Section 4: Assembly Language Shift Instructions
What does the instruction “LSL n” do?
It shifts the bits in the Accumulator (ACC) logically n places to the left, introducing zeros at the right.
What does the instruction “LSR n” do?
It shifts the bits in the Accumulator (ACC) logically n places to the right, introducing zeros at the left.
Which register is always used when performing shift instructions?
The Accumulator (ACC).
Section 5: Logical Operations for Bit Manipulation
How is the “AND” operator used as a mask?
It is used to identify or “keep” specific bits while clearing (setting to 0) all others.
How is the “OR” operator used as a mask?
It is used to “set” specific bits to 1 while keeping all other bits as they are.
How is the “XOR” operator used as a mask?
It is used to “toggle” (invert) a specific bit while keeping others the same.
Section 6: Assembly Opcodes for Logical Operations
What are the two types of operands allowed for the AND, OR, and XOR opcodes?
A denary/binary number (n) or a memory address (<address>).
Where are the results of logical bit manipulation instructions always stored?
In the Accumulator (ACC).
What can the “<address>” represent in these instructions?
It can be an absolute address or a symbolic address (label).
Section 7: Practical Monitoring & Control Examples