Why does code in MS-DOS Debug does not run and makes the prompt disappear?

88 Views Asked by At

I'm writing this code in DOSBox-0.74-3, making use of MS-DOS Debug and once I run it makes the prompt disappear and it does not do anything else.

mov cx,16
db 0d,0a,"placeholder",0d,0a,24
mov ah,09
mov dx,(Memory address of db)
int 21
loop (Memory address of mov ah,09)
mov ah,4c
int 21

What it should do is show the message 'Placeholder' 22 times, but it is not doing it. I have been able to run other simple codes as this one.

1

There are 1 best solutions below

3
paxdiablo On
mov cx,16
db 0d,0a,"placeholder",0d,0a,24
mov ah,09

If you're starting to run your code at the first line above, it's probably not going to do what you expect when it starts executing the data created by the db statement.

By all means manipulate data with your code but it's a rather bad idea to attempt to execute it as if it were code :-)

So the first thing I would do is get that data out of the code area, with something like (added labels to make the code more readable, use of debug means you'll probably have to pre-calculate memory locations unless you want to enter some instructions more than once):

         mov cx, 16
again:   mov ah, 09
         mov dx, my_data
         int 21
         loop again
         mov ah, 4c       ; 'mov ax, 4c00' for zero return code.
         int 21

my_data: db 0d,0a,"placeholder",0d,0a,24

There may still be issues with that code (such as returning a non-zero code in al) but you at least won't be attempting to execute data as code.