000000be <_Z15detectSemicolonPKc>:
// Return the index of the first semicolon in a string
int detectSemicolon(const char* str) {
be: 0f 93 push r16
c0: 1f 93 push r17
c2: cf 93 push r28
c4: df 93 push r29
c6: 8c 01 movw r16, r24
int i;
Serial.print("i = ");
c8: 69 e0 ldi r22, 0x09 ; 9
ca: 71 e0 ldi r23, 0x01 ; 1
cc: 8c e3 ldi r24, 0x3C ; 60
ce: 91 e0 ldi r25, 0x01 ; 1
d0: 0e 94 c7 02 call 0x58e ; 0x58e <_ZN5Print5printEPKc>
Serial.println(i); // prints "i = 0"
d4: 4a e0 ldi r20, 0x0A ; 10
d6: 50 e0 ldi r21, 0x00 ; 0
d8: c0 e0 ldi r28, 0x00 ; 0
da: d0 e0 ldi r29, 0x00 ; 0
dc: be 01 movw r22, r28
de: 8c e3 ldi r24, 0x3C ; 60
e0: 91 e0 ldi r25, 0x01 ; 1
e2: 0e 94 7f 03 call 0x6fe ; 0x6fe <_ZN5Print7printlnEii>
while (i <= strlen(str)) {
e6: f8 01 movw r30, r16
e8: 01 90 ld r0, Z+
ea: 00 20 and r0, r0
ec: e9 f7 brne .-6 ; 0xe8 <_Z15detectSemicolonPKc+0x2a>
ee: 31 97 sbiw r30, 0x01 ; 1
f0: e0 1b sub r30, r16
f2: f1 0b sbc r31, r17
f4: ec 17 cp r30, r28
f6: fd 07 cpc r31, r29
f8: b0 f0 brcs .+44 ; 0x126 <_Z15detectSemicolonPKc+0x68>
fa: d8 01 movw r26, r16
fc: ac 0f add r26, r28
fe: bd 1f adc r27, r29
if (str[i] == ';') {
100: 8c 91 ld r24, X
102: 8b 33 cpi r24, 0x3B ; 59
104: 71 f4 brne .+28 ; 0x122 <_Z15detectSemicolonPKc+0x64>
Serial.print("Found at i = ");
106: 60 e0 ldi r22, 0x00 ; 0
108: 71 e0 ldi r23, 0x01 ; 1
10a: 8c e3 ldi r24, 0x3C ; 60
10c: 91 e0 ldi r25, 0x01 ; 1
10e: 0e 94 c7 02 call 0x58e ; 0x58e <_ZN5Print5printEPKc>
Serial.println(i); // prints "Found at i = 2"
112: 4a e0 ldi r20, 0x0A ; 10
114: 50 e0 ldi r21, 0x00 ; 0
116: be 01 movw r22, r28
118: 8c e3 ldi r24, 0x3C ; 60
11a: 91 e0 ldi r25, 0x01 ; 1
11c: 0e 94 7f 03 call 0x6fe ; 0x6fe <_ZN5Print7printlnEii>
return i;
120: 08 c0 rjmp .+16 ; 0x132 <_Z15detectSemicolonPKc+0x74>
}
i++;
122: 21 96 adiw r28, 0x01 ; 1
124: e7 cf rjmp .-50 ; 0xf4 <_Z15detectSemicolonPKc+0x36>
}
Serial.println("Error"); // Does not execute
126: 6e e0 ldi r22, 0x0E ; 14
128: 71 e0 ldi r23, 0x01 ; 1
12a: 8c e3 ldi r24, 0x3C ; 60
12c: 91 e0 ldi r25, 0x01 ; 1
12e: 0e 94 d4 02 call 0x5a8 ; 0x5a8 <_ZN5Print7printlnEPKc>
return -999;
}
132: 89 e1 ldi r24, 0x19 ; 25
134: 9c ef ldi r25, 0xFC ; 252
136: df 91 pop r29
138: cf 91 pop r28
13a: 1f 91 pop r17
13c: 0f 91 pop r16
13e: 08 95 ret
[ ... ]
int main() {
Serial.begin(250000);
Serial.println(detectSemicolon("TE;ST")); // Prints "2"
152: 84 e1 ldi r24, 0x14 ; 20
154: 91 e0 ldi r25, 0x01 ; 1
156: 0e 94 5f 00 call 0xbe ; 0xbe <_Z15detectSemicolonPKc>
15a: 4a e0 ldi r20, 0x0A ; 10
15c: 50 e0 ldi r21, 0x00 ; 0
15e: bc 01 movw r22, r24
160: 8c e3 ldi r24, 0x3C ; 60
162: 91 e0 ldi r25, 0x01 ; 1
164: 0e 94 7f 03 call 0x6fe ; 0x6fe <_ZN5Print7printlnEii>
}
168: 80 e0 ldi r24, 0x00 ; 0
16a: 90 e0 ldi r25, 0x00 ; 0
16c: 08 95 ret