- Asked 3/22
- 2078 Bhadra · 8 marks
- 2073 Chaitra · 10 marks
- 2067 Asar (old course) · 8 marks
Data manipulation instructions
Short answer
Data manipulation instructions perform arithmetic (ADD, SUB, MUL, DIV), logical (AND, OR, XOR, NOT for bitwise masking/setting/toggling), and shift operations (logical, arithmetic, rotate). They modify data and set condition flags for branching.
Explain the different types of data manipulation instructions with examples.
Data manipulation instructions perform operations on data and give the computer its computational ability. They fall into three groups: arithmetic, logical and bit manipulation, and shift instructions. (The mnemonics follow the typical instructions listed by Mano.)
1. Arithmetic instructions
| Name | Mnemonic | Example operation |
|---|---|---|
| Increment | INC | R1 = R1 + 1 |
| Decrement | DEC | R1 = R1 - 1 |
| Add | ADD | R1 = R1 + R2 |
| Subtract | SUB | R1 = R1 - R2 |
| Multiply | MUL | R1 = R1 × R2 |
| Divide | DIV | R1 = R1 ÷ R2 |
| Add with carry | ADDC | R1 = R1 + R2 + C |
| Subtract with borrow | SUBB | R1 = R1 - R2 - C |
| Negate (2's complement) | NEG | R1 = -R1 |
2. Logical and bit manipulation instructions
| Name | Mnemonic | Effect |
|---|---|---|
| Clear | CLR | R = 0 |
| Complement | COM | R = R' |
| AND | AND | Clear selected bits (mask) |
| OR | OR | Set selected bits |
| Exclusive-OR | XOR | Complement selected bits |
| Clear carry | CLRC | C = 0 |
| Set carry | SETC | C = 1 |
| Complement carry | COMC | C = C' |
| Enable / disable interrupt | EI / DI | IEN = 1 / 0 |
Example: ANDing R1 with the mask 0000 1111 keeps the lower four bits: 1011 0110 AND 0000 1111 = 0000 0110.
3. Shift instructions
| Name | Mnemonic | Effect |
|---|---|---|
| Logical shift right / left | SHR / SHL | Shift, insert 0 |
| Arithmetic shift right / left | SHRA / SHLA | Sign bit kept (right) |
| Rotate right / left | ROR / ROL | Bit leaves one end, enters the other |
| Rotate through carry | RORC / ROLC | Carry takes part in rotation |
Example: R1 = 1001 0110. SHR gives 0100 1011; SHRA gives 1100 1011; ROL gives 0010 1101.
These instructions change the processor status flags (carry, zero, sign, overflow), which are then tested by branch instructions.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Data manipulation: logical and bit instructions · Computer Organization and Architecture, chapter 2 · asked 2×
All Computer Organization and Architecture chapter 2 questions →