Skip to content

Instantly share code, notes, and snippets.

@jsleeio
Created December 29, 2013 21:35
Show Gist options
  • Save jsleeio/8175168 to your computer and use it in GitHub Desktop.
Save jsleeio/8175168 to your computer and use it in GitHub Desktop.
avr-gcc adding useless (?) subi instructions, why?
// compiler commandline as below:
// avr-gcc -mmcu=attiny85 -O2 -DF_CPU=16000000L -I. -Iusbdrv -std=c99 -Wall -g -c -o main.o main.c
ISR(ADC_vect) {
adclast = ADMUX & ~_BV(ADLAR);
adcreading[adclast] = ADCH;
ADMUX = adcmux[adclast];
}
section from avr-objdump -D
00000124 <__vector_8>:
124: 1f 92 push r1
126: 0f 92 push r0
128: 0f b6 in r0, 0x3f ; 63
12a: 0f 92 push r0
12c: 11 24 eor r1, r1
12e: 2f 93 push r18
130: 8f 93 push r24
132: 9f 93 push r25
134: ef 93 push r30
136: ff 93 push r31
138: 87 b1 in r24, 0x07 ; 7
13a: 8f 7d andi r24, 0xDF ; 223
13c: 80 93 00 00 sts 0x0000, r24
140: 90 e0 ldi r25, 0x00 ; 0
142: 25 b1 in r18, 0x05 ; 5
144: fc 01 movw r30, r24
146: e0 50 subi r30, 0x00 ; 0
148: f0 40 sbci r31, 0x00 ; 0
14a: 20 83 st Z, r18
14c: fc 01 movw r30, r24
14e: e0 50 subi r30, 0x00 ; 0
150: f0 40 sbci r31, 0x00 ; 0
152: 80 81 ld r24, Z
154: 87 b9 out 0x07, r24 ; 7
156: ff 91 pop r31
158: ef 91 pop r30
15a: 9f 91 pop r25
15c: 8f 91 pop r24
15e: 2f 91 pop r18
160: 0f 90 pop r0
162: 0f be out 0x3f, r0 ; 63
164: 0f 90 pop r0
166: 1f 90 pop r1
168: 18 95 reti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment