Gcc Optmization

Thomas Doerfler Thomas.Doerfler at imd-systems.de
Thu Sep 21 15:42:12 UTC 2000


Hi,

you should define your pointers to point to a "volatile" (this is an 
ANSI-C keyword) location, this means any access to that location will 
be issued without optimization:

struct my_regs {
    volatile short reg1;
    volatile char  reg2;
};

struct my_regs *memory_mapped_pointer;

The your code should work fine with every compiler optimization level 
(and on any ANSI-C compiler, not just GCC).

bye,
	Thomas.


> 
> 
>         How do I tell gcc to generate unoptimized code within a file compiled with -O4?
> 
>         I'm writing to memory mapped registers and I need to have C code translated verbatum.
> 
>         For example:
> 
>         memory_mapped_pointer->register1 = 0x00000000;
>         memory_mapped_pointer->register1 = 0xFFFFFFF;
> 
>         Needs to be translated into 2 stores not one. The -O4 is removing the first store, how do I avoid this.
> 
>         Thank you,
>         William


--------------------------------------------
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de



More information about the users mailing list