AVR Assembler Analog Comparator (AC), Select any of the ADC[7:0] pins

AVR Assembler Analog Comparator (AC), Select any of the ADC[7:0] pins
  1. Arduino UNO
.nolist .include "./m328Pdef.inc" .list ; positive pin AIN0 = PD6 ; negative pin AIN1 = PD7 .def temp = r16 .org 0x0000 rjmp start start: ldi temp, high(RAMEND) out sph, temp ldi temp, low(RAMEND) out spl, temp sbi ddrb, 5 ldi temp, (1<<ACME) ; Analog Comparator Multiplexer Enable sts ADCSRB, temp lds temp, ADCSRA andi temp, (0xff^(1<<ADEN)) ; disable ADC sts ADCSRA, temp loop: ldi temp, (1<<MUX0)|(1<<MUX2) ; PC5 sts ADMUX, temp rcall toggle rjmp loop toggle: in temp, ACSR sbrs temp, ACO ; Analog Comparator Output sbi PORTB, 5 sbrc temp, ACO ; Analog Comparator Output cbi PORTB, 5 ret