Thread: MISRA rule 54

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    13

    MISRA rule 54

    Hi,
    Does anyone know the MISRA way to call a NOP?
    Code:
    	asm("NOP;");
    will produce the MISRA error:
    A null statements shall only occur on a line by itself, and shall not have any other text on the same line


    thanks for any help,
    Matt

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Doesn't

    Code:
    asm("nop");
    work?

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    13
    doesn't appear to no

    Code:
    syntax error is at or near text '.LN1'.
    Attempting error recovery by ignoring text until the ';'
    
     Previous errors prevent assembly

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    13
    apologies,
    I should have said i was working on VDSP5+ on a blackfin processor (bf561)

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    The 'C' language 'nop' is a ;

    As in (in MISRA terms)
    Code:
    while ( 1 )
        ;
    But that won't create a single "nop" instruction in the assembler, it will simply be removed.

    It's been a while since I last looked at MISRA, but aren't assembler inserts forbidden?

    If you're trying to inject a small delay into the code, then you might have to do something else (call some external function outside the scope of your MISRA checked code).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    how about
    Code:
    asm("nop;");

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    13
    i believe the double ";" on the same line is the issue.

    I am using nops to reserve a large chunk of instruction memory. I think instead i'll have to do this through the linker and remove my need for asm.

    thanks for any help,

    Matt

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > I am using nops to reserve a large chunk of instruction memory.
    If your next comment is "I want to put some code there later", then why are you bothering checking with MISRA if you're going to resort to that kind of underhand programming?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Jan 2010
    Posts
    13
    well we're hoping to get as close to MISRA with future projects as possible.
    This project requires run-time loading and execution of software functions from flash, so yeah, I doubt I could ever claim to have fully MISRA compliant code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Misra Rule 11.2
    By hammer1234 in forum C Programming
    Replies: 1
    Last Post: 04-06-2006, 07:28 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Rule of 72
    By sonict in forum C++ Programming
    Replies: 12
    Last Post: 01-23-2003, 08:31 PM
  4. Who should rule the world?
    By CoderBob in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 02-07-2002, 07:01 AM

Tags for this Thread