Forum: Compiler & IDEs bit_is_set() nur für 8-Bit Speicherstellen?


von Paul H. (powl)


Lesenswert?

Hi!

Sagtmal, funktioniert bit_is_set nur bei 8-Bit Speicherstellen? Bin grad 
bei meinem Programm verzweifelt.
1
#include <avr/io.h>
2
3
uint16_t large;
4
uint8_t small;
5
6
int main(void)
7
{
8
  large = 0xFFFF;
9
  small = 1;
10
11
  if(bit_is_set(large, 10))
12
  {
13
    small = 2;
14
  }
15
}

Das arbeitet hier einfach nicht richtig.. wenn ich if(large & (1 << 10)) 
schreibe, dann funktioniert es. Ist das normal?

lg PoWl

von Philipp B. (philipp_burch)


Lesenswert?

Guck dir halt das Assemblerlisting an...

von Andreas K. (a-k)


Lesenswert?

Die dazu gehörende Doku legt nahe, dass dies nur bei I/O-Ports 
funktioniert (SFR), und auch nur bei 8-Bit Ports (BYTE).

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.