home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,535 of 4,675   
   JJ to Jean pierneef   
   Re: Debug.exe Memory location.   
   26 Dec 22 18:30:21   
   
   From: jj4public@nospicedham.outlook.com   
      
   On Mon, 26 Dec 2022 01:23:31 -0800 (PST), Jean pierneef wrote:   
   > For the purpose of getting to grips with debug.exe on MSDOS 6.22 I have   
   > the following code example:   
   >   
   > .model tiny   
   > .data   
   > msg DB 'test string',0   
   > .code   
   > start:   
   > mov al,msg   
   > end start   
   >   
   > When I compile it with tasm /zi t.asm and link it with tlink t I get the   
   > following behaviour in debug.exe:   
   >   
   > When pressing 'r' to show registers and next command, I get:   
   >   
   > mov al,[0008] as the next instruction to execute.   
   >   
   > I was expecting the memory location of 'test string' to thus be at   
   > ds:0008 but when I do:   
   >   
   > d ds:0108   
   >   
   > 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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca