Search code examples
assemblyx86nasmaccumulatoraddressing-mode

Why does the mov instruction have use ax instead of two segment registers directly?


I see code like:

mov ax, cs
mov ds, ax
mov es, ax

Why can't I just compress this to:

mov ds, cs
mov es, cs

Is the first way faster since its using the accumulator register? But that wouldn't seem intuitive since cs and ds are segment registers. Or is there some restriction that I'm unaware of?

I'm using nasm by the way.


Solution

  • You can't mov segment register to segment register -- there's no instruction for it.