- Asked 2/22
- 2069 Chaitra · 3+5 marks
- 2069 Asar · 5 marks
Data manipulation: logical and bit instructions
Short answer
Data manipulation instructions include logical and shift operations. Logical instructions: AND (mask bits), OR (set bits), XOR (toggle), and COM (complement) work bitwise. Shift instructions: logical shift (insert 0), arithmetic shift (preserve sign), and rotate through carry. Example: AND R1,00001111 extracts low nibble.
Define data manipulation instruction. Explain the logical and bit manipulation instructions with mnemonic code.
A data manipulation instruction performs operations on the data stored in registers or memory and gives the computer its computational capability. The three types are arithmetic, logical and bit manipulation, and shift instructions.
Logical and bit manipulation instructions
These work on each bit of the operand separately. They treat the register as a string of bits, not a number.
| Instruction | Mnemonic | Operation and use |
|---|---|---|
| Clear | CLR | Set all bits to 0 |
| Complement | COM | Change every 0 to 1 and 1 to 0 |
| AND | AND | Bitwise AND; clears selected bits (masking) |
| OR | OR | Bitwise OR; sets selected bits |
| Exclusive-OR | XOR | Bitwise XOR; complements selected bits |
| Clear carry | CLRC | C = 0 |
| Set carry | SETC | C = 1 |
| Complement carry | COMC | C = C' |
| Enable interrupt | EI | IEN = 1 |
| Disable interrupt | DI | IEN = 0 |
Examples with R1 = 1011 0110:
AND R1, 0000 1111 -> 0000 0110 (mask: keep low nibble)
OR R1, 0000 1111 -> 1011 1111 (set low nibble)
XOR R1, 1111 0000 -> 0100 0110 (toggle high nibble)
COM R1 -> 0100 1001
CLR R1 -> 0000 0000
Shift instructions (bit movement)
| Instruction | Mnemonic | Effect |
|---|---|---|
| Logical shift right | SHR | 0 enters at the left end, right bit goes to carry |
| Logical shift left | SHL | 0 enters at the right end |
| Arithmetic shift right | SHRA | Sign bit kept and copied (divide by 2) |
| Arithmetic shift left | SHLA | Multiply by 2; overflow if sign changes |
| Rotate right / left | ROR / ROL | Bit leaving one end enters the other end |
| Rotate right / left with carry | RORC / ROLC | Carry flag is part of the loop |
For R1 = 1001 0110: SHR = 0100 1011, SHRA = 1100 1011, SHL = 0010 1100, ROL = 0010 1101.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Data manipulation instructions · Computer Organization and Architecture, chapter 2 · asked 3×
- Instruction and data format, addressing modes · Microprocessor, chapter 2 · asked 2×
- 3-bit Gray code synchronous counter · Digital Logic, chapter 8 · asked 2×
- Speech characteristics and 7-bit Hamming code · Wireless Communication, chapter 6
- BCD code and 3-bit binary-to-Gray converter · Digital Logic, chapter 1
All Computer Organization and Architecture chapter 2 questions →