You are on page 1of 29

8086 Assembler Directives and

Programming Models
Assembler Directives
• Assembler directives : Directions to the
assembler ,not instruction for the 8086
• Directions : (hints from the programmer given to
assembler using predefined alphabetical string)
• the required storage for a particular
constant or variable,
• Logical name of the segments,
• Types of different routines and modules
• End of file etc
• Machine language - Instructions are written in binary
codes which use 0 and 1

• Assembly Language: Mnemonics-for addition is ADD

• Assembler – tool to convert Assembly language to


machine language

• Assembler Directives
• A label :can be placed at the beginning of a
statement. During assembly, the label is
assigned the current value of the active
location counter and serves as an instruction
operand.
Define Byte

• DB: define a byte type variable


• reserves specific amount of memory to variables
and store the values specified in the statements as
the initial value in the allotted memory locations.

• variable DB value /values

• Eg: prices DB 49H,98H,29H( declare array of 3 bytes


named prices and intialize 3 bytes as shown)
Define Word - DW
• Define Quad Word –DQ – reserve 4 words in
length

• Define Double Word- DD- reserve double


word space

• Define Ten bytes- DT- variable which is 10


bytes in length
• ASSUME:

• Tell the assembler the name of the logical


segment it should be used for the specified
segment.
• COUNT EQU 10
• CONST EQU 20H

• EQUATE SYMBOL TO A VALUE

• DOESN’T STORE ANYTHING IN MEMORY


Example
EXTERN AND PUBLIC
• If one wants to call a procedure in module 1
from module 2

• Module 1 : public
• Module 2 : EXTERN( informs that’s its already
defined in some other module)( Accompanied
by segment and ends)
Example
• MODULE 1 SEGMENT
• PUBLIC FACTORIAL FAR
• MODULE 1 ENDS

• MODULE 2 SEGMENT
• EXTERN FACTORIAL FAR
MODULE 2 ENDS

• LENGTH :LENGTH is an operator, which tells the assembler to
determine the number of elements in some named data item,
such as a string or an array.

• When the assembler reads the statement MOV CX, LENGTH


STRING1, for example, will determine the number of elements in
STRING1 and load it into CX.

• If the string was declared as a string of bytes, LENGTH will


produce the number of bytes in the string. If the string was
declared as a word string, LENGTH will produce the number of
words in the string.
OFFSET
• OFFSET : OFFSET is an operator, which tells the
assembler to determine the offset or displacement
of a named data item (variable), a procedure from
the start of the segment, which contains it.
• When the assembler reads the statement MOV BX,
OFFSET PRICES, for example, it will determine the
offset of the variable PRICES from the start of the
segment in which PRICES is defined and will load
this value into BX.
PROC- PROCEDURE
PTR-POINTER
TYPE
• SHORT – indicates –only one byte is required to code
the displacement for a jump
– saves the memory
– JMP SHORT label

GLOBAL – once a variable is declared as global it can be


used by any module in the program
• ORG: directs the assembler to start the
memory allotment for the particular segment,
block or code from the declared address in
ORG statement

• ORG 100h
Programming models

.MODEL


TINY: Code and data fit within a single 64K segment.
Memory references are NEAR.


SMALL: Code and data have 64K segment individually.
Memory references are NEAR.


MEDIUM: Code may be bigger than 64K but data can only be
64K. References to code are FAR and data is NEAR.
Programming models

COMPACT: Code must fit within 64K but the data may
exceed 64K. Code references are NEAR and data is FAR. No
data array can exceed 64K.


LARGE: Both data and code can be larger than 64K. All
references are FAR. No data array can exceed 64K.


HUGE: Both data and code can be larger than 64K. All
references are FAR. Data array can exceed 64K. Pointers to
elements within an array are far.

You might also like