assemblyx86tasmmemory-segmentation

Why do we need AX instead of MOV DS, data directly with a segment?


So I was being taught the basics of how to program with Tasm (Turbo assembler 16 bits) and these two lines were explained to me, but now I can't remember why have to do it like this:

start: mov ax, data
       mov ds, ax

Why is it that we cannot set DS directly to a data segment we defined?

start: mov ds, data

Solution

  • The reason that you cannot do it is not a limitation in TASM but a "feature" of the instruction set. The Intel/AMD instruction sets do not support moving an immediate value into the DS register.

    It is not unusual in CISC based computers to have various restrictions and limitations. It is very useful to keep the instruction reference handy for this reason. :)