This is a snippet of disassembled avr code from a C project I'm working on. I noticed this curious code being generated and I can't understand how it works. I'm assuming it's some sort of ridiculous optimization...
Can anyone explain?
92: ticks++;
+0000009F: 91900104 LDS R25,0x0104 Load direct from data space
+000000A1: 5F9F SUBI R25,0xFF Subtract immediate
+000000A2: 93900104 STS 0x0104,R25 Store direct to data space
95: if (ticks == 0) {
+000000A4: 2399 TST R25 Test for Zero or Minus
+000000A5: F009 BREQ PC+0x02 Branch if equal
+000000A6: C067 RJMP PC+0x0068 Relative jump