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

Unit 4 The Art of Assembly Language Programming

Uploaded by

oshanmitkari
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Unit 4 The Art of Assembly Language Programming

Uploaded by

oshanmitkari
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Unit 4 The art of assembly

language Programming
Assembler directives :
1. These are the statements that direct the assembler to do
something.
2. They indicate how an operand is treated by the assembler and
how assembler handles the program.
3. They also direct the assembler how program and data should be
arranged in the memory.
4. They do not generate any machine code.
Directives are classified into following categories.
1) Data definition and storage allocation directives
2) Program organization directives
3) Value returning attribute directives
4) Data control directives
5) Procedure directives
6) Macro directives
Data definition and storage allocation directives :
Data definition directives are used to define the program variable
and allocate a specified amount of memory to them. They are as
follows;
DB(Define data Byte) - DB directive is used to declare a byte type.
Variable size of variable is 1 byte.
General form : Name_Of_Varible DB Initialiation_value(,s)

Example: PRICE1 DB 49h PRICE2 DB ?

2) DW (Define data Word) - The DW directive is used to define a


variable of type word. Variable size of variable is 2 byte.
General form : Name_Of_Varible DW Initialiation_value(,s)

Example: PRICE1 DW 1234h PRICE2 DW ?

3) DD (Define DoubleWord) - This directive is used to define a


variable of type double. Variable size of variable is 4 byte.
General form : Name_Of_Varible DD Initialiation_value(,s)

Exmaple : PRICE1 DD 11223344H PRICE2 DD ? PRICE3 DD 5 DUP(0)


4) DQ (Define Quad Word) - This directive is used to define a
variable of type quad word. Variable size of variable is 8 byte.
General form : Name_Of_Varible DQ Initialiation_value(,s)
Exmaple : PRICE1 DQ 1122334455667788h
PRICE2 DQ ?
PRICE3 DQ 5 DUP(0)

5) DT (Define Ten Bytes) - This directive is used to define a variable


which is 10 bytes in length. General form : Name_Of_Varible DT
Initialiation_value(,s)
Exmaple : PRICE1 DT 00112233445566778899h
PRICE2 DT ?
PRICE3 DT 5 DUP(0)

6) STRUCT:Structure Declaration : The directive STRUCT is used


to declare the data type which is a collection of primary data types
(DB,DW,DD).
General form : Structure_Name STRUCT
………………..
………………..
Structure_Name ENDS
Exmaple : STUDENT STRUCT STUD_NAME
DB 15 DUP(0)
STUD_ROLLNO DB 01H
7) EQU (Equate to) - 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.
General form : Symbol_Name EQU eXPRESSION
Example: FACTOR EQU 03H

8) EVEN –Align as even memory location : This EVEN


directive is used to inform the assembler to increment the
location counter to the next even memory address if it is not
already in the even address.
General Form: EVEN

Example : DATA SEGMENT


Name db ‘xyz’
EVEN
Age db 20
DATA ENDS
9) ALIGN :Alignment of memory addresses: The directive
ALIGN is used to force the assembler to align the next data item
or instruction according to given value.
General Form: ALIGN Numeric_value
The number must be a power of 2 such as 2,4,8,16.
Example : ALIGN 4

10) ORG-Originate : The directives ORG assigns the location


counter with the value specified in the directive. It helps in
placing the machine code in the specified location while
translating the instructions into machine codes by the
assembler.
General Form: ORG Numeric_value

Example: ORG 100H


PROCEDURE DEFINITION DIRECTIVE :
PROC and ENDP directives : They are used to define procedures in
assembly language programs. They mark the beginning and end of
the procedure. The term near or far is used to specify the type of
the procedure.

MACRO DEFINITION DIRECTIVES :


They are used to define macros in assembly language programs.
They mark the beginning and end of the MACRO.

You might also like