Assembler mov issue

前端 未结 3 1490
庸人自扰
庸人自扰 2021-01-25 08:24

I have the next code:

mov  ax,@data
mov  ds,ax

Why I can not write just like this?

mov ds,@data

All source:

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-25 08:52

    You can't, because the instruction set doesn't contain an instruction to do that. It is just one of the many idiosyncrasies of the x86.

    These kind of restrictions are fairly normal for assembly languages. Most architectures contain some registers that are treated specially (for example the processor status word), though usually fewer than the x86 architecture.

    The reason to not provide an instruction for all possible moves is to reduce the size of the instruction set, so that an instruction takes less memory. Overall it is more efficient to do moves that are rarely needed in two steps.

提交回复
热议问题