This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

__asm inline selective disable optimization

Hi,
I'm an mixing assembly with C code using Keil uV 4.6
When I have optimization Level 3 (-O3) turned on, the compiler skips alot of assembly function memory reads & writes. I need every line to be executed for this particular function.

 __asm
    {
        MOV r1,#0x0041000
        MOV r2,#0x0040000
        ...
    }


I have tried intrinsic commands like __nop(), __force_store(), __schedule_barrier, etc, and have tried to make variables volatile. I know i must be missing something...
Any suggestions

Parents Reply Children
  • You can use "embedded assembly" instead of "inline assembly". Embedded asm doesn't have the same easy access to variables that inline asm has and it can't be used in the middle of a function -- it's basically a way of writing a whole function in asm without using a separate .s file and you get access to preprocessing and C constant expressions [via __cpp()].