Quiz Entry - updated: 2026.07.14
What are the two-operand arithmetic and logical instructions in x86-64?
They follow the form op S, D, where the destination is also an operand: the result is D ← D op S (the destination is read, combined with the source, and overwritten).
This "destination doubles as an operand" shape is the heart of x86's two-operand format and explains why add %rbx, %rax means "%rax += %rbx."
| Instruction | Effect |
|---|---|
add S, D |
D ← D + S |
sub S, D |
D ← D − S |
imul S, D |
D ← D × S (signed) |
and / or / xor S, D |
bitwise D ← D op S |
sal / shl k, D |
D ← D << k (left shift) |
sar k, D |
D ← D >> k (arithmetic, sign-preserving) |
shr k, D |
D ← D >> k (logical, zero-fill) |
lea S, D |
D ← address of S |
Two points the slides stress:
- There is no two-operand
idiv— division uses the special single-operand form with%rdx:%rax. - A shift amount
kis either an immediate constant or the value in%cl.
Non-commutative warning: sub a, b (b−a) is not sub b, a (a−b) — order matters for subtract and the shifts.
Go deeper:
Felix Cloutier — SAL/SAR/SHL/SHR — the shift family listed in the two-operand table.