1
ADMUX  = ADMUX | _BV(REFS);  // uncompounded bitwise OR
ADMUX |= _BV(REFS0);         // #define _BV(bit) (1 << (bit))
ADMUX |= bit(REFS0);         // #define bit(b) (1UL << (b))
bitSet(ADMUX, REFS0);        // #define bitSet(value, bit) ((value) |= (1UL << (bit)))
sbi(ADMUX, REFS0);           // deprecated assembly? 
ADMUX |= (1 << REFS0);       // shift operator
ADMUX |= (1 << 7);           // bit 7 is named REFS0
ADMUX |= 0b10000000;         // bin
ADMUX |= 0x80;               // hex
ADMUX |= 128;                // dec

*under normal 8 bit Arduino circumstances?

jsotola
  • 1,554
  • 2
  • 12
  • 20
Gaai
  • 55
  • 6

1 Answers1

2

You already got an answer in the comments but, just to make double sure, I tried compiling all these statements for an Uno, and they got all translated into the exact same machine code. Well, almost: I had to do some minor adjustments, which I believe are unrelated to the essence of your question. Just for completeness, I changed the following:

  1. I replaced REFS0 by REFS1: on an Uno, REFS0 is bit 6, and REFS1 is bit 7.

  2. I replaced REFS by REFS1, as the former is not defined.

  3. I #included <compat/deprecated.h>, otherwise I get the error “'sbi' was not declared in this scope”.

Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81