Assemblers Directives

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Assemblers & Assembler Directives

July 25, 2019


To assemble a program automatically the assembler needs information in the form of
assembler directives that controls the assembly or Assembler directives are the directions to the
assembler which indicate how an operand or section of the program is to be processed. These are
also called pseudo operations which are not executable by the microprocessor. For example, the
assembler must be told at what address to start assembling the program. These assembler
directives are command placed in the program by the designer that provides information to the
assembler. They do not become part of the final program as they are not the part of the
instruction set of the microprocessor nor did they translate into executable code. Therefore, they
are also known as pseudo-instruction on false instructions.

Each assembler has its own unique pseudo instructions or assembler directives. These
instructions differ from assembler to assembler but most of the assembler contains an equivalent
set of pseudo instructions written in assembly language format. The various directives are
explained below.

 ASSUME: The ASSUME directive is used to inform the assembler the name of the logical
segment it should use for a specified segment.

Ex: ASSUME DS: DATA tells the assembler that for any program instruction which refers to the
data segment, it should use the logical segment called DATA.

 2. DS: Another pseudo instruction, the define storage, reserves or allocates read/write memory
locations for storage of temporary data. The first of the locations allocated can be referred to by
an optional symbolic label. The define storage instruction has the form
opt. label: DS expression.

 3. DB -Define byte. It is used to declare a byte variable or set aside one or more storage
locations of type byte in memory. When a table of fixed data values is required, memory must
also be allocated. However, unlike the DS, each memory locations must have a defined value
that is assembled into it.
For example, CURRENT_VALUE DB 36H tells the assembler to reserve 1byte of memory for a
variable named CURRENT_ VALUE and to put the value 36 H in that memory location when
the program is loaded into RAM .
 4. DW -Define word. It tells the assembler to define a variable of type word or to reserve storage
locations of type word in memory. Define word DW instruction is similar to define byte pseudo
instruction.

The only difference between the DB & DW is that expression in this define word list is evaluated
to 16-bit quantity and stored as 2-bytes. It is stored with the lower order byte in the lower of the
two memory locations and the higher order byte in the next higher location. This is consistent
with the convention for storing 16- bit quantities in 8085A systems. Some of the assemblers use
DFW for this assembler directive.

 5. DD(define double word) :This directive is used to declare a variable of type double word or
restore memory locations which can be accessed as type double word.

 6.DQ (define quadword) :This directive is used to tell the assembler to declare a variable 4
words in length or to reserve 4 words of storage in memory .

 7.DT (define ten bytes):It is used to inform the assembler to define a variable which is 10 bytes
in length or to reserve 10 bytes of storage in memory.

 8. SET: SET is similar to EQU assembler directive. This directive also assigns a value to the
name associated it. However, the same symbol can be redefined by another SET statement later
in the program. Thus, more than one SET instructions can have the same name the SET
assembler directive has the form.
name SET expression.

 9. EQU – EQU: Symbolic names, which appear in assembly language programs as labels,
instructions mnemonics and operands are translated to binary values by the assembler. Equate it
is used to give a name to some value or symbol. Every time the assembler finds the given name
in the program, it will replace the name with the value or symbol we have equated with that
name.
A symbolic operand can be a register name, an address or a data constant. Register names have
predefined values. All addresses correspond to labels in the program and their values are defined.
Data constants, on the other hand, are defined by the designer using an equate assembler
directive. The equate instruction EQU defines symbols used in the program. Equate assembler
directives usually appear as a group at the beginning of a program and have the form.
name EQU expression.

‘name’ stands for the symbolic name. The assembler evaluates the expression and equates the
symbolic name to it by placing the name in its symbol table along with the value of the
expression. Therefore, whenever the name appears in the program, it is replaced by the value the
expression in the equate pseudo instruction.

 10. ORG -Originate: The origin (ORG) instruction tells the assembler the address of the
memory location for the next instruction or data byte should be assembled. ORG is entered at the
beginning of a program. When different parts of a programme (e.g. subroutines) are to be placed
in different areas of memory, an ORG pseudo instruction is used before each part of the program
to specify the starting location for assembly of that part of the program. The ORG statement
changes the starting offset address of the data.
It allows to set the location counter to a desired value at any point in the program. For example
the statement ORG 3000H tells the assembler to set the location counter to 3000H.

 11 .PROC- Procedures: It is used to identify the start of a procedure or subroutine.

 12. END- End program .This directive indicates the assembler that this is the end of the program
module. The assembler ignores any statements after an END directive. When an assembler scans
the program to be assembled it must know, where the program ends. It cannot depend on a HLT
instruction for this because some programmes don’t contain a halt instruction as the last
instruction and other don’t contain a halt at all. The END statement explicitly indicates the end
of the program to the assembler. If no END statement is given, then the assembler just keeps on
running through all the memory. When there is more than one ORG assembler directive, then the
assembly of group of instruction start at the location specified by the origin assemble directive
that proceeds. But there will be only one END instruction to tell the assembler the physical end
of the program.

 13. ENDP- End procedure: It indicates the end of the procedure (subroutine) to the assembler.

 14. ENDS-End Segment: This directive is used with the name of the segment to indicate the end
of that logical segment.

Ex: CODE SEGMENT: Start of logical segment containing code


CODE ENDS: End of the segment named CODE.

Macros

Macros: Sometimes it is required that same set of instructions are to be repeated again & again.
One way to simplify the problem is the use of subroutine. This increases the execution time due
to overhead. The other way is the use of macros. The assemblers which have the capability to
process macro instructions are called macro assemblers. The assemblers are designed such that
the programmer need to write set of instruction once and then refer it many times as desired.

A macro instruction is a single instruction that the macro assemble replaces with a group of
instruction whenever it appears in an assembly language program. The macro instruction and the
instruction that replace it are defined by the system design only once in the program. Macros are
useful when a small group of instruction must be repeated several times in a program, with only
minor or no changes in each repetition.

The use of macro in ALP entails three groups:

1) The macro definition


2) The macro reference
3) The macro expansion.

The macro definition defines the group of instructions equivalent to macro. Macro reference is
the use of the macro instruction as an instruction in the program. A macro expansion is the
replacement of the macro instruction defined by its equivalent. The first two steps are carried out
by the system designer and the third by the macro assembler.

--- LOCAL label names

The specified label names are defined to have meaning only within the current macro expansion.
Each time the macro is referenced and expanded; the assembler assigns each local symbol a
unique symbol in the form ‘??nnnn’. The assembler assigns ‘??0001’ to the first symbol, ‘??
0002’ to the second symbol and so on.

REFERENCES
1. R. S. Gaonkar, Microprocessor Architecture, Programming, and Applications with the 8085,
Fifth Edition, Penram International Publishing (India) Private Limited.
2. S Ghoshal, Microprocessor Based System Design, Macmillan India Limited, 1996
3. M. Mano, Digital Logic and Computer Design, Prentice – Hall India
4. B. Ram - Fundamentals of Microprocessor and Microcontrollers
5. “Microprocessors: Principles and Applications” by A Pal
6. “Microprocessors and Microcontrollers : Architecture, Programming and Interfacing Using
8085, 8086 and 8051” by Soumitra Kumar Mandal
7. “Introduction to Microprocessors and Microcontrollers” by Crisp John Crisp
8. “Microprocessors And Microcontrollers” by A Nagoor Kani
9. “Microprocessors And Microcontrollers : Architecture, Programming and System Design 8085,
8086, 8051, 8096” by KRISHNA KANT
10. “8 - Bit Microprocessor” by Vibhute

You might also like