Modular Programming: Instead of writing a large program in a single unit, it is better to write small programs—which are parts of the large program. Such small programs are called program modules or simply modules. Each such module can be separately written, tested, and debugged. Once the debugging of the small programs is over, they can be linked together. Such a methodology of developing a large program by linking the modules is called modular programming.

Assembler Directives:

Assembler directives are special instructions that provide information to the assembler but do not generate any code. Examples include the segment directive, equ, assume, and end. These mnemonics are not valid 80x86 instructions. They are messages to the assembler, to generate the address.

A pseudo-opcode is a message to the assembler, just like an assembler directive, however, a pseudo-opcode will emit object code bytes. Examples of pseudo-opcodes include byte, word, dword, qword, and byte. These instructions emit the bytes of data specified by their operands but they are not true 80X86 machine instructions.

ASSUME: The ASSUME directive tell the assembler the name of the logical segment it should use for a specified segment. Ex: ASSUME CS: Code, DS : Data, SS : Stack; or ASSUME CS: Code

Data Directives:

The directives DB, DW, DD, DR and DT are used to (a) define different types of variables or (b) to set aside one or more storage locations in memory-depending on the data type:

DB — Define Byte DW — Define Word DD — Define Double word DQ — Define Quadword DT — Define Ten Bytes

The DB directive is used to declare a byte-type variable or to set aside one or more storage locations of type byte in memory (Define Byte)

Example: Temp DB 42H; Temp is a variable allotted 1byte of memory location assigned with data 42H The DW directive is used to declare a variable of type word or to reserve memory locations which can be accessed as type double word (Define word)

Example: N2 DW 427AH; N2 variable is initialized with value 427AH when it is loaded into memory to run.

The DD directive is used to declare a variable of type double word or to reserve memory locations which can be accessed as type double word (Define double word) Example: Big DD 2456756CH; Big variable is initialized with 4 bytes

The DQ directive is used to tell the assembler to declare a variable 4 words in length or to reverse 4 words of storage in memory (Define Quadword)

Example: Big DQ 2456756C88464567H; Big variable is initialized with 4 words (8 bytes)

The DT directive is used to tell the assembler to declare a variable 10 bytes in length or to reverse 10bytes of storage in memory (Define Ten bytes)

Example: Packed BCD DT 11223344556677889900H; 10 byte data is initialized to variable packed BCD DUP: This directive operator is used to initialize several locations and to assign values to these locations. Its format is: Name Data-Type Num DUP (value)

Example: TABLE DB 20 DUP(0) ; Reserve an array of 20 bytes of memory and initialize all 20 bytes with 0. Array is named TABLE

END: The END directive is placed after the last statement of a program to tell the assembler that this is the end of the program module. The assembler will ignore any statement after an end directive.

The ENDP directive is used with the name of the procedure to indicate the end of a procedure to the assembler.




The ENDS directive is used with the name of the segment to indicate the end of a segment to the assembler.



EQU: The EQU directive is used to give a name to some value or to a symbol. Each time assembler finds the name in the program it will replace the name with the value.

FACTOR EQU 03H; This statement should be written at the start

ADD AL, FACTOR; The assembler converts this instruction as ADD AL, 03H

EVEN: The EVEN 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 starts at an odd address, 8086 will take 2 bus cycles to get the 2 byte of the word. “A series of words can read much more quickly if they are at even address”.

DATA HERE SEGMENT; Location counter will point to 0009H 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 (?); Array of 100 words starting on even address for quicker read DATA HERE ENDS     ;

GLOBAL: This GLOBAL directive can be used in place of PUBLIC directive or in place of an EXTRN directive. The GOLBAL directive is used to make the symbol available to other modules.

PUBLIC: The PUBLIC directive is used along with the EXTRN directive. This informs the assembler that the labels, variables, constants, or procedures declared PUBLIC may be accessed by other assembly modules to form their codes, but while using the PUBLIC declared labels, variables, constants or procedures the user must declare them externals using the EXTRN directive.

EXTRN: This EXTRN directive is used to tell the assembler that the names or labels following the directive are in some other assembly module.

GROUP: This GROUP directive is used to tell the assembler to group the logical segments named after the directive into one logical group segment.



Is an operator which tells the assembler to determine the offset or the displacement of a named data item (variable) or procedure from start of the segment which contains it. This operator is used to load the offset of a variable into a register so that the variable can be accessed with one of the indexed addressing modes. MOV AL, OFFSET N1

ORG – This ORG directive allows to set the location counter to a desired value at any point in the program. The statement ORG 100H tells the assembler to set the location counter to 0100H.

PROCEDURE: A PROC directive is used to define a label and to delineate a sequence of instructions that are usually interpreted to be a subroutine, that is, called either from within the same physical segment (near) or from another physical segment (far).


name PROC [type]


name ENDP


A label, a symbolic name for a particular location in an instruction sequence, maybe defined in one of three ways. The first way is the most common.

The format is shown below: label: [instruction] where "label" is a unique ASM86 identifier and "instruction" is an8086/8087/8088 instruction. This label will have the following attributes:

  1. Segment-the current segment being assembled.
  2. Offset-the current value of the location counter.
  3. Type-will be NEAR.

An example of this form of label definition is: ALAB: MOV AX, COUNT