Assembly Language Programming is normally done with the aid of an assembly compilier. Here we will enter the code directly into memory with debug. This is the most basic form of programming. It is also the most difficult because the programmer must know the numbers to enter. There are no memory aids. We should do this at least once so that we can understand the lowest level of programming. Here is some code that I have developed for you to enter.
This is what you will do. Open debug. Use the E command to enter at address 100 a string of numbers. All these numbers are in HEX. Did you learn hex? It is very simple. Hit enter at the end of the line. Use the E command to enter more numbers at address 111. Again hit enter at the end of the line. If you make a mistake you may repeat with no ill effect. If you would like to confirm your entry type D100 and debug will screen dump starting at 100.
You will use the n command for name to name you program bug.com. Change the name if you want but put the com prefix on.
Use the r or register command to load the number of bytes you want to save to disk into register CX. Be sure you have not been playing with BX as it is used as the most significant number with CX for number of bytes to write to disk. If you write, and write, and write you have left a large number in BX. I did that. There were no ill effects except that I had a very huge file of gibberish. BX should contain zero.
Use the W command to write bug.com to disk.
At the debug prompt type:
E100 B4 09 BA 07 01 CD 21 4D 52 20 48 41 52 52 45 4C 4C
E111 20 49 53 20 47 52 45 41 54 21 24 B4 4C CD 21
You have now entered a machine language program. To save it at the prompt enter:
n bug.com
r cx
:11E
w
you may use D100 to be sure your entry was correct. You may E any address to correct an entry.
use the q command to quit debug.
Debug will report that 11E bytes have been written to disk return to DOS with the Q command and run your program by typing bug and the enter key.
Your program will run and deliver an important message if you have done everything correctly! If it fails to run guess whose fault it is.
This is what we are doing. We are loading register AH with 09. ( B4 09 ) We put the address of a string of ascii characters in DX. ( BA 07 01) That is address 0107. We call interrupt 21 (CD21).This interrupt outputs ascii characters until it finds a "$" (24) character. To stop we enter 4C into AH and call INT 21 again. That is B4 4C CD 21. Isn't that easy?
B409BA0701CD214D522048415252454C4C2049532047524541542124B44CCD21
This is what is in memory. These numbers are in Hex. What would it look like in binary?
I am sure you will want to modify the program message and experiment with it.