Assemblers for PIC® and AVR® Microcontrollers

Last modified by Microchip on 2023/11/09 09:06

PIC® Microcontroller Assembler

The MPLAB® XC8 PIC® Assembler may be used with MPLAB X IDE or Microchip Studio for 8-bit assembly-code projects and solutions. The assembler is bundled with the MPLAB XC8 C compiler.

AVR® Microcontroller  Assembler

The AVR® Assembler (avrasm2) may be used with MPLAB X IDE or Microchip Studio for 8-bit assembly-code projects and solutions. The assembler is bundled with Microchip Studio. (Older version may be found with Atmel Studio.)

Using AVR Assembler with MPLAB® X IDE Projects

Consider using the MPLAB XC8 C Compiler to develop your projects as this compiler toolchain supports AVR devices and assembly code.

Overview

When using the AVR Assembler, only the main project file should be enabled in the project configuration; all other files should be excluded. The other project files should be included in the main file using the .INCLUDE assembler directive.

Back to Top

Step-by-Step Tutorial

Identify the AVR Assembler to MPLAB X IDE

Open MPLAB X IDE and go to Tools > Options > Embedded > Build Tools. Look for "avrasm2" in the Toolchain list. If you do not see it, click Add and locate the file on your computer. The assembler is bundled with Microchip Studio.

Back to Top


Create an Assembly Project

Select File > New Project to open the New Project wizard.

  1. Choose Project: Select the Microchip Embedded category and Standalone Project project.
  2. Select Device: Choose an AVR device (ATtiny, ATmega, or ATxmega) from the drop-down list. Then select your debug tool.
  3. Select Header: N/A
  4. Select Plugin Board: N/A
  5. Select Compler: Choose an avrasm2 version from the list (see image).
  6. Select Project Name and Folder: Give your project a name and select a folder location.

Select Compiler

Back to Top


Create Assembly Project Files

In the Project tree, right-click on the Source Files folder and select New > Other to open the New File wizard (see image).

  1. Choose File Type: Select the Assembler category and AssemblyFile.asm file type.
  2. Name and Location: Give your file a name and select a folder location.

Repeat for each file. Note that once you have created the first file, "AssemblyFile.asm" will appear in the "New" submenu for selection.

Right-click on Source Files folder and select New>Other to create new assembly file.

Back to Top


Include Only Main File in Project

In the Project tree, right-click on the project name and select Properties to open the Project Properties window.

  1. Select the File Inclusion/Exclusion category.
  2. Ensure that only your main file (here called main.asm) is under Included files and all other project files are under Excluded files. To move a file, select it and then click > (see image). To move several files, select them and then click ».

Once files are excluded, they appear grayed in the project tree.

File inclusion exclusion

Back to Top


Use .INCLUDE Directive to Build

Since only the main file is included in the project configuration, the other files will not build until you use the .INCLUDE directive in the main file to include them (see image).​​​​​​

Use .INCLUDE directive

Back to Top