Altera_Forum
Honored Contributor
16 years agogcc generates bad code for volatile data
If you look at the generated code for reads of volatile char and short data, it seems that gcc assumes that the high bits of the register are undefined.
For instance: int fubar(volatile char *bar) { return *bar; } Generates: ldbu r5, 0(r4) andi r3, r5, 255 xori r2, r3, 128 addi r2, r2, -128 ret Without the volatile the expected 'ldb r2, 0(r4)' is generated. I've tried buiding gcc with PROMOTE_MODE defined (to its typical value) - but that has no effect. Any other thoughts?? David