0% found this document useful (0 votes)
8 views

Assembler directives

Uploaded by

224mohiuddin0015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assembler directives

Uploaded by

224mohiuddin0015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MICROPROCESSOR

Lecturer: Sejal Chopra

Assembler Directives

1. Types of assembly language statements:


Assembly language consists of two types of statements:
a) Executable:
 These are the statements to be executed by the processor.
 It consists of the entire instruction set of 8086.
b) Assembler directives:
 These statements direct the assembler to do a task.
 These are effective only during the assembly of the program but do not generate any code that is machine
executable.
 Assembler directives are pseudo instructions.
 They will not be translated into machine instructions.
 They only provide instruction/direction/information to the assembler.
 Their main task is to inform the assembler about the start/end of a segment, procedure or main program, to reserve
appropriate space for data storage etc.

2. Types of assembler directives:


1. AS S UME Directive - The ASSUM E directive is used to tell the assembler that the name of the logical
segment should be used for a specified segment. The 8086 works directly with only 4 physical segments: a Code
segment, a data segment, a stack segment, and an extra segment.
Example:
AS S UME CS : CODE; This tells the assembler that the logical segment named CODE contains the instruction
statements for the program and should be treated as a code segment.
AS S UME DS : DATA; This tells the assembler that for any instruction which refers to a data in the data segment, data
will found in the logical segment DATA.

2. END - 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.

3. PROC - The PROC directive is used to identify the start of a procedure. The term near or far is used to
specify the type of the procedure.
Example:
S MART PROC FAR; This identifies that the start of a procedure named as SM ART and instructs the assembler that
the procedure is far .
S MART ENDP: This PROC is used with ENDP to indicate the break of the procedure.

4. ENDP - ENDP directive is used along with the name of the procedure to indicate the end of a procedure to
the assembler.
Example:
S QUARE_NUM PROC ; It start the procedure ;Some steps to find the square root of a number
S QUARE_NUM ENDP ;Here it is the End for the procedure.
(Note: S imilarly you have MACRO and ENDM directives)

5. ENDS - This ENDS directive is used with name of the segment to indicate the end of that logic segment.
Example:
CODE S EGMENT ;Here it Start the logic segment containing code ; Some instructions statements to perform the
logical operation
CODE ENDS ;End of segment named as CODE

6. GROUP - The GROUP directive is used to group the logical segments named after the directive into one
logical group segment. The assembler passes information to the linker to form the code within a 64KB memory .
Example:
PROGRAM1 GROUP CODE1,DATA1

7. DB - DB directive is used to declare a byte type variable or to store a byte in memory location.
Example:
PRICE DB 49h, 98h, 29h ;Declare an array of 3 bytes, named as PRICE and initialize.
TEMP DB 100 DUP(?) ;Set 100 bytes of storage in memory and give it the name as TEM P, but leave the 100 bytes
uninitialized. Program instructions will load values into these locations.

8. DW - The DW directive is used to define a variable of type word or to reserve storage location of t ype word
in memory.
Example:
MICROPROCESSOR
Lecturer: Sejal Chopra

MULTIPLIER DW 437Ah ; this declares a variable of type word and named it as M ULTIPLIER. This variable is
initialized with the value 437Ah when it is loaded into memory to run.
EXP1 DW 1234h, 3456h, 5678h ; this declares an array of 3 words and initialized with specified values.
S TOR1 DW 100 DUP(0); Reserve an array of 100 words of memory and initialize all words with 0000.Array is
named as STOR1.
Similarly:
DD (Double Word) -
Used to define a Double Word type variable (4 Bytes).
DQ (Quad Word) -
Used to define a Quad Word type variable (8 Bytes).
DT (Ten Bytes) -
Used to define 10 Bytes to a variable (10 Bytes).

9. EQU - This EQU 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.
Example:
FACTOR EQU 03H ; you have to write this statement at the starting of your program and later in the program you
can use this as follows
ADD AL, FACTOR ; When it codes this instruction the assembler will code it as ADD AL, 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.

10. EVEN/ALIGN - This 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 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.
Example:
EVEN
DATA1 DB 20H

11. INCLUDE - This INCLUDE directive is used to insert a block of source code from the named file into the
current source module.
Format: INCLUDE path:file name

12. PTR - This PTR operator is used to assign a specific type of a variable or to a label.
Example:
INC [BX] ; This instruction will not know whether to increment the byte pointed to by BX or a word pointed to by BX.
INC BYTE PTR [BX] ;increment the byte pointed to by BX.

13. ORG-Originate:
This directive allows us 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.A ‘$’ is often used to symbolically represent the current
value of the location counter. The ‘$’ actually represents the next available byte location where the assembler can put a
data or code byte.ORG $ +100 tells the assembler to increment the value of the location counter by 100 from its
current value. A statement such as this can be used in a data segment to leave 100 bytes of space for future use.

14. MODEL:
Used for selecting a standard memory model for the assembly language program.
Each memory model has various limitations depending on the maximum space available for code and data.
.MODEL S MALL; All Data Fits in one 64 KB segment.
All Code fits in one 64 KB S egment
.MODEL MEDIUM; All Data Fits in one 64 KB segment.
Code may be greater than 64 KB
.MODEL LARGE; Both Data and Code may be greater than 64 KB

15. DUP() :
Whenever we want to allocate space for a table or an array the DUP directive can be used.It is used after a storage allocation
directive like DB,DW,DQ,DD,DT.The reserved area can be either filled with a specific value or left uninitialized.
Example: LIS T DB 10 DUP (0) ; S tores LIS T as a series of 10 bytes initialized to Zero.

16. .CODE- Indicates beginning of CODE segment


17. .DATA-Indicates beginning of data segment

You might also like