In assembly language code lines have two parts, the first one is the name of the Instruction which is to be executed, and the second one are the parameters of the command. For example:
ADD ah, bh
Here "ADD" is the command to be executed; in this case an addition, and "ah" as well as "bh" are the parameters.
The name of the Instructions in language is made up of two, three or four letters. These Instructions are also called mnemonic names or operation codes, since they represent a function the processor will perform. There are some commands which do not require parameters for their operation, as well as others that only require just one parameter.
Sometimes Instructions are used as follows:
The brackets in the second parameter indicate to us that we are going to work with the content of the memory cell number 170 and not with the 170 value; this is known as direct direction.
Now we are ready to code for our first program with the help of debug. We are going to create a program that works to illustrate what we have been seeing, and what we will do is to add two values that we will directly introduce into the program.
The first step is to initiate the Debug, this step only consists of typing debug <Enter> on the operative system prompt.
To assemble a program on the Debug, the "a" (assemble) command is used. When this command is used, the address where you want the assembling to begin can be given as a parameter, if the parameter is omitted the assembling will be initiated at the locality specified by CS:IP, usually 0100h, which is the locality where programs with .COM extension must be initiated. And it will be the place we will use since only Debug can create this specific type of programs.
Even though at this moment it is not necessary to give the "a" command a parameter, it is recommendable to do so to avoid problems once the CS:IP Registers are used, therefore we type:
When this is done something like this will appear on the screen: 0C1B:0100 and the cursor is positioned to the right of these numbers, note that the first four digits, in hexadecimal system, can be different, but the last four must be 0100, since it is the address we indicated as a begin. Now we can introduce the Instructions:
0C1B:0100 mov ax,0002; puts the 0002 value on the ax register
0C1B:0103 mov bx,0004; puts the 0004 value on the bx register
0C1B:0106 add ax,bx; the content of bx is added to the content of ax
0C1B:0108 int 20; provoques the termination of the program.
|Sample Chapters from book DATA RECOVERY WITH AND WITHOUT PROGRAMMING by Author Tarun Tyagi
Publishers of the Book
Number of Pages
Price of the Book
BPB Publications, New Delhi, India
$69.00 (Including Shipping Charges, Cost of Book and Other expenses, Free Source Code CD included with the Book)