Skip to main content

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

NameMnemonicExample operation
IncrementINCR1 = R1 + 1
DecrementDECR1 = R1 - 1
AddADDR1 = R1 + R2
SubtractSUBR1 = R1 - R2
MultiplyMULR1 = R1 × R2
DivideDIVR1 = R1 ÷ R2
Add with carryADDCR1 = R1 + R2 + C
Subtract with borrowSUBBR1 = R1 - R2 - C
Negate (2's complement)NEGR1 = -R1

2. Logical and bit manipulation instructions

NameMnemonicEffect
ClearCLRR = 0
ComplementCOMR = R'
ANDANDClear selected bits (mask)
ORORSet selected bits
Exclusive-ORXORComplement selected bits
Clear carryCLRCC = 0
Set carrySETCC = 1
Complement carryCOMCC = C'
Enable / disable interruptEI / DIIEN = 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

NameMnemonicEffect
Logical shift right / leftSHR / SHLShift, insert 0
Arithmetic shift right / leftSHRA / SHLASign bit kept (right)
Rotate right / leftROR / ROLBit leaves one end, enters the other
Rotate through carryRORC / ROLCCarry 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)

All Computer Organization and Architecture chapter 2 questions →