Assembler Directives (cont..

ASSUME DB DD DQ DT DW Defined Byte. Defined Double Word Defined Quad Word Define Ten Bytes Define Word

M. Krishna Kumar



M. a stack segment. Krishna Kumar MAM/M2/LU6/V1/2004 2 . The 8086 works directly with only 4 physical segments: a Code segment.This tells the assembler that the logical segment named CODE contains the instruction statements for the program and should be treated as a code segment.Assembler Directives (cont. data will found in the logical segment DATA.This tells the assembler that for any instruction which refers to a data in the data segment.) ASSUME Directive The ASSUME directive is used to tell the assembler that the name of the logical segment should be used for a specified segment. a data segment. and an extra segment. ASUME DS:DATA .. Example: ASUME CS:CODE .

) DB DB directive is used to declare a bytetype variable or to store a byte in memory location. Program instructions will load values into these locations.Declare an array of 6 bytes and initialize with ASCII code for letters 3. named as PRICE and initialize. M.. PRICE DB 49h. Example: 1.Set 100 bytes of storage in memory and give it the name as TEMP. 2. NAME DB ‘ABCDEF’ . Krishna Kumar MAM/M2/LU6/V1/2004 3 .Declare an array of 3 bytes. 29h .Assembler Directives (cont. 98h. TEMP DB 100 DUP(?) . but leave the 100 bytes uninitialized.

3456h. M. Reserve an array of 100 words of memory and initialize all words with 0000.) DW The DW directive is used to define a variable of type word or to reserve storage location of type word in memory. 5678h .Assembler Directives (cont. STOR1 DW 100 DUP(0). Example: MULTIPLIER DW 437Ah .. This variable is initialized with the value 437Ah when it is loaded into memory to run.Array is named as STOR1. this declares a variable of type word and named it as MULTIPLIER. EXP1 DW 1234h. Krishna Kumar MAM/M2/LU6/V1/2004 4 . this declares an array of 3 words and initialized with specified values.

) END END directive is placed after the last statement of a program to tell the assembler that this is the end of the program module. ENDP ENDP directive is used along with the name of the procedure to indicate the end of a procedure to the assembler Example: SQUARE_NUM PROCE . Krishna Kumar MAM/M2/LU6/V1/2004 5 ..Some steps to find the square root of a number SQUARE_NUM ENDP . Carriage return is required after the END directive.Hear it is the End for the procedure M. The assembler will ignore any statement after an END directive. It start the procedure .Assembler Directives (cont.

Assembler Directives (cont.) END ENDP ENDS EQU EVEN EXTRN End Program End Procedure End Segment Equate Align on Even Memory Address M. Krishna Kumar MAM/M2/LU6/V1/2004 6 ..

Hear it Start the logic .End of segment named as .) ENDS This ENDS directive is used with name of the segment to indicate the end of that logic segment..CODE M. Krishna Kumar MAM/M2/LU6/V1/2004 7 .segment containing code .operation CODE ENDS . Some instructions statements to perform the logical .Assembler Directives (cont. Example: CODE SEGMENT .

Example: FACTOR EQU 03H .) EQU This EQU directive is used to give a name to some value or to a symbol. all you had to do is change the EQU statement at beginning. it will replace the name with the value or symbol you given to that name.The advantage of using EQU in this manner is. 03H . it will changes the rest of all. When it codes this instruction the assembler will code it as ADDAL.Assembler Directives (cont. M. if FACTOR is used many no of times in a program and you want to change the value.. Krishna Kumar MAM/M2/LU6/V1/2004 8 . FACTOR . Each time the assembler finds the name in the program. you has to write this statement at the starting of your program and later in the program you can use this as follows ADD AL.

the 8086 will take 2 bus cycles to get the data. Krishna Kumar MAM/M2/LU6/V1/2004 9 .) EVEN This EVEN directive instructs the assembler to increment the location of the counter to the next even address if it is not already in the even address.Assembler Directives (cont.. M. If the word starts at an odd address. When EVEN is used the location counter will simply incremented to next address and NOP instruction is inserted in that incremented location. A series of words can be read much more quickly if they are at even address. If the word is at even address 8086 can read a memory in 1 bus cycle.

Assembler Directives (cont. Location counter will point to 0009 after assembler reads .next statement SALES DB 9 DUP(?) . increment location counter to 000AH RECORD DW 100 DUP( 0 ) ..) Example: DATA1 SEGMENT .from an even address for quicker read DATA1 ENDS M.Array of 100 words will start . Krishna Kumar MAM/M2/LU6/V1/2004 10 .declare an array of 9 bytes EVEN .

. Krishna Kumar MAM/M2/LU6/V1/2004 11 .Assembler Directives (cont.) GROUP LABLE NAME OFFSET ORG Group Related Segments Originate M.

Assembler Directives (cont. Krishna Kumar MAM/M2/LU6/V1/2004 12 .) GROUP The GROUP directive is used to group the logical segments named after the directive into one logical group segment. M.. INCLUDE This INCLUDE directive is used to insert a block of source code from the named file into the current source module.

Assembler Directives (cont.) PROC PTR PUBLC SEGMENT SHORT TYPE Procedure Pointer M. Krishna Kumar MAM/M2/LU6/V1/2004 13 ..

. This identifies that the start of a procedure named as SMART and instructs the assembler that the procedure is far . Example: SMART PROC FAR . Krishna Kumar MAM/M2/LU6/V1/2004 14 . M. The term near or far is used to specify the type of the procedure.) PROC The PROC directive is used to identify the start of a procedure. SMART ENDP This PROC is used with ENDP to indicate the break of the procedure.Assembler Directives (cont.

Assembler Directives (cont.pointed to by BX This PTR operator can also be used to override the declared type of variable . This instruction will not know whether to increment the byte pointed to by BX or a word pointed to by BX.) PTR This PTR operator is used to assign a specific type of a variable or to a label.increment the byte . Krishna Kumar MAM/M2/LU6/V1/2004 15 . MOV AL.. 0B97h. Example: INC [BX] . If we want to access the a byte in an array WORDS DW 437Ah. BYTE PTR WORDS M. INC BYTE PTR [BX] .

) PUBLIC The PUBLIC directive is used to instruct the assembler that a specified name or label will be accessed from other modules. Krishna Kumar MAM/M2/LU6/V1/2004 16 ..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. M. we can access that module by declaring as EXTRN directive. Example: PUBLIC DIVISOR.Assembler Directives (cont. DIVIDEND .

Assembler Directives TYPE TYPE operator instructs the assembler to determine the type of a variable and determines the number of bytes specified to that variable. TYPE WORD_ ARRAY . hear we want to increment BX to point to next word in an array of words. M. Krishna Kumar MAM/M2/LU6/V1/2004 17 . Example: Byte type variable – assembler will give a value 1 Word type variable – assembler will give a value 2 Double word type variable – assembler will give a value 4 ADD BX.

DOS Function Calls AH AH AH AH AH AH INT 00H 01H 02H 08H 09H 0AH 21H : Terminate a Program : Read the Keyboard : Write to a Standard Output Device : Read a Standard Input without Echo : Display a Character String : Buffered keyboard Input : Call DOS Function M. Krishna Kumar MAM/M2/LU6/V1/2004 18 .

Sign up to vote on this title
UsefulNot useful