Apart from the microcontroller instruction set that is used in writing an AVR assembly code the AVR Assembler support the use of assembler directives. Assembler Directives are used as instruction to the AVR assembler and are in no way translated to machine language during the assembly process.
Assembler Directives are use by the programmer to assist in adjusting the location of the program in memory, defining macros and so fort. A list of the AVR assembler directives available to the AVR assembler is given below.
Some AVR Assembler Directives |
---|
Directives | Description |
---|---|
BYTE | Reserve a Byte for a Variable |
CSEG | Define the Code Segment Section |
DB | Define Constant Byte(s) |
DEF | Define a Symbolic Name |
DEVICE | Define which Microcontroller to Assemble for |
DSEG | Define the Data Segment Section |
DW | Define Constant Word(s) |
ENDMACRO | Signifies the End of a Macro |
EQU | Set a Symbol Equal to an Expression |
ESEG | Define the EEPROM Section |
Exit | Exit from a File |
INCLUDE | Read Source Code from a File |
LIST | Turn List Generation ON |
LISTMAC | Turn Macro Expression ON |
MACRO | Signifies the Beginning of a Macro |
NOLIST | Turn List Generation OFF |
ORG | Set Program Origin |
SET | Set Symbol to an Expression |
.include "m8515def.inc" .org $00 begin: ADD R16, R17 ; Add R17 to R16 MOV R17, R18 ; Copy R18 to R17
.include "m8515def.inc"
The ORG Directive - This assembler directive indicate to the assembler where in the microcontroller memory to start storing the code that follows. The syntax for this directive is shown below, here the location to start storing the machine code for the program is $00. That is, start storing the machine code from address $00 in the program memory.
.org $00
Important Note:
If the ORG directive is written following the CSEG directive, then the machine code that follows is written to SRAM in data memory. This is similar for the ESEG directive and EEPROM memory.
AVR Tutorials hopes this AVR assembly tutorial on AVR assembler directives was beneficial to you and looks forward to your continued visits for all your microcontroller tutorial needs.