Use Extended Assembly Instructions

This tip has been extracted from the full Control of In-line Assembly With MPLAB® XC16/32 article.

If you are using MPLAB XC16 or XC32 you should always use the extended form of the asm statement to ensure your code is robust and more readable.

This more descriptive form of assembly coding allows you to specify parameters that describe the input and output operands of the instruction as well as the device registers the instruction might change. This additional information allows the compiler to make adjustments to the surrounding output so that it can avoid or preserve resources used by the in-line assembly.

Extended syntax qualifiers can also indicate that instructions should not be optimised by the compiler, which is a common requirement for in-lined code.

The extended asm syntax allows you to reference C variables and labels in the instruction operands, making it easier for your in-line assembly to interact with C objects and labels, and making your assembly code more readable.

For details of the syntax and a full list and description of the parameter constraint letters, consult your XC compiler User’s Guide.

20th Annual
Microchip MASTERs Conference 2016

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.