Professional Documents
Culture Documents
Assembler Directives: UCS1502 Microprocessors and Interfacing
Assembler Directives: UCS1502 Microprocessors and Interfacing
UCS1502
MICROPROCESSORS AND INTERFACING
2
8086 Microprocessor
Overview
DB PROC
ORG FAR
DW END NEAR
EVEN ENDP
SEGMENT EQU
ENDS SHORT
ASSUME MACRO
ENDM
3
8086 Microprocessor
Assemble Directives
Instructions to the Assembler regarding the program being executed.
Control the generation of machine codes and organization of the program; but no
machine codes are generated for assembler directives.
Used to :
› specify the start and end of a program
› attach value to variables
› allocate storage locations to input/ output data
› define start and end of segments, procedures, macros etc..
4
8086 Microprocessor
DB
Assemble Directives
Define Byte
ASSUME Range : 00H – FFH for unsigned value; 00H – 7FH for
positive value and 80H – FFH for negative value
ORG
END General form : variable DB value/ values
EVEN
EQU
PROC
FAR Example:
NEAR LIST DB 7FH, 42H, 35H
ENDP
Three consecutive memory locations are reserved for the variable LIST
SHORT and each data specified in the instruction are stored as initial value in
the reserved memory location
MACRO
ENDM 5
8086 Microprocessor
Assemble Directives
DB Define Word
PROC
FAR Example:
NEAR ALIST DW 6512H, 0F251H, 0CDE2H
ENDP
Six consecutive memory locations are reserved for the variable ALIST and
SHORT each 16-bit data specified in the instruction is stored in two consecutive
memory location.
MACRO
ENDM 6
8086 Microprocessor
Assembler Directives
DB SEGMENT : Used to indicate the beginning of a code/ data/
stack segment
DW
ENDS : Used to indicate the end of a code/ data/ stack
SEGMENT segment
ENDS
General form:
ASSUME
ORG
END Segnam SEGMENT
EVEN
…
EQU … Program code
… or
PROC … Data Defining Statements
…
FAR …
NEAR
ENDP Segnam ENDS
SHORT
Assemble Directives
DB Informs the assembler the name of the program/ data
segment that should be used for a specific segment.
DW
General form:
SEGMENT
ENDS
ASSUME segreg : segnam, .. , segreg : segnam
ASSUME
ORG
User defined name of the
END Segment Register
segment
EVEN
EQU
PROC Example:
FAR
NEAR ASSUME CS: ACODE, DS:ADATA Tells the compiler that the instructions of the
ENDP program are stored in the segment ACODE and
data are stored in the segment ADATA
SHORT
MACRO
ENDM 8
8086 Microprocessor
Assemble Directives
ORG (Origin) is used to assign the starting address (Effective address)
DB
for a program/ data segment
ORG
Examples:
END
EVEN ORG 1000H Informs the assembler that the statements following ORG
EQU 1000H should be stored in memory starting with effective
address 1000H
PROC
FAR
LOOP EQU 10FEH Value of variable LOOP is 10FEH
NEAR
ENDP
_SDATA SEGMENT In this data segment, effective address of memory location
SHORT ORG 1200H assigned to A will be 1200H and that of B will be 1202H and
A DB 4CH 1203H.
EVEN
MACRO B DW 1052H
ENDM _SDATA ENDS 9
8086 Microprocessor
Assemble Directives
PROC Indicates the beginning of a procedure
DB
ENDP End of procedure
DW
FAR Intersegment call
SEGMENT
ENDS NEAR Intrasegment call
General form
ASSUME
ORG
procname PROC[NEAR/ FAR]
END
EVEN …
… Program statements of the procedure
EQU
…
Last statement of the procedure
PROC RET
ENDP
FAR procname ENDP
NEAR
DB
Assemble Directives
Examples:
DW
SEGMENT ADD64 PROC NEAR The subroutine/ procedure named ADD64 is declared as
ENDS NEAR and so the assembler will code the CALL and RET
… instructions involved in this procedure as near call and
… return
ASSUME …
RET
ORG
ADD64 ENDP
END
EVEN
EQU CONVERT PROC FAR The subroutine/ procedure named CONVERT is declared as
FAR and so the assembler will code the CALL and RET
… instructions involved in this procedure as far call and return
PROC …
ENDP …
FAR
RET
NEAR CONVERT ENDP
SHORT
MACRO
ENDM 11
8086 Microprocessor
Assemble Directives
DB Reserves one memory location for 8-bit signed displacement
in jump instructions
DW
Example:
SEGMENT
ENDS
ASSUME JMP SHORT AHEAD The directive will reserve one memory location
for 8-bit displacement named AHEAD
ORG
END
EVEN
EQU
PROC
ENDP
FAR
NEAR
SHORT
MACRO
ENDM 12
8086 Microprocessor
Assemble Directives
DB MACRO Indicate the beginning of a macro
PROC
ENDP
FAR
User defined name of the macro
NEAR
SHORT
MACRO
ENDM 13
Check your Understanding
1. When do we use ‘Assume’?
2. What is the difference between ‘Far’ and ‘Near’?
14
8086 Microprocessor
Summary
DB PROC
ORG FAR
DW END NEAR
EVEN ENDP
SEGMENT EQU
ENDS SHORT
ASSUME MACRO
ENDM
15
Reference
16
Thank You
17