Docsity

Assembler Directives in 8086 Assembly Language, Exams of Engineering

Partial preview of the text

Download Assembler Directives in 8086 Assembly Language and more Exams Engineering in PDF only on Docsity!

M. Krishna Kumar^

MAM/M2/LU6/V1/

Assembler Directives (cont..) ¾ ASSUME ¾ DB^

-^ Defined Byte. ¾^ DD^ -^ Defined Double Word ¾^ DQ^ -^ Defined Quad Word ¾^ DT^ -^ Define Ten Bytes ¾^ DW^ -^ Define Word

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ ASSUME

Directive

-^

The ASSUME directive is

used to tell the assembler that the name of the logical segmentshould be used for a specified segment. The 8086 worksdirectly with only 4 physical segments: a Code segment, a datasegment, a stack segment, and an extra segment. ¾ Example:ASUME

CS:CODE

;This tells the assembler

that the logical segment named CODE contains the instructionstatements for the program and should be treated as a codesegment.^ ASUME

DS:DATA

;This tells the assembler

Assembler Directives (cont..)that for any instruction which refers to a data in the datasegment, data will found in the logical segment DATA.

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ DW^

-^ The DW directive is used to define a variable of type word or to reserve storage location of typeword in memory. ¾ Example:MULTIPLIER

DW

437Ah ;

this declares a

variable of type word and named it as MULTIPLIER. Thisvariable is initialized with the value 437Ah when it is loadedinto memory to run.^ EXP1 DW

1234h, 3456h, 5678h ;

this declares an

array of 3 words and initialized with specified values.^ STOR

DW

DUP(0);^ Reserve an array

Assembler Directives (cont..)of 100 words of memory and initialize all words with0000.Array is named as STOR1.

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ END^

-^ END directive is placed after the last statement of a program to tell the assembler that this is the endof the program module. The assembler will ignore anystatement after an END directive. Carriage return is requiredafter the END directive. ¾ ENDP^ -^ ENDP directive is used along with the name of the procedure to indicate the end of a procedure to theassembler ¾ Example:SQUARE_NUM

PROCE

; It start the procedure ;Some steps to find the square root of a number SQUARE_NUM

ENDP^ ;Hear it is the End for the procedure

Assembler Directives (cont..)

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ ENDS^

-^ This ENDS directive is used with name of the segment to indicate the end of that logic segment. ¾ Example:CODE

SEGMENT

;Hear it Start the logic;segment containing code ; Some instructions statements to perform the logical;operation CODE^

ENDS^

;End of segment named as;CODE

Assembler Directives (cont..)

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ EQU^

-^ This EQU directive is used to give a name to some value or to a symbol. Each time the assembler findsthe name in the program, it will replace the name with thevalue or symbol you given to that name. ¾ Example:FACTOR

EQU^

03H^ ; you has to write this statement at the starting of your program and later in theprogram you can use this as follows^ ADD

AL, FACTOR

; When it codes this

Assembler Directives (cont..)instruction the assembler will code it as ADDAL, 03H;The advantage of using EQU in this manner is, if FACTOR isused many no of times in a program and you want to changethe value, all you had to do is change the EQU statement atbeginning, it will changes the rest of all.

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ Example

: DATA1 SEGMENT ; Location counter will point to 0009 after assembler reads;next statement SALES DB 9 DUP(?)

;declare an array of 9 bytes EVEN^

; increment location counter to 000AH RECORD DW 100 DUP( 0 )

;Array of 100 words will start ;from an even address for quicker read DATA^

Assembler Directives (cont..) ENDS

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ GROUP

-^

Group Related Segments ¾^ LABLE ¾^ NAME ¾^ OFFSET ¾^ ORG^

-^ Originate

Assembler Directives (cont..)

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ PROC

-^

Procedure ¾^ PTR^

-^ Pointer

Assembler Directives (cont..) ¾^ PUBLC ¾^ SEGMENT ¾^ SHORT ¾^ TYPE

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ PROC

-^

The^ PROC

directive is used to identify the

start of a procedure. The term near or far is used to specify thetype of the procedure. ¾ Example:^ SMART

PROC

FAR

; This identifies that

the start of a procedure named as SMART and instructs theassembler that the procedure is far.^ SMART

ENDP This PROC is used with ENDP to indicate the break of

Assembler Directives (cont..)the procedure.

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ PUBLIC

-^

The^ PUBLIC

directive is used to instruct

the assembler that a specified name or label will be accessedfrom other modules. ¾ Example:^ PUBLIC

DIVISOR, DIVIDEND

;these two

variables are public so these are available to all modules.

If an instruction in a module refers to a variable in another assembly module, we can access thatmodule by declaring as

EXTRN^

directive.

Assembler Directives (cont..)

M. Krishna Kumar^

MAM/M2/LU6/V1/ ¾^ TYPE^

-^ TYPE

operator instructs the assembler to determine the type of a variable and determines the number ofbytes specified to that variable. ¾ Example:Byte type variable – assembler will give a value 1Word type variable – assembler will give a value 2Double word type variable – assembler will give a value 4ADD^

BX, TYPE WORD_ ARRAY ; hear we want to increment BX to point to next word in an array of words.

Assembler Directives