I read a few posts on the forum about DEBUG, and I also wanted to mess around with DEBUG. It's a long story. DEBUG is really ancient, but if you use it well, it can be very powerful.
A few days ago SARS was going around, and I was afraid of being quarantined, so I ran back home. For a person like me who doesn't even want to live without a computer, how could I possibly stay home for long? So I tried every possible way to borrow a computer. This computer seemed even older than DEBUG. Not only did it have no CD-ROM drive, even the floppy drive was broken. I couldn't install any software at all. It didn't even have the most basic QBASIC. But after checking with DIR, there was still a DEBUG. Fine, I'd use it to write assembly. But it only supports basic assembly. After each press of Enter, the assembly is compiled into instructions right away, which makes it hard to modify. There aren't even labels, only addresses. Every time after finishing, I had to write down the jump addresses from the assembled program, then rewrite it all over again. Too tiring. So I thought of a method: first write the program with software like EDIT, then pass it to debug with DOS commands, put the output into a file, then modify the jump addresses in the source program, and then assemble it again, and it's OK!
Talking without doing won't do, so here's an example:
c:\>edit x.txt
Enter EDIT and edit x.txt
a
mov ah,9
mov dx,100
int 21h
int 20h
db 'Hello','$'
n x.com
rcx
20
w
q
Note that there must be a carriage return before n x.com above! Anyone who knows assembly knows this is a program that outputs a string, but before designing it it's hard to calculate the string address, so in DX I just randomly set it to 100, then execute the following command:
c:\>debug out.txt
After this command finishes, there will be an out.txt
-a
0BD4:0100 mov ah,9
0BD4:0102 mov dx,100
0BD4:0105 int 21
0BD4:0107 int 20
0BD4:0109 db 'Hello','$'
0BD4:010F
-n x.com
-rcx
CX 0000
:20
-w
Writing 00020 bytes
-q
We can see that the string address is 0109, so the value in DX must also be 0109. This program is F bytes long, so the line under RCX should not be 20, it should be F. This way, with just two passes you can generate an X.com.
I wonder whether any forum friends have an even better method than this? Say it out, and let's improve together!
A few days ago SARS was going around, and I was afraid of being quarantined, so I ran back home. For a person like me who doesn't even want to live without a computer, how could I possibly stay home for long? So I tried every possible way to borrow a computer. This computer seemed even older than DEBUG. Not only did it have no CD-ROM drive, even the floppy drive was broken. I couldn't install any software at all. It didn't even have the most basic QBASIC. But after checking with DIR, there was still a DEBUG. Fine, I'd use it to write assembly. But it only supports basic assembly. After each press of Enter, the assembly is compiled into instructions right away, which makes it hard to modify. There aren't even labels, only addresses. Every time after finishing, I had to write down the jump addresses from the assembled program, then rewrite it all over again. Too tiring. So I thought of a method: first write the program with software like EDIT, then pass it to debug with DOS commands, put the output into a file, then modify the jump addresses in the source program, and then assemble it again, and it's OK!
Talking without doing won't do, so here's an example:
c:\>edit x.txt
Enter EDIT and edit x.txt
a
mov ah,9
mov dx,100
int 21h
int 20h
db 'Hello','$'
n x.com
rcx
20
w
q
Note that there must be a carriage return before n x.com above! Anyone who knows assembly knows this is a program that outputs a string, but before designing it it's hard to calculate the string address, so in DX I just randomly set it to 100, then execute the following command:
c:\>debug out.txt
After this command finishes, there will be an out.txt
-a
0BD4:0100 mov ah,9
0BD4:0102 mov dx,100
0BD4:0105 int 21
0BD4:0107 int 20
0BD4:0109 db 'Hello','$'
0BD4:010F
-n x.com
-rcx
CX 0000
:20
-w
Writing 00020 bytes
-q
We can see that the string address is 0109, so the value in DX must also be 0109. This program is F bytes long, so the line under RCX should not be 20, it should be F. This way, with just two passes you can generate an X.com.
I wonder whether any forum friends have an even better method than this? Say it out, and let's improve together!

