![]() ![]() But there is one more thing we should be aware of. I am doing to show you this after speaking about how to load a program. For example, if you return to DOS and again enter debug, the value of CX will not be changed. Because you know it has the convenient value. In fact, sometimes you don't even need to specify the value of CX. Here the order of passing a value to CX register and naming the program is not important. Finally write 'w' and the program will be saved.It will be sufficient if the high byte of the address is 01. More practically, look at the last address and take its low byte. Practically, write the difference between where your program starts and where it ends. And enter the number of bytes you want to save. So, we have to pass a value to CX register. We should specify how many bytes will be saved. Write 'n' and the name of the program like -n.There are three stages to save this program. You are going to see how strange and how different it is from any ordinary saving task in other programs. So, until now, we used a, g, t, r, q instructions and wrote a simple program. So, if you say go, the processor executes what is in 0100, which is mov ax,03 here, and increases the value of IP until a break occurs. ![]() If you want to pass a value to a register, you write ' r ax' or 'r bx' or 'r ip' or whatever and press enter. If you write 'r' and press enter, you see the value of registers. So the value of IP should be changed into 0100. We do that using 'r'. In fact, even 'g' will not run the program. But just at this point, the usage of trace will not work. We can use 't' to trace and see step by step what the program does, that is, we can follow the value of registers. g « run, that is, go to 0100 because IP is 0100 (IP=Instruction Pointer, the code at the address it shows is executed)Īnd the result is directly shown by debug just after 'g « ". I use '«' instead of saying press enter.Īdd ax,bx « add AX with BX, the sum is in AX We are going to use AX and BX registers and the sum will be in AX. Now, let's write a simple program - a program that adds two numbers. To return to DOS from debug environment, write 'q' and quit. So you should use 'push ds' and 'pop ds'.) DS should have the previous value after your program finishes. If you want to save the program int 3 will not be enough not to lock the computer. (Use int 3 (break) or int 20 (return to DOS) instructions otherwise the computer is locked. The program starts to run and ends with the first break. To run the program, we write ' g ', which means ' go ', and press enter. To start writing the code, we write ' a ' meaning ' assemble ', and press enter.Īfter finishing the line, we press enter two times and get the following: We write letters like a,n,l,d,t,g to give directions to debug to write program, to save, to load, etc. Now, we are going to see how to use debug. But it has some very satisfying sides like bringing you closer to the processor and also we got to see what the hell is going around debug because it exists and stays next to us. It can be very hard, depressing and time consuming to write in Debug. The most primitive way must be Debug () which you can find in any machine that includes MS-DOS. If you want to write assembly code, you need an environment to do that.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |