Assembly Directives in Microcontrollers and Applications
What are Assembly Directives?
Assembly directives are instructions to the assembler that do not generate machine code but help in
organizing the program, defining data, and controlling memory layout.
They are also called pseudo-instructions.
Common Assembly Directives and Their Applications
Directive Description Application
ORG Sets the starting address of the program or data....
Used to place code/data at a specific memory location....
DB Define Byte - reserves a byte and assigns a value....
Used to define constants or character data....
DW Define Word - reserves 2 bytes.... Useful for storing 16-bit values....
EQU Equate - assigns a constant value to a label....
Used to make code readable and maintainable....
END Marks the end of the program.... Tells the assembler that the source code ends here....
DS Define Storage - reserves space in memory....
Used to allocate memory for variables....
CODE, DATA Define code or data segments.... Organizes code into separate sections....
SET Like EQU but can be redefined.... Used when values change in different contexts....
Example: 8051 Microcontroller Assembly Code
ORG 0000H ; Program starts at address 0000H
MOV A, #55H ; Load 55H into accumulator
MOV R1, A ; Move accumulator value to register R1
END ; End of program
Applications of Assembly Directives
1. Memory Management: ORG, DB, DS, and DW help allocate memory efficiently.
2. Code Organization: ORG, END, and segment definitions help structure the program.
3. Constants Declaration: EQU helps create readable, maintainable code.
Assembly Directives in Microcontrollers and Applications
4. Interrupt Vectors: ORG places ISRs at correct addresses.
5. Hardware Control: EQU makes hardware-related code easier to modify.