MICROPROCERSSORS
AND
MICROCONTROLLERS
REGULATION /BRANCH :R16/R18 ECE/EEE
UNIT-I
ASSEMBLER DIRECTIVES:
ØThere are some statements in the assembly language
program which are not a part of processor instruction set.
ØThese are the instructions to the assembler, linker,
and Debugger.
ØThese are referred to as pseudo-operations or as
assembler directives.
ØThe assembler directives enable us to control the
way in which a program assembles and lists.
ØThey act during the assembly of a program and do not
generate any executable machine code.
ALIGN
:
The align directive forces the assembler to align the next segment at an
address divisible by specified divisor.
Eg:
ALIGN number (where number can be 2, 4, 8 or 16.)
ASSUME
:
The 8086 may contain a number of logical segments. The 'ASSUME' directive assigns a logical segment to a physical segment at any given time.
That is, the ASSUME directive tells the assembler what addresses will be
in the segment registers at execution time.
Eg
: ASSUME CS : code, DS : Data, SS : stack
DB,
DW, DD, DQ, and DT :
These directives are used to define different types of variables, or to
set aside one or more storage locations of corresponding data type in memory.
DB
- Define Byte DW -
Define Word DD - Define Doubleword
DQ
- Define Quadword DT - Define
Ten Bytes
Eg: num DW 1234h
List DB 10H, 20H, 30H, 40H
MSG
DB “ WELCOME’’
TABLE
DW 10 DUP (?)
DUP
: The DUP
directive can be used to initialize several locations and to assign values to
these locations.
Eg: LIST DB 01H DUP (value)
END
:
The END directive is put after the last statement of a program to tell
the assembler that this is the end of the program module. The assembler ignores
any statement after an END directive.
The EQU directive is used to redefine a data name or variable with
another
data name, variable, or immediate value.
Eg
: NUM EQU 12H
EVEN tells the assembler to advance its location counter if necessary so that the next defined data item or label is aligned on an even storage boundary.
Eg:
EVEN LIST 10H DUP(?)
EXTRN
:
The EXTRN directive is used to inform assembler that the names,
procedures and labels declared after this directive have already been defined
in some other
assembly language
modules.
NOTE
: Names and labels referred to as external in one module must be declared by
MODULE1 SEGMENT
PUBLIC FACTORIAL FAR
MOULE1 ENDS
MODULE2 SEGMENT
EXTRN
FACTORIAL FAR
MODULE2 ENDS
PUBLIC
: The PUBLIC
directive is used to tell the assembler that a specified name or label will be
accessed from other modules.
GROUP:
Group the Related Segments
This directive is used to form logical groups of segments with
similar purpose or type. This directive is used to inform the assembler to form
a logical group of . the following segment names.
Eg: PROGRAM
GROUP CODE, DATA, STACK
ASSUME CS: PROGRAM, DS: PROGRAM, SS:
PROGRAM
NAME
: The name
directive is used at the start of a source program to give sperifiy names to
each assembly module.
OFFSET
: It is an
operator which tells the assembler to determine the offset or displacement of a
named data item (variable) from the start of the segment which contain it.
Example
:MOV AX, OFFSET num
ORG
:Directs the
assembler to start the memory allotment for a particular segment from the
specified address in the statement.
Eg: ORG 1000H ; Set the location counter to 1000H
PTR
: PTR is used to
assign a specific type to a variable or to a label.
Eg: MOV AL, BYTE PTR [SI]
PROC
and ENDP : The
procedures in line programs can be defined by PROC directive.
ENDP directive is used along with the PROC directive. ENDP defines the end of the procedure.
FACT
PROC FAR/NEAR
-----------------------------------
-----------------------------------
FACT
ENDP
SEGMENT and ENDS: The start of the segments is defined by SEGMENT
directive and the ENDS statement indicates the end of the segment.
Eg: DATA SEGMENT
------------------------
-----------------------
DATA ENDS
LENGTH
: It is an
operator which tells the assembler to determine the number of elements in some
named data item such as a string or array.
Eg :MOV BX, LENGTH STRING 1 ; Loads the Length of string in BX
TITLE : The TITLE directive help to control the format of a
listing of an assembled program. TITLE directive causes a title for a program
to print on line 2 of each page of the program listing. Maximum 60 characters
are allowed as title.
Format : TITLE text
Example : TITLE Program to find maximum number
Summary of
Assembler Directives
Directive |
Action |
ALIGN
|
Aligns next variable or instruction to byte which
is multiple of operand |
ASSUME |
Selects segment register(s) to be the default for
all symbol in segment(s) |
COMMENT |
Indicates a comment |
DB
|
Allocates and optionally initializes bytes of
storage |
DW
|
Allocates and optionally initializes words of
storage |
DD
|
Allocates and optionally initializes double words
of storage |
DQ
|
Allocates and optionally initializes quad words of
storage |
DT |
Allocates and optionally initializes 10-byte-long
storage units |
END |
Terminates assembly program |
ENDM |
Terminates a macro definition |
ENDP |
Marks end of procedure definition |
ENDS
|
Marks end of segment or structure |
EQU
|
Assigns expression to name |
EVEN
|
Aligns next variable or instruction to even byte |
EXITM
|
Terminates macro expansion |
EXTRN
|
Indicates externally defined symbols |
LABEL |
Creates a new label with specified type and current
location counter |
LOCAL |
Declares local variables in macro definition |
MACRO |
Starts macro definition |
MODEL
|
Specifies mode for assembling the program. |
ORG
|
Sets location counter to argument |
PROC
|
Starts procedure definition |
PTR |
Assigns a specific type to a variable or to a
label |
PUBLIC
|
Identifies symbols to be visible outside module |
TITLE |
Defines the
program listing title |
No comments:
Post a Comment