Question

I would like to understand how Turbo Debugger works. So, for example, I have a message and I moved it to the DX register.

(I show you how it looks in the debugger):

MOV DX,009E   ;This is a version which debugger shows me in debugger mode;
              ;It takes all information from this code: MOV DX,OFFSET MSG.

In fact, the message's first element address is at 9E (this is how the debugger understands). But actually, in the debugger screen, I can see that in the DS register, MSG address is at A0. How can it be?

I know that code is more preferable, but this time a screenshot is more suitable:

enter image description here

As you can see, I marked 2 addresses, but they are not the same. Actually, I can see that my MSG begins in the above-marked address A0, but that the debugger understands it like 9E and moves it to DX. Can someone explain to me how this can be?

By the way, the program works and prints everything fine, the purpose is to understand how the debugger understands addresses.

MSG code is simply:

MSG db 'Hello, how do you do!!!!,'$'
Was it helpful?

Solution

I believe that if you will single step your code, instruction by instruction, you will see that

  • You are correct that that your message starts at DS:00A0
  • Turbo Debugger is also correct that it starts two bytes before that

Look carefully at what is located at DS:009E.

What do you see there ? Two bytes: 0A and 0D

That's an ascii "Line Feed" and an Ascii "Carriage Return".

Your confusion can be reduced by understanding the historical perspective...

Way back when printers used ink and paper, and telephones carried modem signals at 1200 BPS, and you paid something like ten hours of minimum wage pay for one hour of that connection to a city only three states away, there really was an economic imperative in choosing between running the little print head back to the left, or just jacking the platen down a line while the print head stayed in the same position.

I mean, you really saw it in your phone bill.

No joke, this one change, using the 0A byte without the 0D byte, could mean a 10 or 20 dollar difference in your phone bill; and remember to factor in inflation back then.

The reason that you see the message properly is because your machine is first placing a "line feed" (i.e., the cursor is probably dropping to the next line) and a "carriage return" (i.e., the cursor jumps back to the left edge) before putting your message on the screen. This happens much faster than your eye can see.

With the miracle of Turbo Debugger, you can single step this and watch it happen.

So, you are correct when you write that your message "starts" at 00A0, but Turbo Debugger is also right when it's telling you that the message starts two bytes ahead of that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top