Assembler mov issue

前端 未结 3 1492
庸人自扰
庸人自扰 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:44

    I'm no expert but this is how I understand this constraint to work.

    The Segment registers are used to control which segment of memory is used by the register instructions, as such the last thing you want is to load a segment register (DS in this case which is the Data Segment register) from a memory location. The act of modifying DS could cause the memory location being read to change during the process of updating DS, i.e. the first bits/byte loaded into DS now cause it to be pointing to another segment before the remainder has been read. It's safer to read the value into the Accumulator (AX) or another general purpose register, so now the value is in the processor when it's loaded into the segment register, so no chance of the value getting corrupted during the load.

提交回复
热议问题