[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] maybe a bug in gcc-avr?
From: |
lbuchman |
Subject: |
[avr-gcc-list] maybe a bug in gcc-avr? |
Date: |
Sat, 1 Dec 2012 18:59:50 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello together,
I've been thinking about something for the last days. Atm I guess the
bug of my problem is in the avr-gcc.
Here my code:
uint16_t total=0, temp=0;
uint8_t bufs[64];
uint8_t bufr[64];
...
if (usb_rawhid_recv(bufr, 50) == 64) {
#if 1 //depending on 'if that calculation is done', the result of bufs[0] will
be 0x01 or 0x02...
total = (((uint16_t)bufr[0]) << 8) + ((uint16_t) (bufr[1] & 0xFF));
#endif
temp = (((uint16_t)bufr[0]) << 8); //temp is 0x0200
bufs[0] = temp >> 8;
bufs[1] = (((uint16_t)bufr[0]) << 8) >> 8;
Well, if bufr[0] is 0x02, then bufs[1] is also 0x02. That works fine.
But bufs[0] is calculated wrong IN CASE that i also calculate the variable
"total" inside the "#if 1".
(bufs[0] is then 0x01 instead of 0x02)
The two assemblies are vimdiff'ed and shown in this image:
http://www10.pic-upload.de/28.11.12/1afla5oyatlv.jpg
On the left side the working case (where total isn't calculated due to the "#if
0")
On the right side is my problem shown. I calculate the variable "total" but gcc
seems to ignore my typecasts.
What do you think?
I hope the mailing list is the right place, where I should post my
problem :)
Have a nice evening :)
- [avr-gcc-list] maybe a bug in gcc-avr?,
lbuchman <=