![]() That’s because I want the final program to occupy exactly 32 bytes we’ll see the reason for this later on. For this little program I only need the characters for “hello, world!!”. Equivalently, I could type “a 0100” or “a 100” to achieve the same result. By default, instructions will be placed starting from CS:0100, so I’ll use that address. The command for that is “a”, which might be optionally followed by a memory address. I want to assemble, i.e., I want to type assembly language instructions. After we execute DEBUG.COM we’ll meet a prompt with a “-” symbol. I don’t have any use for this, but it comes as a “relaxing” post after several weeks focused on the release of “DragonScales 3: Eternal Prophecy of Darkness” on Steam and the localization of “DragonScales 5: The Frozen Tomb”. Specifically what I want is to build a minimal “hello, world!” program using DEBUG.COM. You could create little programs, or inspect programs and peek memory areas. ![]() However, DEBUG looked pretty cool back then: it could assemble, disassemble and dump hexadecimal output. ![]() Heck, DEBUG isn’t even available on the Windows 10 machine I’m typing this on. So I’ll revisit this here, mostly as a self-imposed disciplinary measure, an exercise on programming, specifically, an exercise on programming futility. I wrote a post about this “hello, world” with DEBUG.COM elsewhere, and yesterday I found the time to reread it: I verified, first with awe, then with horror, and finally, with relief, that I had almost completely forgotten how to code in assembly. I remember trying to code, as expected, the traditional “hello, world!”, using a strange tool included in DOS, DEBUG.COM. First painful steps were taken and first crashes happily followed. The famous RBIL (Ralf Brown’s Interrupt List) was, back then, my favorite “reference”. I remember the masochist approach to learning the opcodes and the hardware architecture. More than two decades ago I used to code in x86 (Intel) assembly, almost daily. Or an exercise on retro, old-school coding. This will probably cause a crash.Coding “Hello world” with DEBUG will be a blunt exercise on programming futility. Your code, as posted, doesn't contain any "exit" to get back to dos. Try it - you won't break anything (probably ). Note that to debug your program, do "debug " - the ".com" has to be there! There are other (better?) debuggers besides "debug", but "debug" is usually available. Tracing through the "bowels of DOS" may be interesting, but my experience is that it crashes debug before you learn much. When you get to "int 21h" (the debugger won't show the 'h'), use 'p' (proceed) not 't' (trace). ![]() The other important command is '?' - this will print out the other commands you can use. When I first tried to use "debug" I didn't know that 'q' would get me back to the command prompt - I had to reboot to get out of "debug". When you do "mov si, 10", you'll see "0A", not "10" - its the same number. Keep in mind that a debugger represents everything as hex. Joe/dogman is correct that stepping through your code in a debugger will help you understand it. The computer stores everything as a series of 1 bits and 0 bits, but we do not usually see the individual bits, even in a debugger. "binary" may be confusing, since we might mean "a string of '1's and '0's" or we might mean "a plain number". "hexadecimal", "decimal" and "binary" are just different ways to represent a number - it's the same number. It's much faster to divide by 2 with a "shr" than with a "div", but "div" works too - try it! If we wanted to print a character '1' followed by a character '0', we could have divided by 2 (10b) instead of 10 decimal (0Ah or 1010b). this "converts" the number 2 to the ascii code for the character '2' (32h or 50 decimal) which is what we want to print. ![]() Then we pop it and add '0' (or 30h or 48 decimal). Since the quotient is zero, we're all done, and the 2 is the only thing pushed to the stack. It is this 2 (or 10b if you like) that gets pushed to the stack. When we divide 10b or 2 decimal by 10 decimal, the quotient is zero (in ax) and the remainer is 2 (in dx). This seems to be where you're going wrong, Tomar. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |