MASM Directives for the 8086
MASM assembler directives are special commands used in assembly language programming to control the assembler during the assembly process. They are not part of the microprocessor instruction set, but they are used to define data, allocate memory, control the assembly process and provide information to the assembler. Below is a detailed description of the assembler directives in the Intel 8086 microprocessor:
Data Definition Directives
These directives are used to define and initialize data in memory.
DB (define byte)
Defines a one-byte variable or allocates one byte of memory.
Syntax: variable_name db value
Example: num db 25h ; Define a byte with the value 25h
DW (define word)
Defines a word-sized (2-byte) variable or allocates one word of memory.
Syntax: variable_name dw value
Example: num dw 1234h ; Define a word with the value 1234h
DD (define doubleword)
Defines a doubleword-sized (4-byte) variable or allocates one doubleword of memory.
Syntax: variable_name dd value
Example: num dd 12345678h ; Define a doubleword with the value 12345678h
DQ (define quadword)
Defines a quadword-sized (8-byte) variable or allocates a four-word area of memory.
Syntax: variable_name dq value
Example: num dq 123456789ABCDEF0h ; Define a quadword with the value 123456789ABCDEF0h
DT (define ten bytes)
Defines a ten-byte variable or allocates ten bytes of memory.
Syntax: variable_name dt value
Example: num dt 123456789ABCDEF0h ; Define ten bytes with the value 123456789ABCDEF0h
Segment Definition Directives
These directives are used to define and manage memory segments.
SEGMENT
Defines the beginning of a segment.
Syntax: segment_name SEGMENT
Example:
data segment
num db 25h
data ends
ENDS
Defines the end of a segment.
Syntax: segment_name ENDS
Example: data ends
ASSUME
Tells the assembler which segment register to use for a segment.
Syntax: ASSUME segment_register: segment_name
Example: assume cs:code, ds:data
Procedure Definition Directives
These directives are used to define and manage procedures (subroutines).
PROC
Defines the beginning of a procedure.
Syntax: procedure_name PROC
Example:
Myproc proc
mov ax, bx
ret
Myproc endp
ENDP
Defines the end of a procedure.
Syntax: procedure_name ENDP
Example: Myproc endp
Control Directives
These directives control the assembly process.
ORG (origin)
Sets the location counter to a specified address.
Syntax: ORG address
Example: org 100h ; Start assembly at address 100h
END
Marks the end of the source code.
Syntax: END
Example: end
EQU (equate)
Assigns a value to a symbol.
Syntax: symbol_name equ value
Example: port1 equ 80h ; Define PORT1 as 80h
INCLUDE
Includes another source file in the current assembly.
Syntax: include file_name
Example: include "macros.asm"
Macro Definition Directives
These directives are used to define and use macros.
MACRO
Defines the beginning of a macro.
Syntax: macro_name MACRO parameters
Example:
mymacro macro param1, param2
mov ax, param1
add ax, param2
endm
ENDM
Defines the end of a macro.
Syntax: ENDM
Example: endm
Conclusion
Assembler directives are essential for organizing and controlling the assembly process in 8086 programming. They allow programmers to define data, allocate memory, manage segments, define procedures and control the assembly process. Understanding these directives is crucial for writing efficient and well-structured assembly language programs.