AUTOSAR C++14 Rule M7-4-2
Assembler instructions shall only be introduced using the asm declaration
Description
Rule Definition
Assembler instructions shall only be introduced using the asm declaration.
Rationale
The asm
declaration is available in all C++ implementations1
but other ways of introducing assembler instructions might not be available. Using the asm
declaration makes your code portable across implementations.
Polyspace Implementation
The rule checker reports uses of methods other than asm
declarations as rule violations.
For instance, the rule checker allows the asm
declaration:
asm("ADD a0,1")
#pragma asm
, the checker reports a violation:#pragma asm "ADD a0,1" #pragma endasm
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Declaration |
Category: Required, Automated |
Version History
Introduced in R2019a
1 How the asm
declaration is implemented might vary across compilers. See also AUTOSAR C++14 Rule A7-4-1
.