Monday, March 19, 2012

Assembler Directives of 8086/8088

ASSUME
This directive tells the assembler the name of the logical segment it should use for a specified segment. For example ASSUME CS:CODE, tells the assembler that the instructions for a program are in a logical segment named CODE. The 8086 works directly with only 4 physical segments: a Code segment, a data segment, a stack segment, and an extra segment.
DB – Define Byte
This directive is used to declare a byte type variable or to store a byte in memory location. For example

NAME DB ‘THOMAS’;
VALUES DB ‘0’,’1’,’2’,’3’;
DD – Define Doubleword
This directive is used to define a variable of type doubleword or to reserve storage location of type doubleword in memory. For example

POINTER DD 12341234H
DQ – Define Quadword
This directive is used to define a variable of type quadword or to reserve storage location of type quadword in memory. For example

POINTER DQ  1234123412341234H
DT – Define Ten Bytes
This directive is used to define a variable which is 10 bytes in length or to reserve 10 bytes of storage in the memory. For example

POINTER DT 11223344556677889900
DW – Define Word
This directive is used to define a variable of type word or to reserve storage location of type word in memory. For example

ARRAY DW 100DUP(0) ; defines an array of size 100 all initialized to 0.
MULTIPLIER DW 1234h; defines a variable multiplier of value 1234h
ENDS
This directive is used with name of the segment to indicate the end of that logic segment. For example

CODE SEGMENT ; this statement starts the segment

CODE ENDS ; this statement ends the segment
EQU
This directive is used to give a name to some value or to a symbol. Each time the assembler finds the name in the program, it will replace the name with the value or symbol you given to that name. for example

FACTOR EQU 03H ; this equates factor to 03h can be used as
ADD AL, FACTOR ; When it codes this instruction the assembler will code it as ADDAL, 03H ;The advantage of using EQU in this manner is, if FACTOR is used many no of times in a program and you want to change the value, all you had to do is change the EQU statement at beginning, it will changes the rest of all.
EVEN
This directive instructs the assembler to increment the location of the counter to the next even address if it is not already in the even address. If the word is at even address 8086 can read a memory in 1 bus cycle.

If the word starts at an odd address, the 8086 will take 2 bus cycles to get the data. A series of words can be read much more quickly if they are at even address. When EVEN is used the location counter will simply incremented to next address and NOP instruction is inserted in that incremented location. For example

DATA1 SEGMENT
; Location counter will point to 0009 after assembler reads next statement
SALES DB 9 DUP(?) ;declare an array of 9 bytes
EVEN ; increment location counter to 000AH
RECORD DW 100 DUP(0) ;Array of 100 words will start from an even address for quicker read
DATA1 ENDS
GROUP
This directive is used to group the logical segments named after the directive into one logical group segment.
INCLUDE
This directive is used to insert a block of source code from the named file into the current source module.
Rest will be added with time……

11 comments: