4.3 ProcessorFundamentals.bit_manipulation Flashcards
What is a shift operation in computing?
Moving the bits stored in a register a given number of places within the register.
What happens in a logical shift?
Bits shifted out of the register are replaced with zeros.
What is an arithmetic shift?
A shift operation where the sign of the number is preserved.
How does a cyclic shift work?
No bits are lost; bits shifted out of one end of the register are introduced at the other end.
What is a monitor in computing?
A system that automatically takes readings from a device.
What is control in computing?
A system that automatically takes readings from a device and uses the data to adjust the device.
What is a mask in computing?
A number used with logical operators (AND, OR, XOR) to identify, remove, or set specific bits in an address or register.
What is a binary shift?
Moving the bits stored in a register a given number of places within the register.
How is shifting used in the IR (Instruction Register)?
Each bit in the IR may be used to identify a different interrupt.
Example: Logical left shift of 10101111 by 3 places?
01111000
Example: Arithmetic right shift of 10101111 by 3 places?
11110101
What is an arithmetic shift used for?
Multiplication or division by powers of two.
Example: Cyclic left shift of 10101111 by 3 places?
01111101
What is a left shift?
Bits are shifted to the left in logical, arithmetic, and cyclic shifts.
What is a right shift?
Bits are shifted to the right in logical, arithmetic, and cyclic shifts.
What does the LSL instruction do?
LSL n shifts the bits in ACC logically left by n places, introducing zeros on the right.
What does the LSR instruction do?
LSR n shifts the bits in ACC logically right by n places, introducing zeros on the left.
Where are shifts always performed in assembly language?
On the ACC (Accumulator).
How is bit manipulation used in monitoring and control?
Each bit in a register or memory location can be used as a flag to track the status of sensors or processes.
How can a control system with eight sensors track processed data?
By using 8 different bits in the same memory location.
What logical operation is used to check if a bit has been set?
AND
What logical operation is used to set a bit?
OR
What logical operation is used to clear a bit that has been set?
XOR
What does the AND n
instruction do?
Performs a bitwise AND operation between the contents of ACC and the operand n.
What does the AND <address>
instruction do?
Performs a bitwise AND operation between the contents of ACC and the contents of <address>.
What does the XOR n
instruction do?
Performs a bitwise XOR operation between the contents of ACC and the operand n.
What does the XOR <address>
instruction do?
Performs a bitwise XOR operation between the contents of ACC and the contents of <address>.
What does the OR <address>
instruction do?
Performs a bitwise OR operation between the contents of ACC and the contents of <address>.
Where are the results of logical bit manipulation stored?
In the ACC (Accumulator).
What can <address>
in bit manipulation instructions represent?
An absolute address or a symbolic address.
How is the operand used in logical bit manipulation?
As a mask to set or clear bits.
Example: Testing Sensor 3 in Assembly Language
Opcode | Operand | Comment
- LDD sensors
→ Load content of sensors into ACC
- AND #B100
→ Mask to select bit 3 only
- CMP #B100
→ Check if bit 3 is set
- JPN process
→ Jump to process routine if bit not set
- LDD sensors
→ Load sensors into ACC
- XOR #B100
→ Clear bit 3 as sensor 3 has been processed