Chapter 4 (Section 3) Final Revision #1
No description yet. This curated deck is ready for daily study.
Card preview (24)
Key Terms and Definitions
What is a “shift” in binary terms?
Moving the bits stored in a register a given number of places within the register.
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.
What is the difference between monitoring and control (in terms of using sensor data)?
Monitoring: automatically takes readings from a device. Control: takes readings AND uses that data to adjust the device.
Types of Binary Shifts
What is a logical shift?
A shift in which bits shifted out of the register are simply discarded, and zeros are introduced at the opposite end.
What is the defining characteristic of an arithmetic shift?
The sign of the number is preserved (the leftmost / sign bit is treated specially so the value retains its sign).
What happens during a left arithmetic shift?
• The leftmost bit is shifted out, and a 0 is introduced at the rightmost end. • This multiplies the binary number by 2 for each shift (or overflow occurs).
What happens during a right arithmetic shift?
• The rightmost bit is shifted out, and the leftmost (sign) bit is preserved/duplicated to maintain the sign of the number. • This divides the binary number by 2 for each shift, keeping the sign intact (underflow may occur).
What is a cyclic shift, and how does it differ from logical/arithmetic shifts?
A cyclic shift loses no bits — bits shifted out of one end of the register are introduced at the opposite end.
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).
Assembly Shift Instructions
What does the instruction “LSL n” do?
Logically shifts the bits in the Accumulator (ACC) n places to the left, introducing zeros at the right.
What does the instruction “LSR n” do?
Logically shifts the bits in the Accumulator (ACC) n places to the right, introducing zeros at the left.
Which register is always used when performing shift instructions?
The Accumulator (ACC).
Logical Operations as Masks (AND / OR / XOR)
How is the AND operator used as a mask?
To identify or “keep” specific bits, while clearing (setting to 0) all others. A bit ANDed with 1 stays the same; ANDed with 0 becomes 0.
How is the OR operator used as a mask?
To “set” specific bits to 1, while keeping all other bits as they are. A bit ORed with 1 becomes 1; ORed with 0 stays the same.
How is the XOR operator used as a mask?
To “toggle” (invert) specific bits, while keeping others the same. A bit XORed with 1 is flipped; XORed with 0 stays the same.
Assembly Opcodes for Logical Operations
What are the two types of operand allowed for the AND, OR, and XOR opcodes?
A denary or binary number (n) — i.e. an immediate value, or a memory address (<address>).
Where are the results of logical bit-manipulation instructions always stored?
In the Accumulator (ACC).