MOV in 8086 Assembly: Syntax, Forms and Examples

MOV is the instruction you will use more than any other in 8086 assembly. It copies data from a source to a destination: a register, a memory location, or a segment register. It does not do arithmetic, and it does not change any flags, which makes it safe to use between a comparison and a conditional jump.

The basic syntax

MOV destination, source

The destination and the source must be the same size: you cannot move a 16-bit register into an 8-bit register, or a byte into a word, without an explicit size step in between. The two operands also cannot both be memory locations. If you need to copy memory to memory, move the value through a register first.

The forms you will actually use

Form Example Notes
Register to register MOV BX, AX Both operands the same size.
Immediate to register MOV AX, 1234h The value is written into the instruction itself.
Register to memory MOV [SI], AL Stores AL at the address in SI.
Memory to register MOV AX, [1234h] Loads a word from a fixed address.
Immediate to memory MOV BYTE PTR [DI], 0 The size keyword is needed because the value alone does not say byte or word.
Segment register MOV DS, AX Segment registers are loaded through a general register, never directly from an immediate value.

Rules that catch beginners

  • MOV never affects the flags. After CMP AX, BX, a MOV will not disturb the result, so you can set up a value and then jump on the comparison.
  • You cannot move one segment register to another directly. MOV DS, ES is not allowed; go through AX.
  • CS cannot be the destination. The code segment is changed by jumps, calls and returns, not by MOV.
  • An immediate value cannot go straight into a segment register. MOV DS, 1000h is not allowed; load AX first, then MOV DS, AX.
  • Byte and word registers are separate views. AX is made of AH (high byte) and AL (low byte). MOV AL, 0FFh leaves AH untouched.

Worked example: setting up a data segment

The classic opening of an 8086 program loads DS so the program can reach its own data. In a .COM program DS already points at the program segment, but the pattern is the same in both program models:

; Load a data segment address through AX.
MOV AX, @data
MOV DS, AX

; Copy a value through a register, not memory to memory.
MOV AX, [counter]
MOV [result], AX

; Clear a register with an immediate value.
MOV BX, 0
RET

Common mistakes

The three most frequent MOV errors are a size mismatch (MOV AX, BL), a memory-to-memory move (MOV [DI], [SI]), and forgetting that MOV leaves the flags alone and then wondering why a jump after a MOV behaves as if the earlier comparison never happened. It behaves that way because the flags really were preserved, which is usually what you want.

What to learn next

Once MOV feels automatic, the next step is arithmetic that does change the flags, and the jumps that read them. The ADD and CMP post covers both, and the addressing modes and flags post explains every way an operand can name a location.

Further reading

Similar Posts