Why is this an issue?
Ensuring that assembly language code is encapsulated and isolated aids portability. Where assembly language instructions are needed, they shall be
encapsulated and isolated in either assembler functions or C++ functions.
Noncompliant code example
void fn ( void )
{
DoSomething ( );
asm ( "NOP" ); // Noncompliant, asm mixed with C/C++ statements
DoSomething ( );
}
Compliant solution
void Delay ( void )
{
asm ( "NOP" ); // Compliant, asm not mixed with C/C++ statements
}
void fn ( void )
{
DoSomething ( );
Delay ( ); // Compliant, Assembler is encapsulated
DoSomething ( );
}
Resources
- MISRA C 2004, 2.1 - Assembly language shall be encapsulated and isolated.
- MISRA C++ 2008, 7-4-3 - Assembly language shall be encapsulated and isolated.