|
From: Bernhard H. <ber...@be...> - 2001-09-21 06:17:28
|
> dummy = graRD1; //Dummy Read > grafik_wbusy(); > dummy = graRD1; > grafik_wbusy(); > > graRD1 is a XRAM location declared as: > > volatile xdata at 0xF003 unsigned char graRD1; > > Now the asm file look's like the optimizer only use: > > dummy = graRD1; > grafik_wbusy(); I can't reproduce this. The output of the latest SDCC corresponds to: grafik_wbusy(); grafik_wbusy(); The read access on graRD1 is twice omitted. > one time. The second read is optimized. I understand why this is so but i > have to do a dummy read before the normal read. The compiler always otimize > the second read away. I can define a variable and do something with it. > > temp = graRD1; //Dummy Read > grafik_wbusy(); > dummy = graRD1; > grafik_wbusy(); > > /*do something with dummy*/ > > dummy = dummy | temp; > > But this can't be the right way to do that. Is there a statement or > something to tell the compiler not to otimize these four lines? This could be a bug in SDCC, but I don't know exactly. A "workaround" is to define dummy as volatile: volatile unsigned char dummy; Bernhard |