Problem when printing message in debug - Windows

6

I'm doing an assembly programming practice, about the Windows debug tool for 32 bits.

The proposed exercise is as follows:

  

Beginning at the 012F Memory position design an algorithm that   show on the screen the following flow of characters "This is my   first program in the DEBUG "

They gave us an example of how to print the typical "Hello World" in assembler.

Following this example, then I proceeded to write my version depending on the proposed exercise:

-a
   jmp 120

-e 0102 "Este es mi primer programa en debug" 0a 0d "$"
-a 120
   mov ah,09
   mov dx,0102
   int 21
   int 20

All this code, I wrote it, based on the functional example. The only thing that I have changed is the text.

But when executing the program (that is, executing the -g instruction).

I get the following result:

I do not understand where the problem is, I have reviewed the notes, regarding the instructions, but I do not understand what has failed.

My question is:

What is the mistake I made, which leads me to get the wrong result?

    
asked by Ivan Botero 01.04.2017 в 17:04
source

1 answer

5

Change your code to the following:

-a
   jmp 130

-e 0102 "Este es mi primer programa en debug" 0a 0d "$"
-a 130
   mov ah,09
   mov dx,0102
   int 21
   int 20

-g

I'm not very good with assembler, but what I can notice is that your string is located in the 0102 position and your application starts at 0120 .

Now, being

  

"This is my first debug program"

longer than

  

"Hello world"

needs more positions available to be copied. Therefore, when you start writing the application in the position 0120 , you are overwriting the string and when you try to print it does not find the end of the string "$" .

So what we are doing with the location 0130 is to start the application a little further away so that the string has enough space to be copied.

    
answered by 12.04.2017 / 18:46
source