I have the following code in my ATMega 6450 program:
x = read_fuse(); // Read fuse high byte to check OCDEN if (x & (1 << OCDEN) != 0) { ...
The compiler turns it into this asm:
(0749) x = read_fuse(); // Read fuse high byte to check OCDEN 004B3 D018 RCALL _read_fuse 004B4 2EA0 MOV R10,R16 (0750) if (x & (1 << OCDEN) != 0) { 004B5 FF00 SBRS R16,0 004B6 C006 RJMP 0x04BD
I've confirmed that the asm places the fuse high byte in R16 (in the read_fuse() function). OCDEN, however, is bit 7 in the fuse byte, so I can't figure out why the SBRS instruction at 004B5 is testing bit 0. What's more, the value of the fuse byte (and x) is 0x19, yet the if statement evaluates to true. Is (1 << OCDEN) being compared to 0 before being ANDed with x? What am I doing wrong? Thanks.