I need to port a function, which uses inline assembly in a way understood by gcc, to the compiler used in ImageCraft 's IDE ( ICC ). Because of the different calling convention for inline assembly I need to understand exactly what this lines of assembly code do, so I can rewrite it in a way ICCAVR understands it. Can someone, with knowledge of assembly, please support me to fulfil this task?
Thanks you.
XTAL is the clock frequency the Atmel uses. In my project it is 14 Mhz. #define XTAL 14745000
/************************************************************************* delay for a minimum of microseconds the number of loops is calculated at compile-time from MCU clock frequency
*************************************************************************/ #define delay(us) _delayFourCycles( ( ( 1*(XTAL/4000) )*us)/1000 ) /************************************************************************* delay loop for small accurate delays: 16-bit counter, 4 cycles/loop *************************************************************************/ static inline void _delayFourCycles(unsigned int __count) { if ( __count == 0 ) __asm__ __volatile__( "rjmp 1f\n 1:" ); // 2 cycles else __asm__ __volatile__ ( "1: sbiw %0,1" "\n\t" "brne 1b" // 4 cycles/loop : "=w" (__count) : "0" (__count) ); }