This is another newbie question (I've previously used IAR).
For debuggin purposes in a bit of test code I want some nops to single step through
If In insert multiple nops e.g.
__NOP();
__NOP();
__NOP();
they seem to be optimised out. How can I stop this.
I've selected the following settings but they don't appear to have any effect on keeping the NOPs
Project/Properties/C/C++ Build/Tool Settings/Optimization/Optimization Level = None (-O0)
Project/Properties/C/C++ Build/Tool Settings/Debugging/Debug Level = Maximum (-g3)
Solved! Go to Solution.
Such instructions must be marked asVolatile to prevent the compiler from removing it.
Compiler sees that it has no side effects so removes it as unnecessary.
For GCC:
#define ATTR_NO_INSTRUMENT_FUNCTION __attribute__( ( no_instrument_function ) )
/*
* NOP is not necessarily a time-consuming NOP. The processor might
* remove it from the pipeline before it reaches the execution stage.
* Use in combination with the Sync Barrier Instruction to consume time.
*/
static inline ATTR_NO_INSTRUMENT_FUNCTION void nop( void )
{
__asm__ __volatile__ ("nop");
}
Then use 'nop();' in your code.
The pipeline comment depends on what part you are using.
A Sync Barrier Instruction may consume thousands of cycles.
Such instructions must be marked asVolatile to prevent the compiler from removing it.
Compiler sees that it has no side effects so removes it as unnecessary.
For GCC:
#define ATTR_NO_INSTRUMENT_FUNCTION __attribute__( ( no_instrument_function ) )
/*
* NOP is not necessarily a time-consuming NOP. The processor might
* remove it from the pipeline before it reaches the execution stage.
* Use in combination with the Sync Barrier Instruction to consume time.
*/
static inline ATTR_NO_INSTRUMENT_FUNCTION void nop( void )
{
__asm__ __volatile__ ("nop");
}
Then use 'nop();' in your code.
The pipeline comment depends on what part you are using.
A Sync Barrier Instruction may consume thousands of cycles.
Thanks