Post by Jean pierneef
For the purpose of getting to grips with debug.exe on MSDOS 6.22 I have
msg DB 'test string',0
When I compile it with tasm /zi t.asm and link it with tlink t I get the
mov al, as the next instruction to execute.
I find 'test string' there instead (and garbage at ds:0008).
Can somebody please explain why 0100h is 'subtracted' from 0108h when I
do the 'r' command in debug.exe ?
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.