At program start, DS is initially set to the PSP - which may not be the same
as the program's data segment. Depending on the memory model, the program's
data segment may be same as the program's code segment. e.g. Tiny model.
Unless Tiny model is used, and the code starts at 100h, and the source is
compiled to a COM binary (i.e. with `tlink /t`), the program's code segment
will be different than the PSP segment.
Your code is not compiled into a COM binary, so PSP, data segment, and code
segment, are all different. At program startup, DS points to the PSP
segment. Not the data segment. For programs where its code and data segments
are different, the program must manually set the DS register to point to its
data segment. Usually, it's done at program startup like below.
mov ax, dgroup
mov ds, ax
DEBUG does not execute any of the program code when loading a program. So,
any program's initialization code, are not executed. Meaning that, the DS
register still point to the PSP, and not the data segment. Since your code
doesn't set the DS register to its data segment, below code:
mov al, msg
It takes data from the PSP, rather than the data segment.