Rev Author Line No. Line
1234 kaklik 1  
2 glg.elf: file format elf32-avr
3  
4 Sections:
5 Idx Name Size VMA LMA File off Algn
6  
7 CONTENTS, ALLOC, LOAD, DATA
8 1 .text 000022ec 00000000 00000000 00000074 2**1
9 CONTENTS, ALLOC, LOAD, READONLY, CODE
10 2 .bss 00000341 00800106 000022f2 00002366 2**0
11 ALLOC
12 3 .stab 0000087c 00000000 00000000 00002368 2**2
13 CONTENTS, READONLY, DEBUGGING
14 4 .stabstr 0000019e 00000000 00000000 00002be4 2**0
15 CONTENTS, READONLY, DEBUGGING
16 5 .debug_aranges 00000060 00000000 00000000 00002d82 2**0
17 CONTENTS, READONLY, DEBUGGING
18 6 .debug_pubnames 0000019e 00000000 00000000 00002de2 2**0
19 CONTENTS, READONLY, DEBUGGING
20 7 .debug_info 00001cfd 00000000 00000000 00002f80 2**0
21 CONTENTS, READONLY, DEBUGGING
22 8 .debug_abbrev 000007a6 00000000 00000000 00004c7d 2**0
23 CONTENTS, READONLY, DEBUGGING
24 9 .debug_line 000019a4 00000000 00000000 00005423 2**0
25 CONTENTS, READONLY, DEBUGGING
26 10 .debug_frame 00000260 00000000 00000000 00006dc8 2**2
27 CONTENTS, READONLY, DEBUGGING
1254 kaklik 28 11 .debug_str 000005e7 00000000 00000000 00007028 2**0
1234 kaklik 29 CONTENTS, READONLY, DEBUGGING
1254 kaklik 30 12 .debug_loc 000020ca 00000000 00000000 0000760f 2**0
1234 kaklik 31 CONTENTS, READONLY, DEBUGGING
1254 kaklik 32 13 .debug_ranges 00000178 00000000 00000000 000096d9 2**0
1234 kaklik 33 CONTENTS, READONLY, DEBUGGING
34 Disassembly of section .text:
35  
36 00000000 <__vectors>:
37 0: 0c 94 4c 00 jmp 0x98 ; 0x98 <__ctors_end>
38 4: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
39 8: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
40 c: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
41 10: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
42 14: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
43 18: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
44 1c: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
45 20: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
46 24: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
47 28: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
48 2c: 0c 94 7a 01 jmp 0x2f4 ; 0x2f4 <__vector_11>
49 30: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
50 34: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
51 38: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
52 3c: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
53 40: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
54 44: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
55 48: 0c 94 d6 00 jmp 0x1ac ; 0x1ac <__vector_18>
56 4c: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
57 50: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
58 54: 0c 94 6b 00 jmp 0xd6 ; 0xd6 <__vector_21>
59 58: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
60 5c: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
61 60: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
62 64: 0c 94 69 00 jmp 0xd2 ; 0xd2 <__bad_interrupt>
63  
64 00000068 <__c.2081>:
65 68: 0d 0a 00 ...
66  
67 0000006b <__c.2079>:
68 6b: 2c 00 ,.
69  
70 0000006d <__c.2075>:
71 6d: 24 47 50 52 4d 43 00 $GPRMC.
72  
73 00000074 <__c.2073>:
74 74: 24 47 50 47 47 41 00 $GPGGA.
75  
76 0000007b <__c.2071>:
77 7b: 2e 6c 6f 67 00 .log.
78  
79 00000080 <__c.2065>:
80 80: 24 47 50 52 4d 43 00 $GPRMC.
81  
82 00000087 <__c.2014>:
83 87: 24 50 53 52 46 31 30 36 2c 32 31 2a 30 46 0d 0a $PSRF106,21*0F..
84 ...
85  
86 00000098 <__ctors_end>:
87 98: 11 24 eor r1, r1
88 9a: 1f be out 0x3f, r1 ; 63
89 9c: cf ef ldi r28, 0xFF ; 255
90 9e: d4 e0 ldi r29, 0x04 ; 4
91 a0: de bf out 0x3e, r29 ; 62
92 a2: cd bf out 0x3d, r28 ; 61
93  
94 000000a4 <__do_copy_data>:
95 a4: 11 e0 ldi r17, 0x01 ; 1
96 a6: a0 e0 ldi r26, 0x00 ; 0
97 a8: b1 e0 ldi r27, 0x01 ; 1
98 aa: ec ee ldi r30, 0xEC ; 236
99 ac: f2 e2 ldi r31, 0x22 ; 34
100 ae: 02 c0 rjmp .+4 ; 0xb4 <.do_copy_data_start>
101  
102 000000b0 <.do_copy_data_loop>:
103 b0: 05 90 lpm r0, Z+
104 b2: 0d 92 st X+, r0
105  
106 000000b4 <.do_copy_data_start>:
107 b4: a6 30 cpi r26, 0x06 ; 6
108 b6: b1 07 cpc r27, r17
109 b8: d9 f7 brne .-10 ; 0xb0 <.do_copy_data_loop>
110  
111 000000ba <__do_clear_bss>:
112 ba: 14 e0 ldi r17, 0x04 ; 4
113 bc: a6 e0 ldi r26, 0x06 ; 6
114 be: b1 e0 ldi r27, 0x01 ; 1
115 c0: 01 c0 rjmp .+2 ; 0xc4 <.do_clear_bss_start>
116  
117 000000c2 <.do_clear_bss_loop>:
118 c2: 1d 92 st X+, r1
119  
120 000000c4 <.do_clear_bss_start>:
121 c4: a7 34 cpi r26, 0x47 ; 71
122 c6: b1 07 cpc r27, r17
123 c8: e1 f7 brne .-8 ; 0xc2 <.do_clear_bss_loop>
124 ca: 0e 94 ba 01 call 0x374 ; 0x374 <main>
125 ce: 0c 94 75 11 jmp 0x22ea ; 0x22ea <_exit>
126  
127 000000d2 <__bad_interrupt>:
128 d2: 0c 94 00 00 jmp 0 ; 0x0 <__heap_end>
129  
130 000000d6 <__vector_21>:
131 /*---------------------------------------------------------*/
132 /* ADC interrupt */
133 /*---------------------------------------------------------*/
134  
135 ISR(ADC_vect)
136 {
137 d6: 1f 92 push r1
138 d8: 0f 92 push r0
139 da: 0f b6 in r0, 0x3f ; 63
140 dc: 0f 92 push r0
141 de: 11 24 eor r1, r1
142 e0: 2f 93 push r18
143 e2: 3f 93 push r19
144 e4: 8f 93 push r24
145 WORD n;
146 static BYTE l, h;
147  
148 n = ADC;
149 e6: 20 91 78 00 lds r18, 0x0078
150 ea: 30 91 79 00 lds r19, 0x0079
151  
152 if(ADMUX == POWER_check)
153 ee: 80 91 7c 00 lds r24, 0x007C
154 {
155 if (n < VTH_LOW) {
156 f2: 20 3d cpi r18, 0xD0 ; 208
157 f4: 31 05 cpc r19, r1
158 f6: 70 f4 brcc .+28 ; 0x114 <__vector_21+0x3e>
159 if (l >= 15) {
160 f8: 80 91 09 01 lds r24, 0x0109
161 fc: 8f 30 cpi r24, 0x0F ; 15
162 fe: 30 f0 brcs .+12 ; 0x10c <__vector_21+0x36>
163 Stat |= 0x01;
164 100: 80 91 69 01 lds r24, 0x0169
165 104: 81 60 ori r24, 0x01 ; 1
166 106: 80 93 69 01 sts 0x0169, r24
167 10a: 06 c0 rjmp .+12 ; 0x118 <__vector_21+0x42>
168 }
169 else {l++;}
170 10c: 8f 5f subi r24, 0xFF ; 255
171 10e: 80 93 09 01 sts 0x0109, r24
172 112: 02 c0 rjmp .+4 ; 0x118 <__vector_21+0x42>
173 }
174 else {l = 0;}
175 114: 10 92 09 01 sts 0x0109, r1
176  
177 if (n > VTH_HIGH) {
178 118: 81 e0 ldi r24, 0x01 ; 1
179 11a: 2c 32 cpi r18, 0x2C ; 44
180 11c: 38 07 cpc r19, r24
181 11e: 70 f0 brcs .+28 ; 0x13c <__vector_21+0x66>
182 if (h >= 15) {
183 120: 80 91 08 01 lds r24, 0x0108
184 124: 8f 30 cpi r24, 0x0F ; 15
185 126: 30 f0 brcs .+12 ; 0x134 <__vector_21+0x5e>
186 Stat &= 0xFE;
187 128: 80 91 69 01 lds r24, 0x0169
188 12c: 8e 7f andi r24, 0xFE ; 254
189 12e: 80 93 69 01 sts 0x0169, r24
190 132: 06 c0 rjmp .+12 ; 0x140 <__vector_21+0x6a>
191 }
192 else {h++;}
193 134: 8f 5f subi r24, 0xFF ; 255
194 136: 80 93 08 01 sts 0x0108, r24
195 13a: 02 c0 rjmp .+4 ; 0x140 <__vector_21+0x6a>
196 }
197 else {h = 0;}
198 13c: 10 92 08 01 sts 0x0108, r1
199  
200 battery = n;
201 140: 30 93 6f 01 sts 0x016F, r19
202 144: 20 93 6e 01 sts 0x016E, r18
203 ADMUX = ANALOG_IN1;
204 148: 82 e4 ldi r24, 0x42 ; 66
205 14a: 80 93 7c 00 sts 0x007C, r24
206 }
207  
208 if(ADMUX == ANALOG_IN1)
209 14e: 80 91 7c 00 lds r24, 0x007C
210 {
211 intensity = n;
212 152: 30 93 0a 02 sts 0x020A, r19
213 156: 20 93 09 02 sts 0x0209, r18
214 ADMUX = POWER_check;
215 15a: 81 e4 ldi r24, 0x41 ; 65
216 15c: 80 93 7c 00 sts 0x007C, r24
217 }
218  
219 //!!!!
220 //Stat &= 0xFE;
221  
222 ADCSRA = _BV(ADEN)|_BV(ADSC)|_BV(ADIF)|_BV(ADIE)|0b111;
223 160: 8f ed ldi r24, 0xDF ; 223
224 162: 80 93 7a 00 sts 0x007A, r24
225 166: 8f 91 pop r24
226 168: 3f 91 pop r19
227 16a: 2f 91 pop r18
228 16c: 0f 90 pop r0
229 16e: 0f be out 0x3f, r0 ; 63
230 170: 0f 90 pop r0
231 172: 1f 90 pop r1
232 174: 18 95 reti
233  
234 00000176 <get_fattime>:
235 /* FatFs module. Any valid time must be returned even if */
236 /* the system does not support a real time clock. */
237  
238  
239 DWORD get_fattime ()
240 {
241 176: 60 e0 ldi r22, 0x00 ; 0
242 178: 70 e0 ldi r23, 0x00 ; 0
243 17a: 81 ea ldi r24, 0xA1 ; 161
244 17c: 96 e3 ldi r25, 0x36 ; 54
245 17e: 08 95 ret
246  
247 00000180 <uart_init>:
248 /* UART control */
249  
250  
251 static
252 void uart_init (void)
253 {
254 180: f8 94 cli
255 cli();
256 UCSR0B = 0;
257 182: e1 ec ldi r30, 0xC1 ; 193
258 184: f0 e0 ldi r31, 0x00 ; 0
259 186: 10 82 st Z, r1
260 rxfifo.idx_r = 0;
261 188: 10 92 71 01 sts 0x0171, r1
262 rxfifo.idx_w = 0;
263 18c: 10 92 70 01 sts 0x0170, r1
264 rxfifo.count = 0;
265 190: 10 92 72 01 sts 0x0172, r1
266 UBRR0L = SYSCLK/16/9600; // Enable USRAT0 in N81,4800bps
267 194: 81 e4 ldi r24, 0x41 ; 65
268 196: 80 93 c4 00 sts 0x00C4, r24
269 UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0);
270 19a: 88 e9 ldi r24, 0x98 ; 152
271 19c: 80 83 st Z, r24
272 Stat &= 0xFD; // Clear overflow flag
273 19e: 80 91 69 01 lds r24, 0x0169
274 1a2: 8d 7f andi r24, 0xFD ; 253
275 1a4: 80 93 69 01 sts 0x0169, r24
276 sei();
277 1a8: 78 94 sei
278 1aa: 08 95 ret
279  
280 000001ac <__vector_18>:
281 }
282  
283  
284 /* USART0 RXC interrupt */
285 ISR(USART_RX_vect)
286 {
287 1ac: 1f 92 push r1
288 1ae: 0f 92 push r0
289 1b0: 0f b6 in r0, 0x3f ; 63
290 1b2: 0f 92 push r0
291 1b4: 11 24 eor r1, r1
292 1b6: 8f 93 push r24
293 1b8: 9f 93 push r25
294 1ba: ef 93 push r30
295 1bc: ff 93 push r31
296 uint8_t d, n, i;
297  
298  
299 d = UDR0;
300 1be: 90 91 c6 00 lds r25, 0x00C6
301 n = rxfifo.count;
302 1c2: 80 91 72 01 lds r24, 0x0172
303 if(n < sizeof(rxfifo.buff)) {
304 1c6: 86 39 cpi r24, 0x96 ; 150
305 1c8: 88 f4 brcc .+34 ; 0x1ec <__vector_18+0x40>
306 rxfifo.count = ++n;
307 1ca: 8f 5f subi r24, 0xFF ; 255
308 1cc: 80 93 72 01 sts 0x0172, r24
309 i = rxfifo.idx_w;
310 1d0: 80 91 70 01 lds r24, 0x0170
311 rxfifo.buff[i++] = d;
312 1d4: e8 2f mov r30, r24
313 1d6: ff 27 eor r31, r31
314 1d8: e0 59 subi r30, 0x90 ; 144
315 1da: fe 4f sbci r31, 0xFE ; 254
316 1dc: 93 83 std Z+3, r25 ; 0x03
317 1de: 8f 5f subi r24, 0xFF ; 255
318 if(i >= sizeof(rxfifo.buff))
319 1e0: 86 39 cpi r24, 0x96 ; 150
320 1e2: 08 f0 brcs .+2 ; 0x1e6 <__vector_18+0x3a>
321 1e4: 80 e0 ldi r24, 0x00 ; 0
322 i = 0;
323 rxfifo.idx_w = i;
324 1e6: 80 93 70 01 sts 0x0170, r24
325 1ea: 05 c0 rjmp .+10 ; 0x1f6 <__vector_18+0x4a>
326 } else {
327 Stat |= 2;
328 1ec: 80 91 69 01 lds r24, 0x0169
329 1f0: 82 60 ori r24, 0x02 ; 2
330 1f2: 80 93 69 01 sts 0x0169, r24
331 1f6: ff 91 pop r31
332 1f8: ef 91 pop r30
333 1fa: 9f 91 pop r25
334 1fc: 8f 91 pop r24
335 1fe: 0f 90 pop r0
336 200: 0f be out 0x3f, r0 ; 63
337 202: 0f 90 pop r0
338 204: 1f 90 pop r1
339 206: 18 95 reti
340  
341 00000208 <get_line>:
342 /* Get a line received from GPS module */
343 /*----------------------------------------------------*/
344  
345 static
346 BYTE get_line (void) // 0: Power fail occured, >0: Number of bytes received.
347 {
348 208: 90 e0 ldi r25, 0x00 ; 0
349 BYTE c, i = 0;
350  
351  
352 for (;;) {
353 if (Stat & 1) return 0; // When power fail is detected, return with zero.
354 20a: 80 91 69 01 lds r24, 0x0169
355 20e: 80 ff sbrs r24, 0
356 210: 03 c0 rjmp .+6 ; 0x218 <get_line+0x10>
357 212: 80 e0 ldi r24, 0x00 ; 0
358 214: 90 e0 ldi r25, 0x00 ; 0
359 216: 08 95 ret
360 uint8_t uart_get ()
361 {
362 uint8_t d, i;
363  
364  
365 i = rxfifo.idx_r;
366 218: 20 91 71 01 lds r18, 0x0171
367 if (rxfifo.count == 0) return 0;
368 21c: 80 91 72 01 lds r24, 0x0172
369 220: 88 23 and r24, r24
370 222: 19 f4 brne .+6 ; 0x22a <get_line+0x22>
371 224: 20 e0 ldi r18, 0x00 ; 0
372 226: 30 e0 ldi r19, 0x00 ; 0
373 228: 15 c0 rjmp .+42 ; 0x254 <get_line+0x4c>
374 d = rxfifo.buff[i++];
375 22a: e2 2f mov r30, r18
376 22c: ff 27 eor r31, r31
377 22e: e0 59 subi r30, 0x90 ; 144
378 230: fe 4f sbci r31, 0xFE ; 254
379 232: 33 81 ldd r19, Z+3 ; 0x03
380 234: e2 2f mov r30, r18
381 236: ef 5f subi r30, 0xFF ; 255
382 cli();
383 238: f8 94 cli
384 rxfifo.count--;
385 23a: 80 91 72 01 lds r24, 0x0172
386 23e: 81 50 subi r24, 0x01 ; 1
387 240: 80 93 72 01 sts 0x0172, r24
388 sei();
389 244: 78 94 sei
390 if(i >= sizeof(rxfifo.buff))
391 246: e6 39 cpi r30, 0x96 ; 150
392 248: 08 f0 brcs .+2 ; 0x24c <get_line+0x44>
393 24a: e0 e0 ldi r30, 0x00 ; 0
394 i = 0;
395 rxfifo.idx_r = i;
396 24c: e0 93 71 01 sts 0x0171, r30
397  
398 return d;
399 250: 23 2f mov r18, r19
400 252: 33 27 eor r19, r19
401  
402  
403 for (;;) {
404 if (Stat & 1) return 0; // When power fail is detected, return with zero.
405 c = uart_get();
406 if (Stat & 2) { // When buffer overflow has occured, restert to receive line.
407 254: 80 91 69 01 lds r24, 0x0169
408 258: 81 ff sbrs r24, 1
409 25a: 03 c0 rjmp .+6 ; 0x262 <get_line+0x5a>
410 uart_init();
411 25c: 0e 94 c0 00 call 0x180 ; 0x180 <uart_init>
412 260: d3 cf rjmp .-90 ; 0x208 <get_line>
413 BYTE c, i = 0;
414  
415  
416 for (;;) {
417 if (Stat & 1) return 0; // When power fail is detected, return with zero.
418 c = uart_get();
419 262: 82 2f mov r24, r18
420 if (Stat & 2) { // When buffer overflow has occured, restert to receive line.
421 uart_init();
422 i = 0; c = 0;
423 }
424 if (!c || (i == 0 && c != '$')) continue;
425 264: 22 23 and r18, r18
426 266: 89 f2 breq .-94 ; 0x20a <get_line+0x2>
427 268: 99 23 and r25, r25
428 26a: 11 f4 brne .+4 ; 0x270 <get_line+0x68>
429 26c: 24 32 cpi r18, 0x24 ; 36
430 26e: 69 f6 brne .-102 ; 0x20a <get_line+0x2>
431 Buff[i++] = c;
432 270: e9 2f mov r30, r25
433 272: ff 27 eor r31, r31
434 274: e9 5e subi r30, 0xE9 ; 233
435 276: fe 4f sbci r31, 0xFE ; 254
436 278: 20 83 st Z, r18
437 27a: 9f 5f subi r25, 0xFF ; 255
438 if (c == '\n') break;
439 27c: 8a 30 cpi r24, 0x0A ; 10
440 27e: 21 f0 breq .+8 ; 0x288 <get_line+0x80>
441 if (i >= sizeof(Buff)) i = 0;
442 280: 92 35 cpi r25, 0x52 ; 82
443 282: 08 f0 brcs .+2 ; 0x286 <get_line+0x7e>
444 284: c1 cf rjmp .-126 ; 0x208 <get_line>
445 286: c1 cf rjmp .-126 ; 0x20a <get_line+0x2>
446 }
447 return i;
448 288: 89 2f mov r24, r25
449 28a: 99 27 eor r25, r25
450 }
451 28c: 08 95 ret
452  
453 0000028e <beep>:
454 /*--------------------------------------------------------------------------*/
455 /* Controls */
456  
457 static
458 void beep (BYTE len, BYTE cnt)
459 {
460 28e: 98 2f mov r25, r24
461 290: 0f c0 rjmp .+30 ; 0x2b0 <beep+0x22>
462 while (cnt--) {
463 BEEP_ON();
464 292: 83 e0 ldi r24, 0x03 ; 3
465 294: 85 bd out 0x25, r24 ; 37
466 DELAY(len);
467 296: 90 93 16 01 sts 0x0116, r25
468 29a: 80 91 16 01 lds r24, 0x0116
469 29e: 88 23 and r24, r24
470 2a0: e1 f7 brne .-8 ; 0x29a <beep+0xc>
471 BEEP_OFF();
472 2a2: 15 bc out 0x25, r1 ; 37
473 DELAY(len);
474 2a4: 90 93 16 01 sts 0x0116, r25
475 2a8: 80 91 16 01 lds r24, 0x0116
476 2ac: 88 23 and r24, r24
477 2ae: e1 f7 brne .-8 ; 0x2a8 <beep+0x1a>
478 /* Controls */
479  
480 static
481 void beep (BYTE len, BYTE cnt)
482 {
483 while (cnt--) {
484 2b0: 61 50 subi r22, 0x01 ; 1
485 2b2: 78 f7 brcc .-34 ; 0x292 <beep+0x4>
486 2b4: 08 95 ret
487  
488 000002b6 <gp_comp>:
489  
490  
491 /* Compare sentence header string */
492 static
493 BYTE gp_comp (BYTE *str1, const prog_uint8_t *str2)
494 {
495 2b6: dc 01 movw r26, r24
496 2b8: fb 01 movw r30, r22
497 BYTE c;
498  
499 do {
500 c = pgm_read_byte(str2++);
501 2ba: 6f 5f subi r22, 0xFF ; 255
502 2bc: 7f 4f sbci r23, 0xFF ; 255
503 2be: 94 91 lpm r25, Z
504 } while (c && c == *str1++);
505 2c0: 99 23 and r25, r25
506 2c2: 29 f0 breq .+10 ; 0x2ce <gp_comp+0x18>
507 2c4: 8c 91 ld r24, X
508 2c6: 98 17 cp r25, r24
509 2c8: 11 f4 brne .+4 ; 0x2ce <gp_comp+0x18>
510 2ca: 11 96 adiw r26, 0x01 ; 1
511 2cc: f5 cf rjmp .-22 ; 0x2b8 <gp_comp+0x2>
512 return c;
513 }
514 2ce: 89 2f mov r24, r25
515 2d0: 99 27 eor r25, r25
516 2d2: 08 95 ret
517  
518 000002d4 <gp_col>:
519 /* Get a column item */
520 static
521 BYTE* gp_col ( /* Returns pointer to the item (returns a NULL when not found) */
522 const BYTE* buf, /* Pointer to the sentence */
523 BYTE col /* Column number (0 is the 1st item) */
524 ) {
525 2d4: fc 01 movw r30, r24
526 2d6: 0a c0 rjmp .+20 ; 0x2ec <gp_col+0x18>
527 BYTE c;
528  
529  
530 while (col) {
531 do {
532 c = *buf++;
533 2d8: 80 81 ld r24, Z
534 if (c <= ' ') return NULL;
535 2da: 81 32 cpi r24, 0x21 ; 33
536 2dc: 18 f4 brcc .+6 ; 0x2e4 <gp_col+0x10>
537 2de: 80 e0 ldi r24, 0x00 ; 0
538 2e0: 90 e0 ldi r25, 0x00 ; 0
539 2e2: 08 95 ret
540 BYTE c;
541  
542  
543 while (col) {
544 do {
545 c = *buf++;
546 2e4: 31 96 adiw r30, 0x01 ; 1
547 if (c <= ' ') return NULL;
548 } while (c != ',');
549 2e6: 8c 32 cpi r24, 0x2C ; 44
550 2e8: b9 f7 brne .-18 ; 0x2d8 <gp_col+0x4>
551 col--;
552 2ea: 61 50 subi r22, 0x01 ; 1
553 BYTE col /* Column number (0 is the 1st item) */
554 ) {
555 BYTE c;
556  
557  
558 while (col) {
559 2ec: 66 23 and r22, r22
560 2ee: a1 f7 brne .-24 ; 0x2d8 <gp_col+0x4>
561 c = *buf++;
562 if (c <= ' ') return NULL;
563 } while (c != ',');
564 col--;
565 }
566 return (BYTE*)buf;
567 2f0: cf 01 movw r24, r30
568 }
569 2f2: 08 95 ret
570  
571 000002f4 <__vector_11>:
572 /* 100Hz timer interrupt generated by OC1A */
573 /*---------------------------------------------------------*/
574  
575  
576 ISR(TIMER1_COMPA_vect)
577 {
578 2f4: 1f 92 push r1
579 2f6: 0f 92 push r0
580 2f8: 0f b6 in r0, 0x3f ; 63
581 2fa: 0f 92 push r0
582 2fc: 11 24 eor r1, r1
583 2fe: 2f 93 push r18
584 300: 3f 93 push r19
585 302: 4f 93 push r20
586 304: 5f 93 push r21
587 306: 6f 93 push r22
588 308: 7f 93 push r23
589 30a: 8f 93 push r24
590 30c: 9f 93 push r25
591 30e: af 93 push r26
592 310: bf 93 push r27
593 312: ef 93 push r30
594 314: ff 93 push r31
595 BYTE n;
596 static WORD ivt_sync;
597  
598  
599 n = Timer;
600 316: 80 91 16 01 lds r24, 0x0116
601 if (n) Timer = n - 1;
602 31a: 88 23 and r24, r24
603 31c: 19 f0 breq .+6 ; 0x324 <__vector_11+0x30>
604 31e: 81 50 subi r24, 0x01 ; 1
605 320: 80 93 16 01 sts 0x0116, r24
606  
607 if (++ivt_sync >= 180 * 100) {
608 324: 80 91 06 01 lds r24, 0x0106
609 328: 90 91 07 01 lds r25, 0x0107
610 32c: 01 96 adiw r24, 0x01 ; 1
611 32e: 90 93 07 01 sts 0x0107, r25
612 332: 80 93 06 01 sts 0x0106, r24
613 336: 80 55 subi r24, 0x50 ; 80
614 338: 96 44 sbci r25, 0x46 ; 70
615 33a: 48 f0 brcs .+18 ; 0x34e <__vector_11+0x5a>
616 ivt_sync = 0;
617 33c: 10 92 07 01 sts 0x0107, r1
618 340: 10 92 06 01 sts 0x0106, r1
619 Stat |= 4;
620 344: 80 91 69 01 lds r24, 0x0169
621 348: 84 60 ori r24, 0x04 ; 4
622 34a: 80 93 69 01 sts 0x0169, r24
623 }
624  
625 disk_timerproc(); /* Drive timer procedure of low level disk I/O module */
626 34e: 0e 94 c8 0d call 0x1b90 ; 0x1b90 <disk_timerproc>
627 352: ff 91 pop r31
628 354: ef 91 pop r30
629 356: bf 91 pop r27
630 358: af 91 pop r26
631 35a: 9f 91 pop r25
632 35c: 8f 91 pop r24
633 35e: 7f 91 pop r23
634 360: 6f 91 pop r22
635 362: 5f 91 pop r21
636 364: 4f 91 pop r20
637 366: 3f 91 pop r19
638 368: 2f 91 pop r18
639 36a: 0f 90 pop r0
640 36c: 0f be out 0x3f, r0 ; 63
641 36e: 0f 90 pop r0
642 370: 1f 90 pop r1
643 372: 18 95 reti
644  
645 00000374 <main>:
646 /*-----------------------------------------------------------------------*/
647 /* Main */
648  
649  
650 int main ()
651 {
652 374: cd ef ldi r28, 0xFD ; 253
653 376: d4 e0 ldi r29, 0x04 ; 4
654 378: de bf out 0x3e, r29 ; 62
655 37a: cd bf out 0x3d, r28 ; 61
656  
657  
658 static
659 void ioinit (void)
660 {
661 PORTB = 0b00001101; // Port B
662 37c: 8d e0 ldi r24, 0x0D ; 13
663 37e: 85 b9 out 0x05, r24 ; 5
664 DDRB = 0b00101110;
665 380: 8e e2 ldi r24, 0x2E ; 46
666 382: 84 b9 out 0x04, r24 ; 4
667 PORTC = 0b00111111; // Port C
668 384: 8f e3 ldi r24, 0x3F ; 63
669 386: 88 b9 out 0x08, r24 ; 8
670 DDRC = 0b00000000;
671 388: 17 b8 out 0x07, r1 ; 7
672 PORTD = 0b10101110; // Port D
673 38a: 8e ea ldi r24, 0xAE ; 174
674 38c: 8b b9 out 0x0b, r24 ; 11
675 DDRD = 0b01010010;
676 38e: 82 e5 ldi r24, 0x52 ; 82
677 390: 8a b9 out 0x0a, r24 ; 10
678  
679 SPCR = 0b01010000; /* Initialize SPI port (Mode 0) */
680 392: 80 e5 ldi r24, 0x50 ; 80
681 394: 8c bd out 0x2c, r24 ; 44
682 SPSR = 0b00000001;
683 396: 81 e0 ldi r24, 0x01 ; 1
684 398: 8d bd out 0x2d, r24 ; 45
685  
686 OCR1A = SYSCLK/8/100-1; // Timer1: 100Hz interval (OC1A)
687 39a: 83 ed ldi r24, 0xD3 ; 211
688 39c: 90 e3 ldi r25, 0x30 ; 48
689 39e: 90 93 89 00 sts 0x0089, r25
690 3a2: 80 93 88 00 sts 0x0088, r24
691 TCCR1B = 0b00001010;
692 3a6: 8a e0 ldi r24, 0x0A ; 10
693 3a8: 80 93 81 00 sts 0x0081, r24
694 TIMSK1 = _BV(OCIE1A); // Enable TC1.oca interrupt
695 3ac: 82 e0 ldi r24, 0x02 ; 2
696 3ae: 80 93 6f 00 sts 0x006F, r24
697  
698 OCR0A = SYSCLK/64/4000/2-1; // Timer0: 4kHz sound (OC0A)
699 3b2: 82 e1 ldi r24, 0x12 ; 18
700 3b4: 87 bd out 0x27, r24 ; 39
701 TCCR0A = 0b01000010;
702 3b6: 82 e4 ldi r24, 0x42 ; 66
703 3b8: 84 bd out 0x24, r24 ; 36
704  
705 ADMUX = POWER_check; // Select ADC input
706 3ba: 81 e4 ldi r24, 0x41 ; 65
707 3bc: 80 93 7c 00 sts 0x007C, r24
708 ADCSRA = _BV(ADEN)|_BV(ADSC)|_BV(ADIF)|_BV(ADIE)|0b111;
709 3c0: 8f ed ldi r24, 0xDF ; 223
710 3c2: 80 93 7a 00 sts 0x007A, r24
711  
712 sei();
713 3c6: 78 94 sei
714 BYTE b, err, *p = NULL;
715 WORD s;
716  
717  
718 ioinit();
719 f_mount(0, &fatfs); /* Enable file I/O layer */
720 3c8: 67 e2 ldi r22, 0x27 ; 39
721 3ca: 72 e0 ldi r23, 0x02 ; 2
722 3cc: 80 e0 ldi r24, 0x00 ; 0
723 3ce: 0e 94 ef 08 call 0x11de ; 0x11de <f_mount>
724 3d2: cc 24 eor r12, r12
725 3d4: dd 24 eor r13, r13
726 3d6: 47 e1 ldi r20, 0x17 ; 23
727 3d8: e4 2e mov r14, r20
728 3da: 41 e0 ldi r20, 0x01 ; 1
729 3dc: f4 2e mov r15, r20
730 3de: 3b e0 ldi r19, 0x0B ; 11
731 3e0: a3 2e mov r10, r19
732 3e2: 32 e0 ldi r19, 0x02 ; 2
733 3e4: b3 2e mov r11, r19
734 // || !gp_comp(Buff, PSTR("$GPGSV"))
735 // || !gp_comp(Buff, PSTR("$GPZDA"))
736 // || !gp_comp(Buff, PSTR("$GPVTG"))
737 )
738 {
739 if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
740 3e6: 2e 01 movw r4, r28
741 3e8: 08 94 sec
742 3ea: 41 1c adc r4, r1
743 3ec: 51 1c adc r5, r1
744 3ee: 22 e1 ldi r18, 0x12 ; 18
745 3f0: 62 2e mov r6, r18
746 3f2: 21 e0 ldi r18, 0x01 ; 1
747 3f4: 72 2e mov r7, r18
748 3f6: 9a e6 ldi r25, 0x6A ; 106
749 3f8: 89 2e mov r8, r25
750 3fa: 91 e0 ldi r25, 0x01 ; 1
751 3fc: 99 2e mov r9, r25
752 3fe: 89 e0 ldi r24, 0x09 ; 9
753 400: 28 2e mov r2, r24
754 402: 31 2c mov r3, r1
755 404: 2e 0c add r2, r14
756 406: 3f 1c adc r3, r15
757  
758  
759 static
760 void uart_stop (void)
761 {
762 UCSR0B = 0;
763 408: 10 92 c1 00 sts 0x00C1, r1
764 ioinit();
765 f_mount(0, &fatfs); /* Enable file I/O layer */
766  
767 for (;;) {
768 uart_stop();
769 GPS_OFF();
770 40c: 29 98 cbi 0x05, 1 ; 5
771 Timer = 100;
772 40e: 84 e6 ldi r24, 0x64 ; 100
773 410: 80 93 16 01 sts 0x0116, r24
774 do {
775 if (Stat & 1) Timer = 100;
776 414: 80 91 69 01 lds r24, 0x0169
777 418: 80 ff sbrs r24, 0
778 41a: 03 c0 rjmp .+6 ; 0x422 <main+0xae>
779 41c: 84 e6 ldi r24, 0x64 ; 100
780 41e: 80 93 16 01 sts 0x0116, r24
781 } while (Timer);
782 422: 80 91 16 01 lds r24, 0x0116
783 426: 88 23 and r24, r24
784 428: a9 f7 brne .-22 ; 0x414 <main+0xa0>
785  
786 GPS_ON();
787 42a: 29 9a sbi 0x05, 1 ; 5
788 Timer = 255;
789 42c: 8f ef ldi r24, 0xFF ; 255
790 42e: 80 93 16 01 sts 0x0116, r24
791 do {
792 if ((Stat & 1) || (disk_status(0) & STA_NODISK)) Timer = 255;
793 432: 80 91 69 01 lds r24, 0x0169
794 436: 80 fd sbrc r24, 0
795 438: 05 c0 rjmp .+10 ; 0x444 <main+0xd0>
796 43a: 80 e0 ldi r24, 0x00 ; 0
797 43c: 0e 94 bf 0d call 0x1b7e ; 0x1b7e <disk_status>
798 440: 81 ff sbrs r24, 1
799 442: 03 c0 rjmp .+6 ; 0x44a <main+0xd6>
800 444: 8f ef ldi r24, 0xFF ; 255
801 446: 80 93 16 01 sts 0x0116, r24
802 } while (Timer);
803 44a: 80 91 16 01 lds r24, 0x0116
804 44e: 88 23 and r24, r24
805 450: 81 f7 brne .-32 ; 0x432 <main+0xbe>
806  
807 beep(5, 1); // Single beep. Start to get current time.
808 452: 61 e0 ldi r22, 0x01 ; 1
809 454: 85 e0 ldi r24, 0x05 ; 5
810 456: 0e 94 47 01 call 0x28e ; 0x28e <beep>
811 uart_init();
812 45a: 0e 94 c0 00 call 0x180 ; 0x180 <uart_init>
813 /* Initialize GPS module (depends on each product) */
814 static
815 void gp_init (void)
816 {
817 const prog_char *s =
818 PSTR("$PSRF106,21*0F\r\n"); // Select datum of WGS84 (for EM-406A)
819 45e: 27 e8 ldi r18, 0x87 ; 135
820 460: 30 e0 ldi r19, 0x00 ; 0
821 462: 06 c0 rjmp .+12 ; 0x470 <main+0xfc>
822  
823 /* Put a character to transmit */
824 static
825 void uart_put (uint8_t d)
826 {
827 while (bit_is_clear(UCSR0A, UDRE0));
828 464: 80 91 c0 00 lds r24, 0x00C0
829 468: 85 ff sbrs r24, 5
830 46a: fc cf rjmp .-8 ; 0x464 <main+0xf0>
831 UDR0 = d;
832 46c: 90 93 c6 00 sts 0x00C6, r25
833 470: f9 01 movw r30, r18
834 {
835 const prog_char *s =
836 PSTR("$PSRF106,21*0F\r\n"); // Select datum of WGS84 (for EM-406A)
837 char c;
838  
839 while ((c = pgm_read_byte(s++)) != 0) uart_put(c);
840 472: 2f 5f subi r18, 0xFF ; 255
841 474: 3f 4f sbci r19, 0xFF ; 255
842 476: 94 91 lpm r25, Z
843 478: 99 23 and r25, r25
844 47a: a1 f7 brne .-24 ; 0x464 <main+0xf0>
845  
846 beep(5, 1); // Single beep. Start to get current time.
847 uart_init();
848 gp_init(); // Initialize GPS module to let output data in NMEA-0183 format.
849 do { // Wait for valid RMC sentence.
850 b = get_line();
851 47c: 0e 94 04 01 call 0x208 ; 0x208 <get_line>
852 if (!b) break;
853 480: 88 23 and r24, r24
854 482: 09 f4 brne .+2 ; 0x486 <main+0x112>
855 484: c1 cf rjmp .-126 ; 0x408 <main+0x94>
856 if (gp_comp(Buff, PSTR("$GPRMC"))) continue;
857 486: 60 e8 ldi r22, 0x80 ; 128
858 488: 70 e0 ldi r23, 0x00 ; 0
859 48a: c7 01 movw r24, r14
860 48c: 0e 94 5b 01 call 0x2b6 ; 0x2b6 <gp_comp>
861 490: 88 23 and r24, r24
862 492: 29 f4 brne .+10 ; 0x49e <main+0x12a>
863 p = gp_col(Buff,2);
864 494: 62 e0 ldi r22, 0x02 ; 2
865 496: c7 01 movw r24, r14
866 498: 0e 94 6a 01 call 0x2d4 ; 0x2d4 <gp_col>
867 49c: 6c 01 movw r12, r24
868 } while (!p || *p != 'A');
869 49e: c1 14 cp r12, r1
870 4a0: d1 04 cpc r13, r1
871 4a2: 61 f3 breq .-40 ; 0x47c <main+0x108>
872 4a4: f6 01 movw r30, r12
873 4a6: 80 81 ld r24, Z
874 4a8: 81 34 cpi r24, 0x41 ; 65
875 4aa: 41 f7 brne .-48 ; 0x47c <main+0x108>
876 if (!b) continue;
877 p = gp_col(Buff,9); // Open log file with the name of current date (YYMMDD.log in UTC).
878 4ac: 69 e0 ldi r22, 0x09 ; 9
879 4ae: c7 01 movw r24, r14
880 4b0: 0e 94 6a 01 call 0x2d4 ; 0x2d4 <gp_col>
881 4b4: 6c 01 movw r12, r24
882  
883 if (!p) {err = 3; break;}
884 4b6: 00 97 sbiw r24, 0x00 ; 0
885 4b8: 11 f4 brne .+4 ; 0x4be <main+0x14a>
886 4ba: 63 e0 ldi r22, 0x03 ; 3
887 4bc: a8 c0 rjmp .+336 ; 0x60e <__stack+0x10f>
888  
889 memcpy(&Buff[0], p+4, 2);
890 4be: fc 01 movw r30, r24
891 4c0: 84 81 ldd r24, Z+4 ; 0x04
892 4c2: 95 81 ldd r25, Z+5 ; 0x05
893 4c4: 90 93 18 01 sts 0x0118, r25
894 4c8: 80 93 17 01 sts 0x0117, r24
895 memcpy(&Buff[2], p+2, 2);
896 4cc: 82 81 ldd r24, Z+2 ; 0x02
897 4ce: 93 81 ldd r25, Z+3 ; 0x03
898 4d0: 90 93 1a 01 sts 0x011A, r25
899 4d4: 80 93 19 01 sts 0x0119, r24
900 memcpy(&Buff[4], p+0, 2);
901 4d8: 80 81 ld r24, Z
902 4da: 91 81 ldd r25, Z+1 ; 0x01
903 4dc: 90 93 1c 01 sts 0x011C, r25
904 4e0: 80 93 1b 01 sts 0x011B, r24
905 strcpy_P(&Buff[6], PSTR(".log"));
906 4e4: 6b e7 ldi r22, 0x7B ; 123
907 4e6: 70 e0 ldi r23, 0x00 ; 0
908 4e8: 8d e1 ldi r24, 0x1D ; 29
909 4ea: 91 e0 ldi r25, 0x01 ; 1
910 4ec: 0e 94 8d 10 call 0x211a ; 0x211a <strcpy_P>
911 if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }
912 4f0: 42 e1 ldi r20, 0x12 ; 18
913 4f2: b7 01 movw r22, r14
914 4f4: c5 01 movw r24, r10
915 4f6: 0e 94 44 09 call 0x1288 ; 0x1288 <f_open>
916 4fa: 89 2b or r24, r25
917 4fc: 09 f0 breq .+2 ; 0x500 <__stack+0x1>
918 4fe: 86 c0 rjmp .+268 ; 0x60c <__stack+0x10d>
919 500: 40 91 15 02 lds r20, 0x0215
920 504: 50 91 16 02 lds r21, 0x0216
921 508: 60 91 17 02 lds r22, 0x0217
922 50c: 70 91 18 02 lds r23, 0x0218
923 510: c5 01 movw r24, r10
924 512: 0e 94 8b 05 call 0xb16 ; 0xb16 <f_lseek>
925 516: 89 2b or r24, r25
926 518: 09 f0 breq .+2 ; 0x51c <__stack+0x1d>
927 51a: 78 c0 rjmp .+240 ; 0x60c <__stack+0x10d>
928  
929 beep(5, 2); // Two beeps. Start logging.
930 51c: 62 e0 ldi r22, 0x02 ; 2
931 51e: 85 e0 ldi r24, 0x05 ; 5
932 520: 0e 94 47 01 call 0x28e ; 0x28e <beep>
933 524: 65 c0 rjmp .+202 ; 0x5f0 <__stack+0xf1>
934 err = 0;
935 while ((b = get_line()) > 0) {
936 if ( !gp_comp(Buff, PSTR("$GPGGA")) // Which sentence is logged?
937 526: 64 e7 ldi r22, 0x74 ; 116
938 528: 70 e0 ldi r23, 0x00 ; 0
939 52a: c7 01 movw r24, r14
940 52c: 0e 94 5b 01 call 0x2b6 ; 0x2b6 <gp_comp>
941 530: 88 23 and r24, r24
942 532: 41 f0 breq .+16 ; 0x544 <__stack+0x45>
943 534: 6d e6 ldi r22, 0x6D ; 109
944 536: 70 e0 ldi r23, 0x00 ; 0
945 538: c7 01 movw r24, r14
946 53a: 0e 94 5b 01 call 0x2b6 ; 0x2b6 <gp_comp>
947 53e: 88 23 and r24, r24
948 540: 09 f0 breq .+2 ; 0x544 <__stack+0x45>
949 542: 44 c0 rjmp .+136 ; 0x5cc <__stack+0xcd>
950 // || !gp_comp(Buff, PSTR("$GPGSV"))
951 // || !gp_comp(Buff, PSTR("$GPZDA"))
952 // || !gp_comp(Buff, PSTR("$GPVTG"))
953 )
954 {
955 if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
956 544: 01 2f mov r16, r17
957 546: 11 27 eor r17, r17
958 548: 92 01 movw r18, r4
959 54a: a8 01 movw r20, r16
960 54c: b7 01 movw r22, r14
961 54e: c5 01 movw r24, r10
962 550: 0e 94 c0 06 call 0xd80 ; 0xd80 <f_write>
963 554: 89 2b or r24, r25
964 556: 09 f0 breq .+2 ; 0x55a <__stack+0x5b>
965 558: 52 c0 rjmp .+164 ; 0x5fe <__stack+0xff>
966 55a: 89 81 ldd r24, Y+1 ; 0x01
967 55c: 9a 81 ldd r25, Y+2 ; 0x02
968 55e: 08 17 cp r16, r24
969 560: 19 07 cpc r17, r25
970 562: 09 f0 breq .+2 ; 0x566 <__stack+0x67>
971 564: 4c c0 rjmp .+152 ; 0x5fe <__stack+0xff>
972 itoa(battery,&Value1,10);
973 566: 4a e0 ldi r20, 0x0A ; 10
974 568: 50 e0 ldi r21, 0x00 ; 0
975 56a: b3 01 movw r22, r6
976 56c: 80 91 6e 01 lds r24, 0x016E
977 570: 90 91 6f 01 lds r25, 0x016F
978 574: 0e 94 b8 10 call 0x2170 ; 0x2170 <itoa>
979 itoa(intensity,&Value2,10);
980 578: 4a e0 ldi r20, 0x0A ; 10
981 57a: 50 e0 ldi r21, 0x00 ; 0
982 57c: b4 01 movw r22, r8
983 57e: 80 91 09 02 lds r24, 0x0209
984 582: 90 91 0a 02 lds r25, 0x020A
985 586: 0e 94 b8 10 call 0x2170 ; 0x2170 <itoa>
986 strcpy(&Buff[0], Value1);
987 58a: b3 01 movw r22, r6
988 58c: c7 01 movw r24, r14
989 58e: 0e 94 b1 10 call 0x2162 ; 0x2162 <strcpy>
990 strcpy_P(&Buff[4], PSTR(","));
991 592: 6b e6 ldi r22, 0x6B ; 107
992 594: 70 e0 ldi r23, 0x00 ; 0
993 596: 8b e1 ldi r24, 0x1B ; 27
994 598: 91 e0 ldi r25, 0x01 ; 1
995 59a: 0e 94 8d 10 call 0x211a ; 0x211a <strcpy_P>
996 strcpy(&Buff[5], Value2);
997 59e: b4 01 movw r22, r8
998 5a0: 8c e1 ldi r24, 0x1C ; 28
999 5a2: 91 e0 ldi r25, 0x01 ; 1
1000 5a4: 0e 94 b1 10 call 0x2162 ; 0x2162 <strcpy>
1001 strcpy_P(&Buff[9], PSTR("\r\n"));
1002 5a8: 68 e6 ldi r22, 0x68 ; 104
1003 5aa: 70 e0 ldi r23, 0x00 ; 0
1004 5ac: c1 01 movw r24, r2
1005 5ae: 0e 94 8d 10 call 0x211a ; 0x211a <strcpy_P>
1006 if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 5; break; };
1007 5b2: 92 01 movw r18, r4
1008 5b4: 4b e0 ldi r20, 0x0B ; 11
1009 5b6: 50 e0 ldi r21, 0x00 ; 0
1010 5b8: b7 01 movw r22, r14
1011 5ba: c5 01 movw r24, r10
1012 5bc: 0e 94 c0 06 call 0xd80 ; 0xd80 <f_write>
1013 5c0: 89 2b or r24, r25
1014 5c2: e9 f4 brne .+58 ; 0x5fe <__stack+0xff>
1015 5c4: 89 81 ldd r24, Y+1 ; 0x01
1016 5c6: 9a 81 ldd r25, Y+2 ; 0x02
1017 5c8: 0b 97 sbiw r24, 0x0b ; 11
1018 5ca: c9 f4 brne .+50 ; 0x5fe <__stack+0xff>
1019 }
1020 if ((Stat & 4) == 0) continue;
1021 5cc: 80 91 69 01 lds r24, 0x0169
1022 5d0: 82 ff sbrs r24, 2
1023 5d2: 0e c0 rjmp .+28 ; 0x5f0 <__stack+0xf1>
1024 if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec.
1025 5d4: c5 01 movw r24, r10
1026 5d6: 0e 94 5d 06 call 0xcba ; 0xcba <f_sync>
1027 5da: 89 2b or r24, r25
1028 5dc: 11 f0 breq .+4 ; 0x5e2 <__stack+0xe3>
1029 5de: 66 e0 ldi r22, 0x06 ; 6
1030 5e0: 16 c0 rjmp .+44 ; 0x60e <__stack+0x10f>
1031 cli(); Stat &= 0xFB; sei(); // Clear sync request
1032 5e2: f8 94 cli
1033 5e4: 80 91 69 01 lds r24, 0x0169
1034 5e8: 8b 7f andi r24, 0xFB ; 251
1035 5ea: 80 93 69 01 sts 0x0169, r24
1036 5ee: 78 94 sei
1037 strcpy_P(&Buff[6], PSTR(".log"));
1038 if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }
1039  
1040 beep(5, 2); // Two beeps. Start logging.
1041 err = 0;
1042 while ((b = get_line()) > 0) {
1043 5f0: 0e 94 04 01 call 0x208 ; 0x208 <get_line>
1044 5f4: 18 2f mov r17, r24
1045 5f6: 88 23 and r24, r24
1046 5f8: 09 f0 breq .+2 ; 0x5fc <__stack+0xfd>
1047 5fa: 95 cf rjmp .-214 ; 0x526 <__stack+0x27>
1048 5fc: 0f c0 rjmp .+30 ; 0x61c <__stack+0x11d>
1049 5fe: 65 e0 ldi r22, 0x05 ; 5
1050 600: 06 c0 rjmp .+12 ; 0x60e <__stack+0x10f>
1051 uart_stop();
1052 GPS_OFF();
1053 if (f_close(&file1)) { err = 7; break; };
1054  
1055 // When a long beep is sounded, the shutdoun process has been succeeded.
1056 beep(50, 1);
1057 602: 61 e0 ldi r22, 0x01 ; 1
1058 604: 82 e3 ldi r24, 0x32 ; 50
1059 606: 0e 94 47 01 call 0x28e ; 0x28e <beep>
1060 60a: fe ce rjmp .-516 ; 0x408 <main+0x94>
1061 60c: 64 e0 ldi r22, 0x04 ; 4
1062  
1063  
1064 static
1065 void uart_stop (void)
1066 {
1067 UCSR0B = 0;
1068 60e: 10 92 c1 00 sts 0x00C1, r1
1069 beep(50, 1);
1070 }
1071  
1072 // Unrecoverble error. Enter shutdown state.
1073 uart_stop();
1074 GPS_OFF();
1075 612: 29 98 cbi 0x05, 1 ; 5
1076 beep(25, err);
1077 614: 89 e1 ldi r24, 0x19 ; 25
1078 616: 0e 94 47 01 call 0x28e ; 0x28e <beep>
1079 61a: ff cf rjmp .-2 ; 0x61a <__stack+0x11b>
1080  
1081  
1082 static
1083 void uart_stop (void)
1084 {
1085 UCSR0B = 0;
1086 61c: 10 92 c1 00 sts 0x00C1, r1
1087 }
1088 if (err) break;
1089  
1090 // Turn-off GPS power and close the log file by power supply is discharged.
1091 uart_stop();
1092 GPS_OFF();
1093 620: 29 98 cbi 0x05, 1 ; 5
1094 if (f_close(&file1)) { err = 7; break; };
1095 622: c5 01 movw r24, r10
1096 624: 0e 94 b4 06 call 0xd68 ; 0xd68 <f_close>
1097 628: 89 2b or r24, r25
1098 62a: 59 f3 breq .-42 ; 0x602 <__stack+0x103>
1099 62c: 67 e0 ldi r22, 0x07 ; 7
1100 62e: ef cf rjmp .-34 ; 0x60e <__stack+0x10f>
1101  
1102 00000630 <clust2sect>:
1103  
1104 static
1105 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
1106 CLUST clust /* Cluster# to be converted */
1107 )
1108 {
1109 630: cf 93 push r28
1110 632: df 93 push r29
1111 FATFS *fs = FatFs;
1112 634: c0 91 0a 01 lds r28, 0x010A
1113 638: d0 91 0b 01 lds r29, 0x010B
1114  
1115  
1116 clust -= 2;
1117 63c: bc 01 movw r22, r24
1118 63e: 62 50 subi r22, 0x02 ; 2
1119 640: 70 40 sbci r23, 0x00 ; 0
1120 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
1121 642: 8e 89 ldd r24, Y+22 ; 0x16
1122 644: 9f 89 ldd r25, Y+23 ; 0x17
1123 646: 02 97 sbiw r24, 0x02 ; 2
1124 648: 68 17 cp r22, r24
1125 64a: 79 07 cpc r23, r25
1126 64c: 28 f0 brcs .+10 ; 0x658 <clust2sect+0x28>
1127 64e: 20 e0 ldi r18, 0x00 ; 0
1128 650: 30 e0 ldi r19, 0x00 ; 0
1129 652: 40 e0 ldi r20, 0x00 ; 0
1130 654: 50 e0 ldi r21, 0x00 ; 0
1131 656: 12 c0 rjmp .+36 ; 0x67c <clust2sect+0x4c>
1132 return (DWORD)clust * fs->sects_clust + fs->database;
1133 658: 88 27 eor r24, r24
1134 65a: 99 27 eor r25, r25
1135 65c: 2d 8d ldd r18, Y+29 ; 0x1d
1136 65e: 33 27 eor r19, r19
1137 660: 44 27 eor r20, r20
1138 662: 55 27 eor r21, r21
1139 664: 0e 94 e9 10 call 0x21d2 ; 0x21d2 <__mulsi3>
1140 668: 9b 01 movw r18, r22
1141 66a: ac 01 movw r20, r24
1142 66c: 88 89 ldd r24, Y+16 ; 0x10
1143 66e: 99 89 ldd r25, Y+17 ; 0x11
1144 670: aa 89 ldd r26, Y+18 ; 0x12
1145 672: bb 89 ldd r27, Y+19 ; 0x13
1146 674: 28 0f add r18, r24
1147 676: 39 1f adc r19, r25
1148 678: 4a 1f adc r20, r26
1149 67a: 5b 1f adc r21, r27
1150 }
1151 67c: ca 01 movw r24, r20
1152 67e: b9 01 movw r22, r18
1153 680: df 91 pop r29
1154 682: cf 91 pop r28
1155 684: 08 95 ret
1156  
1157 00000686 <validate>:
1158 static
1159 FRESULT validate ( /* FR_OK(0): The id is valid, !=0: Not valid */
1160 const FATFS *fs, /* Pointer to the file system object */
1161 WORD id /* id member of the target object to be checked */
1162 )
1163 {
1164 686: fc 01 movw r30, r24
1165 if (!fs || fs->id != id)
1166 688: 89 2b or r24, r25
1167 68a: 61 f0 breq .+24 ; 0x6a4 <validate+0x1e>
1168 68c: 80 81 ld r24, Z
1169 68e: 91 81 ldd r25, Z+1 ; 0x01
1170 690: 86 17 cp r24, r22
1171 692: 97 07 cpc r25, r23
1172 694: 39 f4 brne .+14 ; 0x6a4 <validate+0x1e>
1173 return FR_INVALID_OBJECT;
1174 if (disk_status(0) & STA_NOINIT)
1175 696: 80 e0 ldi r24, 0x00 ; 0
1176 698: 0e 94 bf 0d call 0x1b7e ; 0x1b7e <disk_status>
1177 69c: 99 27 eor r25, r25
1178 69e: 81 70 andi r24, 0x01 ; 1
1179 6a0: 90 70 andi r25, 0x00 ; 0
1180 6a2: 08 95 ret
1181 6a4: 8c e0 ldi r24, 0x0C ; 12
1182 6a6: 90 e0 ldi r25, 0x00 ; 0
1183 return FR_NOT_READY;
1184  
1185 return FR_OK;
1186 }
1187 6a8: 08 95 ret
1188  
1189 000006aa <move_window>:
1190  
1191 static
1192 BOOL move_window ( /* TRUE: successful, FALSE: failed */
1193 DWORD sector /* Sector number to make apperance in the FatFs->win */
1194 ) /* Move to zero only writes back dirty window */
1195 {
1196 6aa: a0 e0 ldi r26, 0x00 ; 0
1197 6ac: b0 e0 ldi r27, 0x00 ; 0
1198 6ae: eb e5 ldi r30, 0x5B ; 91
1199 6b0: f3 e0 ldi r31, 0x03 ; 3
1200 6b2: 0c 94 2e 11 jmp 0x225c ; 0x225c <__prologue_saves__+0x8>
1201 6b6: 4b 01 movw r8, r22
1202 6b8: 5c 01 movw r10, r24
1203 DWORD wsect;
1204 FATFS *fs = FatFs;
1205 6ba: c0 91 0a 01 lds r28, 0x010A
1206 6be: d0 91 0b 01 lds r29, 0x010B
1207  
1208  
1209 wsect = fs->winsect;
1210 6c2: cc 80 ldd r12, Y+4 ; 0x04
1211 6c4: dd 80 ldd r13, Y+5 ; 0x05
1212 6c6: ee 80 ldd r14, Y+6 ; 0x06
1213 6c8: ff 80 ldd r15, Y+7 ; 0x07
1214 if (wsect != sector) { /* Changed current window */
1215 6ca: c6 16 cp r12, r22
1216 6cc: d7 06 cpc r13, r23
1217 6ce: e8 06 cpc r14, r24
1218 6d0: f9 06 cpc r15, r25
1219 6d2: 09 f4 brne .+2 ; 0x6d6 <move_window+0x2c>
1220 6d4: 4f c0 rjmp .+158 ; 0x774 <move_window+0xca>
1221 #if !_FS_READONLY
1222 BYTE n;
1223 if (fs->winflag) { /* Write back dirty window if needed */
1224 6d6: 8f 8d ldd r24, Y+31 ; 0x1f
1225 6d8: 88 23 and r24, r24
1226 6da: a1 f1 breq .+104 ; 0x744 <move_window+0x9a>
1227 if (disk_write(0, fs->win, wsect, 1) != RES_OK)
1228 6dc: 80 e2 ldi r24, 0x20 ; 32
1229 6de: 68 2e mov r6, r24
1230 6e0: 71 2c mov r7, r1
1231 6e2: 6c 0e add r6, r28
1232 6e4: 7d 1e adc r7, r29
1233 6e6: 01 e0 ldi r16, 0x01 ; 1
1234 6e8: a7 01 movw r20, r14
1235 6ea: 96 01 movw r18, r12
1236 6ec: b3 01 movw r22, r6
1237 6ee: 80 e0 ldi r24, 0x00 ; 0
1238 6f0: 0e 94 d3 0e call 0x1da6 ; 0x1da6 <disk_write>
1239 6f4: 89 2b or r24, r25
1240 6f6: d9 f5 brne .+118 ; 0x76e <move_window+0xc4>
1241 return FALSE;
1242 fs->winflag = 0;
1243 6f8: 1f 8e std Y+31, r1 ; 0x1f
1244 if (wsect < (fs->fatbase + fs->sects_fat)) { /* In FAT area */
1245 6fa: 8c 89 ldd r24, Y+20 ; 0x14
1246 6fc: 9d 89 ldd r25, Y+21 ; 0x15
1247 6fe: aa 27 eor r26, r26
1248 700: bb 27 eor r27, r27
1249 702: 28 85 ldd r18, Y+8 ; 0x08
1250 704: 39 85 ldd r19, Y+9 ; 0x09
1251 706: 4a 85 ldd r20, Y+10 ; 0x0a
1252 708: 5b 85 ldd r21, Y+11 ; 0x0b
1253 70a: 82 0f add r24, r18
1254 70c: 93 1f adc r25, r19
1255 70e: a4 1f adc r26, r20
1256 710: b5 1f adc r27, r21
1257 712: c8 16 cp r12, r24
1258 714: d9 06 cpc r13, r25
1259 716: ea 06 cpc r14, r26
1260 718: fb 06 cpc r15, r27
1261 71a: a0 f4 brcc .+40 ; 0x744 <move_window+0x9a>
1262 for (n = fs->n_fats; n >= 2; n--) { /* Refrect the change to all FAT copies */
1263 71c: 1e 8d ldd r17, Y+30 ; 0x1e
1264 71e: 10 c0 rjmp .+32 ; 0x740 <move_window+0x96>
1265 wsect += fs->sects_fat;
1266 720: 8c 89 ldd r24, Y+20 ; 0x14
1267 722: 9d 89 ldd r25, Y+21 ; 0x15
1268 724: aa 27 eor r26, r26
1269 726: bb 27 eor r27, r27
1270 728: c8 0e add r12, r24
1271 72a: d9 1e adc r13, r25
1272 72c: ea 1e adc r14, r26
1273 72e: fb 1e adc r15, r27
1274 disk_write(0, fs->win, wsect, 1);
1275 730: 01 e0 ldi r16, 0x01 ; 1
1276 732: a7 01 movw r20, r14
1277 734: 96 01 movw r18, r12
1278 736: b3 01 movw r22, r6
1279 738: 80 e0 ldi r24, 0x00 ; 0
1280 73a: 0e 94 d3 0e call 0x1da6 ; 0x1da6 <disk_write>
1281 if (fs->winflag) { /* Write back dirty window if needed */
1282 if (disk_write(0, fs->win, wsect, 1) != RES_OK)
1283 return FALSE;
1284 fs->winflag = 0;
1285 if (wsect < (fs->fatbase + fs->sects_fat)) { /* In FAT area */
1286 for (n = fs->n_fats; n >= 2; n--) { /* Refrect the change to all FAT copies */
1287 73e: 11 50 subi r17, 0x01 ; 1
1288 740: 12 30 cpi r17, 0x02 ; 2
1289 742: 70 f7 brcc .-36 ; 0x720 <move_window+0x76>
1290 disk_write(0, fs->win, wsect, 1);
1291 }
1292 }
1293 }
1294 #endif
1295 if (sector) {
1296 744: 81 14 cp r8, r1
1297 746: 91 04 cpc r9, r1
1298 748: a1 04 cpc r10, r1
1299 74a: b1 04 cpc r11, r1
1300 74c: 99 f0 breq .+38 ; 0x774 <move_window+0xca>
1301 if (disk_read(0, fs->win, sector, 1) != RES_OK)
1302 74e: be 01 movw r22, r28
1303 750: 60 5e subi r22, 0xE0 ; 224
1304 752: 7f 4f sbci r23, 0xFF ; 255
1305 754: 01 e0 ldi r16, 0x01 ; 1
1306 756: a5 01 movw r20, r10
1307 758: 94 01 movw r18, r8
1308 75a: 80 e0 ldi r24, 0x00 ; 0
1309 75c: 0e 94 51 0f call 0x1ea2 ; 0x1ea2 <disk_read>
1310 760: 89 2b or r24, r25
1311 762: 29 f4 brne .+10 ; 0x76e <move_window+0xc4>
1312 return FALSE;
1313 fs->winsect = sector;
1314 764: 8c 82 std Y+4, r8 ; 0x04
1315 766: 9d 82 std Y+5, r9 ; 0x05
1316 768: ae 82 std Y+6, r10 ; 0x06
1317 76a: bf 82 std Y+7, r11 ; 0x07
1318 76c: 03 c0 rjmp .+6 ; 0x774 <move_window+0xca>
1319 76e: 80 e0 ldi r24, 0x00 ; 0
1320 770: 90 e0 ldi r25, 0x00 ; 0
1321 772: 02 c0 rjmp .+4 ; 0x778 <move_window+0xce>
1322 774: 81 e0 ldi r24, 0x01 ; 1
1323 776: 90 e0 ldi r25, 0x00 ; 0
1324 778: ee e0 ldi r30, 0x0E ; 14
1325 77a: cd b7 in r28, 0x3d ; 61
1326 77c: de b7 in r29, 0x3e ; 62
1327 77e: 0c 94 4a 11 jmp 0x2294 ; 0x2294 <__epilogue_restores__+0x8>
1328  
1329 00000782 <put_cluster>:
1330 static
1331 BOOL put_cluster ( /* TRUE: successful, FALSE: failed */
1332 CLUST clust, /* Cluster# to change */
1333 CLUST val /* New value to mark the cluster */
1334 )
1335 {
1336 782: a0 e0 ldi r26, 0x00 ; 0
1337 784: b0 e0 ldi r27, 0x00 ; 0
1338 786: e7 ec ldi r30, 0xC7 ; 199
1339 788: f3 e0 ldi r31, 0x03 ; 3
1340 78a: 0c 94 2d 11 jmp 0x225a ; 0x225a <__prologue_saves__+0x6>
1341 78e: ec 01 movw r28, r24
1342 790: 5b 01 movw r10, r22
1343 WORD bc;
1344 BYTE *p;
1345 DWORD fatsect;
1346 FATFS *fs = FatFs;
1347 792: 80 90 0a 01 lds r8, 0x010A
1348 796: 90 90 0b 01 lds r9, 0x010B
1349  
1350  
1351 fatsect = fs->fatbase;
1352 79a: f4 01 movw r30, r8
1353 79c: c0 84 ldd r12, Z+8 ; 0x08
1354 79e: d1 84 ldd r13, Z+9 ; 0x09
1355 7a0: e2 84 ldd r14, Z+10 ; 0x0a
1356 7a2: f3 84 ldd r15, Z+11 ; 0x0b
1357 switch (fs->fs_type) {
1358 7a4: 84 8d ldd r24, Z+28 ; 0x1c
1359 7a6: 81 30 cpi r24, 0x01 ; 1
1360 7a8: 21 f0 breq .+8 ; 0x7b2 <put_cluster+0x30>
1361 7aa: 82 30 cpi r24, 0x02 ; 2
1362 7ac: 09 f0 breq .+2 ; 0x7b0 <put_cluster+0x2e>
1363 7ae: 70 c0 rjmp .+224 ; 0x890 <put_cluster+0x10e>
1364 7b0: 56 c0 rjmp .+172 ; 0x85e <put_cluster+0xdc>
1365 case FS_FAT12 :
1366 bc = (WORD)clust * 3 / 2;
1367 7b2: 8e 01 movw r16, r28
1368 7b4: 00 0f add r16, r16
1369 7b6: 11 1f adc r17, r17
1370 7b8: 0c 0f add r16, r28
1371 7ba: 1d 1f adc r17, r29
1372 7bc: 16 95 lsr r17
1373 7be: 07 95 ror r16
1374 if (!move_window(fatsect + bc / 512)) return FALSE;
1375 7c0: b8 01 movw r22, r16
1376 7c2: 67 2f mov r22, r23
1377 7c4: 77 27 eor r23, r23
1378 7c6: 66 95 lsr r22
1379 7c8: 88 27 eor r24, r24
1380 7ca: 99 27 eor r25, r25
1381 7cc: 6c 0d add r22, r12
1382 7ce: 7d 1d adc r23, r13
1383 7d0: 8e 1d adc r24, r14
1384 7d2: 9f 1d adc r25, r15
1385 7d4: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
1386 7d8: 88 23 and r24, r24
1387 7da: 09 f4 brne .+2 ; 0x7de <put_cluster+0x5c>
1388 7dc: 59 c0 rjmp .+178 ; 0x890 <put_cluster+0x10e>
1389 p = &fs->win[bc % 512];
1390 7de: 60 e2 ldi r22, 0x20 ; 32
1391 7e0: 66 2e mov r6, r22
1392 7e2: 71 2c mov r7, r1
1393 7e4: 68 0c add r6, r8
1394 7e6: 79 1c adc r7, r9
1395 7e8: f8 01 movw r30, r16
1396 7ea: f1 70 andi r31, 0x01 ; 1
1397 7ec: e6 0d add r30, r6
1398 7ee: f7 1d adc r31, r7
1399 *p = (clust & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val;
1400 7f0: ce 01 movw r24, r28
1401 7f2: 81 70 andi r24, 0x01 ; 1
1402 7f4: 90 70 andi r25, 0x00 ; 0
1403 7f6: 58 2e mov r5, r24
1404 7f8: 88 23 and r24, r24
1405 7fa: 39 f0 breq .+14 ; 0x80a <put_cluster+0x88>
1406 7fc: 80 81 ld r24, Z
1407 7fe: 8f 70 andi r24, 0x0F ; 15
1408 800: 9a 2d mov r25, r10
1409 802: 92 95 swap r25
1410 804: 90 7f andi r25, 0xF0 ; 240
1411 806: 98 2b or r25, r24
1412 808: 01 c0 rjmp .+2 ; 0x80c <put_cluster+0x8a>
1413 80a: 9a 2d mov r25, r10
1414 80c: 90 83 st Z, r25
1415 bc++;
1416 80e: e8 01 movw r28, r16
1417 810: 21 96 adiw r28, 0x01 ; 1
1418 fs->winflag = 1;
1419 812: 81 e0 ldi r24, 0x01 ; 1
1420 814: f4 01 movw r30, r8
1421 816: 87 8f std Z+31, r24 ; 0x1f
1422 if (!move_window(fatsect + bc / 512)) return FALSE;
1423 818: be 01 movw r22, r28
1424 81a: 67 2f mov r22, r23
1425 81c: 77 27 eor r23, r23
1426 81e: 66 95 lsr r22
1427 820: 88 27 eor r24, r24
1428 822: 99 27 eor r25, r25
1429 824: 6c 0d add r22, r12
1430 826: 7d 1d adc r23, r13
1431 828: 8e 1d adc r24, r14
1432 82a: 9f 1d adc r25, r15
1433 82c: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
1434 830: 88 23 and r24, r24
1435 832: 71 f1 breq .+92 ; 0x890 <put_cluster+0x10e>
1436 p = &fs->win[bc % 512];
1437 834: fe 01 movw r30, r28
1438 836: f1 70 andi r31, 0x01 ; 1
1439 838: e6 0d add r30, r6
1440 83a: f7 1d adc r31, r7
1441 *p = (clust & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F));
1442 83c: 55 20 and r5, r5
1443 83e: 39 f0 breq .+14 ; 0x84e <put_cluster+0xcc>
1444 840: 44 e0 ldi r20, 0x04 ; 4
1445 842: b6 94 lsr r11
1446 844: a7 94 ror r10
1447 846: 4a 95 dec r20
1448 848: e1 f7 brne .-8 ; 0x842 <put_cluster+0xc0>
1449 84a: 2a 2d mov r18, r10
1450 84c: 06 c0 rjmp .+12 ; 0x85a <put_cluster+0xd8>
1451 84e: 20 81 ld r18, Z
1452 850: 20 7f andi r18, 0xF0 ; 240
1453 852: 8b 2d mov r24, r11
1454 854: 99 27 eor r25, r25
1455 856: 8f 70 andi r24, 0x0F ; 15
1456 858: 28 2b or r18, r24
1457 85a: 20 83 st Z, r18
1458 85c: 13 c0 rjmp .+38 ; 0x884 <put_cluster+0x102>
1459 break;
1460  
1461 case FS_FAT16 :
1462 if (!move_window(fatsect + clust / 256)) return FALSE;
1463 85e: 6d 2f mov r22, r29
1464 860: 77 27 eor r23, r23
1465 862: 88 27 eor r24, r24
1466 864: 99 27 eor r25, r25
1467 866: 6c 0d add r22, r12
1468 868: 7d 1d adc r23, r13
1469 86a: 8e 1d adc r24, r14
1470 86c: 9f 1d adc r25, r15
1471 86e: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
1472 872: 88 23 and r24, r24
1473 874: 69 f0 breq .+26 ; 0x890 <put_cluster+0x10e>
1474 ST_WORD(&fs->win[((WORD)clust * 2) % 512], (WORD)val);
1475 876: cc 0f add r28, r28
1476 878: dd 1f adc r29, r29
1477 87a: d1 70 andi r29, 0x01 ; 1
1478 87c: c8 0d add r28, r8
1479 87e: d9 1d adc r29, r9
1480 880: b9 a2 std Y+33, r11 ; 0x21
1481 882: a8 a2 std Y+32, r10 ; 0x20
1482 break;
1483 #endif
1484 default :
1485 return FALSE;
1486 }
1487 fs->winflag = 1;
1488 884: 81 e0 ldi r24, 0x01 ; 1
1489 886: f4 01 movw r30, r8
1490 888: 87 8f std Z+31, r24 ; 0x1f
1491 88a: 81 e0 ldi r24, 0x01 ; 1
1492 88c: 90 e0 ldi r25, 0x00 ; 0
1493 88e: 02 c0 rjmp .+4 ; 0x894 <put_cluster+0x112>
1494 return TRUE;
1495 890: 80 e0 ldi r24, 0x00 ; 0
1496 892: 90 e0 ldi r25, 0x00 ; 0
1497 894: ef e0 ldi r30, 0x0F ; 15
1498 896: cd b7 in r28, 0x3d ; 61
1499 898: de b7 in r29, 0x3e ; 62
1500 89a: 0c 94 49 11 jmp 0x2292 ; 0x2292 <__epilogue_restores__+0x6>
1501  
1502 0000089e <get_cluster>:
1503  
1504 static
1505 CLUST get_cluster ( /* 0,>=2: successful, 1: failed */
1506 CLUST clust /* Cluster# to get the link information */
1507 )
1508 {
1509 89e: a0 e0 ldi r26, 0x00 ; 0
1510 8a0: b0 e0 ldi r27, 0x00 ; 0
1511 8a2: e5 e5 ldi r30, 0x55 ; 85
1512 8a4: f4 e0 ldi r31, 0x04 ; 4
1513 8a6: 0c 94 31 11 jmp 0x2262 ; 0x2262 <__prologue_saves__+0xe>
1514 8aa: 8c 01 movw r16, r24
1515 WORD wc, bc;
1516 DWORD fatsect;
1517 FATFS *fs = FatFs;
1518 8ac: e0 90 0a 01 lds r14, 0x010A
1519 8b0: f0 90 0b 01 lds r15, 0x010B
1520  
1521  
1522 if (clust >= 2 && clust < fs->max_clust) { /* Valid cluster# */
1523 8b4: 02 97 sbiw r24, 0x02 ; 2
1524 8b6: 08 f4 brcc .+2 ; 0x8ba <get_cluster+0x1c>
1525 8b8: 67 c0 rjmp .+206 ; 0x988 <get_cluster+0xea>
1526 8ba: f7 01 movw r30, r14
1527 8bc: 86 89 ldd r24, Z+22 ; 0x16
1528 8be: 97 89 ldd r25, Z+23 ; 0x17
1529 8c0: 08 17 cp r16, r24
1530 8c2: 19 07 cpc r17, r25
1531 8c4: 08 f0 brcs .+2 ; 0x8c8 <get_cluster+0x2a>
1532 8c6: 60 c0 rjmp .+192 ; 0x988 <get_cluster+0xea>
1533 fatsect = fs->fatbase;
1534 8c8: a0 84 ldd r10, Z+8 ; 0x08
1535 8ca: b1 84 ldd r11, Z+9 ; 0x09
1536 8cc: c2 84 ldd r12, Z+10 ; 0x0a
1537 8ce: d3 84 ldd r13, Z+11 ; 0x0b
1538 switch (fs->fs_type) {
1539 8d0: 84 8d ldd r24, Z+28 ; 0x1c
1540 8d2: 81 30 cpi r24, 0x01 ; 1
1541 8d4: 21 f0 breq .+8 ; 0x8de <get_cluster+0x40>
1542 8d6: 82 30 cpi r24, 0x02 ; 2
1543 8d8: 09 f0 breq .+2 ; 0x8dc <get_cluster+0x3e>
1544 8da: 56 c0 rjmp .+172 ; 0x988 <get_cluster+0xea>
1545 8dc: 40 c0 rjmp .+128 ; 0x95e <get_cluster+0xc0>
1546 case FS_FAT12 :
1547 bc = (WORD)clust * 3 / 2;
1548 8de: e8 01 movw r28, r16
1549 8e0: cc 0f add r28, r28
1550 8e2: dd 1f adc r29, r29
1551 8e4: c0 0f add r28, r16
1552 8e6: d1 1f adc r29, r17
1553 8e8: d6 95 lsr r29
1554 8ea: c7 95 ror r28
1555 if (!move_window(fatsect + bc / 512)) break;
1556 8ec: be 01 movw r22, r28
1557 8ee: 67 2f mov r22, r23
1558 8f0: 77 27 eor r23, r23
1559 8f2: 66 95 lsr r22
1560 8f4: 88 27 eor r24, r24
1561 8f6: 99 27 eor r25, r25
1562 8f8: 6a 0d add r22, r10
1563 8fa: 7b 1d adc r23, r11
1564 8fc: 8c 1d adc r24, r12
1565 8fe: 9d 1d adc r25, r13
1566 900: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
1567 904: 88 23 and r24, r24
1568 906: 09 f4 brne .+2 ; 0x90a <get_cluster+0x6c>
1569 908: 3f c0 rjmp .+126 ; 0x988 <get_cluster+0xea>
1570 wc = fs->win[bc % 512]; bc++;
1571 90a: fe 01 movw r30, r28
1572 90c: f1 70 andi r31, 0x01 ; 1
1573 90e: ee 0d add r30, r14
1574 910: ff 1d adc r31, r15
1575 912: 90 a0 ldd r9, Z+32 ; 0x20
1576 914: 21 96 adiw r28, 0x01 ; 1
1577 if (!move_window(fatsect + bc / 512)) break;
1578 916: be 01 movw r22, r28
1579 918: 67 2f mov r22, r23
1580 91a: 77 27 eor r23, r23
1581 91c: 66 95 lsr r22
1582 91e: 88 27 eor r24, r24
1583 920: 99 27 eor r25, r25
1584 922: 6a 0d add r22, r10
1585 924: 7b 1d adc r23, r11
1586 926: 8c 1d adc r24, r12
1587 928: 9d 1d adc r25, r13
1588 92a: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
1589 92e: 88 23 and r24, r24
1590 930: 59 f1 breq .+86 ; 0x988 <get_cluster+0xea>
1591 fatsect = fs->fatbase;
1592 switch (fs->fs_type) {
1593 case FS_FAT12 :
1594 bc = (WORD)clust * 3 / 2;
1595 if (!move_window(fatsect + bc / 512)) break;
1596 wc = fs->win[bc % 512]; bc++;
1597 932: 29 2d mov r18, r9
1598 934: 33 27 eor r19, r19
1599 if (!move_window(fatsect + bc / 512)) break;
1600 wc |= (WORD)fs->win[bc % 512] << 8;
1601 936: d1 70 andi r29, 0x01 ; 1
1602 938: ec 0e add r14, r28
1603 93a: fd 1e adc r15, r29
1604 93c: f7 01 movw r30, r14
1605 93e: 80 a1 ldd r24, Z+32 ; 0x20
1606 940: 99 27 eor r25, r25
1607 942: 98 2f mov r25, r24
1608 944: 88 27 eor r24, r24
1609 946: 82 2b or r24, r18
1610 948: 93 2b or r25, r19
1611 return (clust & 1) ? (wc >> 4) : (wc & 0xFFF);
1612 94a: 00 ff sbrs r16, 0
1613 94c: 06 c0 rjmp .+12 ; 0x95a <get_cluster+0xbc>
1614 94e: 24 e0 ldi r18, 0x04 ; 4
1615 950: 96 95 lsr r25
1616 952: 87 95 ror r24
1617 954: 2a 95 dec r18
1618 956: e1 f7 brne .-8 ; 0x950 <get_cluster+0xb2>
1619 958: 19 c0 rjmp .+50 ; 0x98c <get_cluster+0xee>
1620 95a: 9f 70 andi r25, 0x0F ; 15
1621 95c: 17 c0 rjmp .+46 ; 0x98c <get_cluster+0xee>
1622  
1623 case FS_FAT16 :
1624 if (!move_window(fatsect + clust / 256)) break;
1625 95e: 61 2f mov r22, r17
1626 960: 77 27 eor r23, r23
1627 962: 88 27 eor r24, r24
1628 964: 99 27 eor r25, r25
1629 966: 6a 0d add r22, r10
1630 968: 7b 1d adc r23, r11
1631 96a: 8c 1d adc r24, r12
1632 96c: 9d 1d adc r25, r13
1633 96e: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
1634 972: 88 23 and r24, r24
1635 974: 49 f0 breq .+18 ; 0x988 <get_cluster+0xea>
1636 return LD_WORD(&fs->win[((WORD)clust * 2) % 512]);
1637 976: 00 0f add r16, r16
1638 978: 11 1f adc r17, r17
1639 97a: 11 70 andi r17, 0x01 ; 1
1640 97c: e0 0e add r14, r16
1641 97e: f1 1e adc r15, r17
1642 980: f7 01 movw r30, r14
1643 982: 80 a1 ldd r24, Z+32 ; 0x20
1644 984: 91 a1 ldd r25, Z+33 ; 0x21
1645 986: 02 c0 rjmp .+4 ; 0x98c <get_cluster+0xee>
1646 988: 81 e0 ldi r24, 0x01 ; 1
1647 98a: 90 e0 ldi r25, 0x00 ; 0
1648 98c: eb e0 ldi r30, 0x0B ; 11
1649 98e: cd b7 in r28, 0x3d ; 61
1650 990: de b7 in r29, 0x3e ; 62
1651 992: 0c 94 4d 11 jmp 0x229a ; 0x229a <__epilogue_restores__+0xe>
1652  
1653 00000996 <next_dir_entry>:
1654  
1655 static
1656 BOOL next_dir_entry ( /* TRUE: successful, FALSE: could not move next */
1657 DIR *dirobj /* Pointer to directory object */
1658 )
1659 {
1660 996: ef 92 push r14
1661 998: ff 92 push r15
1662 99a: 0f 93 push r16
1663 99c: 1f 93 push r17
1664 99e: cf 93 push r28
1665 9a0: df 93 push r29
1666 9a2: ec 01 movw r28, r24
1667 CLUST clust;
1668 WORD idx;
1669 FATFS *fs = FatFs;
1670 9a4: e0 90 0a 01 lds r14, 0x010A
1671 9a8: f0 90 0b 01 lds r15, 0x010B
1672  
1673  
1674 idx = dirobj->index + 1;
1675 9ac: 0a 81 ldd r16, Y+2 ; 0x02
1676 9ae: 1b 81 ldd r17, Y+3 ; 0x03
1677 9b0: 0f 5f subi r16, 0xFF ; 255
1678 9b2: 1f 4f sbci r17, 0xFF ; 255
1679 if ((idx & 15) == 0) { /* Table sector changed? */
1680 9b4: c8 01 movw r24, r16
1681 9b6: 8f 70 andi r24, 0x0F ; 15
1682 9b8: 90 70 andi r25, 0x00 ; 0
1683 9ba: 89 2b or r24, r25
1684 9bc: d1 f5 brne .+116 ; 0xa32 <next_dir_entry+0x9c>
1685 dirobj->sect++; /* Next sector */
1686 9be: 8a 85 ldd r24, Y+10 ; 0x0a
1687 9c0: 9b 85 ldd r25, Y+11 ; 0x0b
1688 9c2: ac 85 ldd r26, Y+12 ; 0x0c
1689 9c4: bd 85 ldd r27, Y+13 ; 0x0d
1690 9c6: 01 96 adiw r24, 0x01 ; 1
1691 9c8: a1 1d adc r26, r1
1692 9ca: b1 1d adc r27, r1
1693 9cc: 8a 87 std Y+10, r24 ; 0x0a
1694 9ce: 9b 87 std Y+11, r25 ; 0x0b
1695 9d0: ac 87 std Y+12, r26 ; 0x0c
1696 9d2: bd 87 std Y+13, r27 ; 0x0d
1697 if (!dirobj->clust) { /* In static table */
1698 9d4: 48 85 ldd r20, Y+8 ; 0x08
1699 9d6: 59 85 ldd r21, Y+9 ; 0x09
1700 9d8: 41 15 cp r20, r1
1701 9da: 51 05 cpc r21, r1
1702 9dc: 39 f4 brne .+14 ; 0x9ec <next_dir_entry+0x56>
1703 if (idx >= fs->n_rootdir) return FALSE; /* Reached to end of table */
1704 9de: f7 01 movw r30, r14
1705 9e0: 82 81 ldd r24, Z+2 ; 0x02
1706 9e2: 93 81 ldd r25, Z+3 ; 0x03
1707 9e4: 08 17 cp r16, r24
1708 9e6: 19 07 cpc r17, r25
1709 9e8: 20 f1 brcs .+72 ; 0xa32 <next_dir_entry+0x9c>
1710 9ea: 28 c0 rjmp .+80 ; 0xa3c <next_dir_entry+0xa6>
1711 } else { /* In dynamic table */
1712 if (((idx / 16) & (fs->sects_clust - 1)) == 0) { /* Cluster changed? */
1713 9ec: f7 01 movw r30, r14
1714 9ee: 85 8d ldd r24, Z+29 ; 0x1d
1715 9f0: 99 27 eor r25, r25
1716 9f2: 01 97 sbiw r24, 0x01 ; 1
1717 9f4: 98 01 movw r18, r16
1718 9f6: b4 e0 ldi r27, 0x04 ; 4
1719 9f8: 36 95 lsr r19
1720 9fa: 27 95 ror r18
1721 9fc: ba 95 dec r27
1722 9fe: e1 f7 brne .-8 ; 0x9f8 <next_dir_entry+0x62>
1723 a00: 82 23 and r24, r18
1724 a02: 93 23 and r25, r19
1725 a04: 89 2b or r24, r25
1726 a06: a9 f4 brne .+42 ; 0xa32 <next_dir_entry+0x9c>
1727 clust = get_cluster(dirobj->clust); /* Get next cluster */
1728 a08: ca 01 movw r24, r20
1729 a0a: 0e 94 4f 04 call 0x89e ; 0x89e <get_cluster>
1730 a0e: 9c 01 movw r18, r24
1731 if (clust < 2 || clust >= fs->max_clust) /* Reached to end of table */
1732 a10: 02 97 sbiw r24, 0x02 ; 2
1733 a12: a0 f0 brcs .+40 ; 0xa3c <next_dir_entry+0xa6>
1734 a14: f7 01 movw r30, r14
1735 a16: 86 89 ldd r24, Z+22 ; 0x16
1736 a18: 97 89 ldd r25, Z+23 ; 0x17
1737 a1a: 28 17 cp r18, r24
1738 a1c: 39 07 cpc r19, r25
1739 a1e: 70 f4 brcc .+28 ; 0xa3c <next_dir_entry+0xa6>
1740 return FALSE;
1741 dirobj->clust = clust; /* Initialize for new cluster */
1742 a20: 39 87 std Y+9, r19 ; 0x09
1743 a22: 28 87 std Y+8, r18 ; 0x08
1744 dirobj->sect = clust2sect(clust);
1745 a24: c9 01 movw r24, r18
1746 a26: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
1747 a2a: 6a 87 std Y+10, r22 ; 0x0a
1748 a2c: 7b 87 std Y+11, r23 ; 0x0b
1749 a2e: 8c 87 std Y+12, r24 ; 0x0c
1750 a30: 9d 87 std Y+13, r25 ; 0x0d
1751 }
1752 }
1753 }
1754 dirobj->index = idx; /* Lower 4 bit of dirobj->index indicates offset in dirobj->sect */
1755 a32: 1b 83 std Y+3, r17 ; 0x03
1756 a34: 0a 83 std Y+2, r16 ; 0x02
1757 a36: 81 e0 ldi r24, 0x01 ; 1
1758 a38: 90 e0 ldi r25, 0x00 ; 0
1759 a3a: 02 c0 rjmp .+4 ; 0xa40 <next_dir_entry+0xaa>
1760 return TRUE;
1761 a3c: 80 e0 ldi r24, 0x00 ; 0
1762 a3e: 90 e0 ldi r25, 0x00 ; 0
1763 a40: e6 e0 ldi r30, 0x06 ; 6
1764 a42: cd b7 in r28, 0x3d ; 61
1765 a44: de b7 in r29, 0x3e ; 62
1766 a46: 0c 94 52 11 jmp 0x22a4 ; 0x22a4 <__epilogue_restores__+0x18>
1767  
1768 00000a4a <create_chain>:
1769 #if !_FS_READONLY
1770 static
1771 CLUST create_chain ( /* 0: no free cluster, 1: error, >=2: new cluster number */
1772 CLUST clust /* Cluster# to stretch, 0 means create new */
1773 )
1774 {
1775 a4a: a0 e0 ldi r26, 0x00 ; 0
1776 a4c: b0 e0 ldi r27, 0x00 ; 0
1777 a4e: eb e2 ldi r30, 0x2B ; 43
1778 a50: f5 e0 ldi r31, 0x05 ; 5
1779 a52: 0c 94 32 11 jmp 0x2264 ; 0x2264 <__prologue_saves__+0x10>
1780 a56: 7c 01 movw r14, r24
1781 CLUST cstat, ncl, scl, mcl;
1782 FATFS *fs = FatFs;
1783 a58: a0 90 0a 01 lds r10, 0x010A
1784 a5c: b0 90 0b 01 lds r11, 0x010B
1785  
1786  
1787 mcl = fs->max_clust;
1788 a60: f5 01 movw r30, r10
1789 a62: c6 88 ldd r12, Z+22 ; 0x16
1790 a64: d7 88 ldd r13, Z+23 ; 0x17
1791 if (clust == 0) { /* Create new chain */
1792 a66: 00 97 sbiw r24, 0x00 ; 0
1793 a68: 49 f4 brne .+18 ; 0xa7c <create_chain+0x32>
1794 scl = fs->last_clust; /* Get last allocated cluster */
1795 a6a: 00 8d ldd r16, Z+24 ; 0x18
1796 a6c: 11 8d ldd r17, Z+25 ; 0x19
1797 if (scl < 2 || scl >= mcl) scl = 1;
1798 a6e: 02 30 cpi r16, 0x02 ; 2
1799 a70: 11 05 cpc r17, r1
1800 a72: 80 f0 brcs .+32 ; 0xa94 <create_chain+0x4a>
1801 a74: 0c 15 cp r16, r12
1802 a76: 1d 05 cpc r17, r13
1803 a78: 68 f4 brcc .+26 ; 0xa94 <create_chain+0x4a>
1804 a7a: 0e c0 rjmp .+28 ; 0xa98 <create_chain+0x4e>
1805 }
1806 else { /* Stretch existing chain */
1807 cstat = get_cluster(clust); /* Check the cluster status */
1808 a7c: 0e 94 4f 04 call 0x89e ; 0x89e <get_cluster>
1809 if (cstat < 2) return 1; /* It is an invalid cluster */
1810 a80: 82 30 cpi r24, 0x02 ; 2
1811 a82: 91 05 cpc r25, r1
1812 a84: e8 f1 brcs .+122 ; 0xb00 <create_chain+0xb6>
1813 if (cstat < mcl) return cstat; /* It is already followed by next cluster */
1814 a86: 8c 15 cp r24, r12
1815 a88: 9d 05 cpc r25, r13
1816 a8a: 10 f4 brcc .+4 ; 0xa90 <create_chain+0x46>
1817 a8c: bc 01 movw r22, r24
1818 a8e: 3d c0 rjmp .+122 ; 0xb0a <create_chain+0xc0>
1819 a90: 87 01 movw r16, r14
1820 a92: 02 c0 rjmp .+4 ; 0xa98 <create_chain+0x4e>
1821 a94: 01 e0 ldi r16, 0x01 ; 1
1822 a96: 10 e0 ldi r17, 0x00 ; 0
1823 a98: e8 01 movw r28, r16
1824 scl = clust;
1825 }
1826  
1827 ncl = scl; /* Start cluster */
1828 for (;;) {
1829 ncl++; /* Next cluster */
1830 a9a: 21 96 adiw r28, 0x01 ; 1
1831 if (ncl >= mcl) { /* Wrap around */
1832 a9c: cc 15 cp r28, r12
1833 a9e: dd 05 cpc r29, r13
1834 aa0: 28 f0 brcs .+10 ; 0xaac <create_chain+0x62>
1835 ncl = 2;
1836 if (ncl > scl) return 0; /* No free custer */
1837 aa2: 02 30 cpi r16, 0x02 ; 2
1838 aa4: 11 05 cpc r17, r1
1839 aa6: 78 f1 brcs .+94 ; 0xb06 <create_chain+0xbc>
1840 aa8: c2 e0 ldi r28, 0x02 ; 2
1841 aaa: d0 e0 ldi r29, 0x00 ; 0
1842 }
1843 cstat = get_cluster(ncl); /* Get the cluster status */
1844 aac: ce 01 movw r24, r28
1845 aae: 0e 94 4f 04 call 0x89e ; 0x89e <get_cluster>
1846 if (cstat == 0) break; /* Found a free cluster */
1847 ab2: 00 97 sbiw r24, 0x00 ; 0
1848 ab4: 31 f0 breq .+12 ; 0xac2 <create_chain+0x78>
1849 if (cstat == 1) return 1; /* Any error occured */
1850 ab6: 01 97 sbiw r24, 0x01 ; 1
1851 ab8: 19 f1 breq .+70 ; 0xb00 <create_chain+0xb6>
1852 if (ncl == scl) return 0; /* No free custer */
1853 aba: c0 17 cp r28, r16
1854 abc: d1 07 cpc r29, r17
1855 abe: 19 f1 breq .+70 ; 0xb06 <create_chain+0xbc>
1856 ac0: ec cf rjmp .-40 ; 0xa9a <create_chain+0x50>
1857 }
1858  
1859 if (!put_cluster(ncl, (CLUST)0x0FFFFFFF)) return 1; /* Mark the new cluster "in use" */
1860 ac2: 6f ef ldi r22, 0xFF ; 255
1861 ac4: 7f ef ldi r23, 0xFF ; 255
1862 ac6: ce 01 movw r24, r28
1863 ac8: 0e 94 c1 03 call 0x782 ; 0x782 <put_cluster>
1864 acc: 88 23 and r24, r24
1865 ace: c1 f0 breq .+48 ; 0xb00 <create_chain+0xb6>
1866 if (clust && !put_cluster(clust, ncl)) return 1; /* Link it to previous one if needed */
1867 ad0: e1 14 cp r14, r1
1868 ad2: f1 04 cpc r15, r1
1869 ad4: 31 f0 breq .+12 ; 0xae2 <create_chain+0x98>
1870 ad6: be 01 movw r22, r28
1871 ad8: c7 01 movw r24, r14
1872 ada: 0e 94 c1 03 call 0x782 ; 0x782 <put_cluster>
1873 ade: 88 23 and r24, r24
1874 ae0: 79 f0 breq .+30 ; 0xb00 <create_chain+0xb6>
1875  
1876 fs->last_clust = ncl; /* Update fsinfo */
1877 ae2: f5 01 movw r30, r10
1878 ae4: d1 8f std Z+25, r29 ; 0x19
1879 ae6: c0 8f std Z+24, r28 ; 0x18
1880 if (fs->free_clust != (CLUST)0xFFFFFFFF) {
1881 ae8: 82 8d ldd r24, Z+26 ; 0x1a
1882 aea: 93 8d ldd r25, Z+27 ; 0x1b
1883 aec: ff ef ldi r31, 0xFF ; 255
1884 aee: 8f 3f cpi r24, 0xFF ; 255
1885 af0: 9f 07 cpc r25, r31
1886 af2: 21 f0 breq .+8 ; 0xafc <create_chain+0xb2>
1887 fs->free_clust--;
1888 af4: 01 97 sbiw r24, 0x01 ; 1
1889 af6: f5 01 movw r30, r10
1890 af8: 93 8f std Z+27, r25 ; 0x1b
1891 afa: 82 8f std Z+26, r24 ; 0x1a
1892 afc: be 01 movw r22, r28
1893 afe: 05 c0 rjmp .+10 ; 0xb0a <create_chain+0xc0>
1894 b00: 61 e0 ldi r22, 0x01 ; 1
1895 b02: 70 e0 ldi r23, 0x00 ; 0
1896 b04: 02 c0 rjmp .+4 ; 0xb0a <create_chain+0xc0>
1897 b06: 60 e0 ldi r22, 0x00 ; 0
1898 b08: 70 e0 ldi r23, 0x00 ; 0
1899 fs->fsi_flag = 1;
1900 #endif
1901 }
1902  
1903 return ncl; /* Return new cluster number */
1904 }
1905 b0a: cb 01 movw r24, r22
1906 b0c: ea e0 ldi r30, 0x0A ; 10
1907 b0e: cd b7 in r28, 0x3d ; 61
1908 b10: de b7 in r29, 0x3e ; 62
1909 b12: 0c 94 4e 11 jmp 0x229c ; 0x229c <__epilogue_restores__+0x10>
1910  
1911 00000b16 <f_lseek>:
1912  
1913 FRESULT f_lseek (
1914 FIL *fp, /* Pointer to the file object */
1915 DWORD ofs /* File pointer from top of file */
1916 )
1917 {
1918 b16: a0 e0 ldi r26, 0x00 ; 0
1919 b18: b0 e0 ldi r27, 0x00 ; 0
1920 b1a: e1 e9 ldi r30, 0x91 ; 145
1921 b1c: f5 e0 ldi r31, 0x05 ; 5
1922 b1e: 0c 94 2a 11 jmp 0x2254 ; 0x2254 <__prologue_saves__>
1923 b22: ec 01 movw r28, r24
1924 b24: 3a 01 movw r6, r20
1925 b26: 4b 01 movw r8, r22
1926 CLUST clust;
1927 DWORD csize;
1928 BYTE csect;
1929 FRESULT res;
1930 FATFS *fs = fp->fs;
1931 b28: 4c 80 ldd r4, Y+4 ; 0x04
1932 b2a: 5d 80 ldd r5, Y+5 ; 0x05
1933  
1934  
1935 res = validate(fs, fp->id); /* Check validity of the object */
1936 b2c: 68 81 ld r22, Y
1937 b2e: 79 81 ldd r23, Y+1 ; 0x01
1938 b30: c2 01 movw r24, r4
1939 b32: 0e 94 43 03 call 0x686 ; 0x686 <validate>
1940 b36: 1c 01 movw r2, r24
1941 if (res) return res;
1942 b38: 89 2b or r24, r25
1943 b3a: 09 f0 breq .+2 ; 0xb3e <f_lseek+0x28>
1944 b3c: b8 c0 rjmp .+368 ; 0xcae <f_lseek+0x198>
1945  
1946 if (fp->flag & FA__ERROR) return FR_RW_ERROR;
1947 b3e: 2a 81 ldd r18, Y+2 ; 0x02
1948 b40: 22 23 and r18, r18
1949 b42: 0c f4 brge .+2 ; 0xb46 <f_lseek+0x30>
1950 b44: b1 c0 rjmp .+354 ; 0xca8 <f_lseek+0x192>
1951 #if !_FS_READONLY
1952 if (ofs > fp->fsize && !(fp->flag & FA_WRITE))
1953 b46: 8a 85 ldd r24, Y+10 ; 0x0a
1954 b48: 9b 85 ldd r25, Y+11 ; 0x0b
1955 b4a: ac 85 ldd r26, Y+12 ; 0x0c
1956 b4c: bd 85 ldd r27, Y+13 ; 0x0d
1957 b4e: 86 15 cp r24, r6
1958 b50: 97 05 cpc r25, r7
1959 b52: a8 05 cpc r26, r8
1960 b54: b9 05 cpc r27, r9
1961 b56: 20 f4 brcc .+8 ; 0xb60 <f_lseek+0x4a>
1962 b58: 21 fd sbrc r18, 1
1963 b5a: 02 c0 rjmp .+4 ; 0xb60 <f_lseek+0x4a>
1964 b5c: 3c 01 movw r6, r24
1965 b5e: 4d 01 movw r8, r26
1966 #else
1967 if (ofs > fp->fsize)
1968 #endif
1969 ofs = fp->fsize;
1970 fp->fptr = 0; fp->sect_clust = 1; /* Set file R/W pointer to top of the file */
1971 b60: 1e 82 std Y+6, r1 ; 0x06
1972 b62: 1f 82 std Y+7, r1 ; 0x07
1973 b64: 18 86 std Y+8, r1 ; 0x08
1974 b66: 19 86 std Y+9, r1 ; 0x09
1975 b68: 81 e0 ldi r24, 0x01 ; 1
1976 b6a: 8b 83 std Y+3, r24 ; 0x03
1977  
1978 /* Move file R/W pointer if needed */
1979 if (ofs) {
1980 b6c: 61 14 cp r6, r1
1981 b6e: 71 04 cpc r7, r1
1982 b70: 81 04 cpc r8, r1
1983 b72: 91 04 cpc r9, r1
1984 b74: 09 f4 brne .+2 ; 0xb78 <f_lseek+0x62>
1985 b76: 7e c0 rjmp .+252 ; 0xc74 <f_lseek+0x15e>
1986 clust = fp->org_clust; /* Get start cluster */
1987 b78: 2e 85 ldd r18, Y+14 ; 0x0e
1988 b7a: 3f 85 ldd r19, Y+15 ; 0x0f
1989 #if !_FS_READONLY
1990 if (!clust) { /* If the file does not have a cluster chain, create new cluster chain */
1991 b7c: 21 15 cp r18, r1
1992 b7e: 31 05 cpc r19, r1
1993 b80: 71 f4 brne .+28 ; 0xb9e <f_lseek+0x88>
1994 clust = create_chain(0);
1995 b82: 80 e0 ldi r24, 0x00 ; 0
1996 b84: 90 e0 ldi r25, 0x00 ; 0
1997 b86: 0e 94 25 05 call 0xa4a ; 0xa4a <create_chain>
1998 b8a: 9c 01 movw r18, r24
1999 if (clust == 1) goto fk_error;
2000 b8c: 81 30 cpi r24, 0x01 ; 1
2001 b8e: 91 05 cpc r25, r1
2002 b90: 09 f4 brne .+2 ; 0xb94 <f_lseek+0x7e>
2003 b92: 87 c0 rjmp .+270 ; 0xca2 <f_lseek+0x18c>
2004 fp->org_clust = clust;
2005 b94: 9f 87 std Y+15, r25 ; 0x0f
2006 b96: 8e 87 std Y+14, r24 ; 0x0e
2007 }
2008 #endif
2009 if (clust) { /* If the file has a cluster chain, it can be followed */
2010 b98: 89 2b or r24, r25
2011 b9a: 09 f4 brne .+2 ; 0xb9e <f_lseek+0x88>
2012 b9c: 6b c0 rjmp .+214 ; 0xc74 <f_lseek+0x15e>
2013 csize = (DWORD)fs->sects_clust * 512; /* Cluster size in unit of byte */
2014 b9e: f2 01 movw r30, r4
2015 ba0: 85 8d ldd r24, Z+29 ; 0x1d
2016 ba2: e8 2e mov r14, r24
2017 ba4: ff 24 eor r15, r15
2018 ba6: 00 27 eor r16, r16
2019 ba8: 11 27 eor r17, r17
2020 baa: 89 e0 ldi r24, 0x09 ; 9
2021 bac: ee 0c add r14, r14
2022 bae: ff 1c adc r15, r15
2023 bb0: 00 1f adc r16, r16
2024 bb2: 11 1f adc r17, r17
2025 bb4: 8a 95 dec r24
2026 bb6: d1 f7 brne .-12 ; 0xbac <f_lseek+0x96>
2027 for (;;) { /* Loop to skip leading clusters */
2028 fp->curr_clust = clust; /* Update current cluster */
2029 bb8: 39 8b std Y+17, r19 ; 0x11
2030 bba: 28 8b std Y+16, r18 ; 0x10
2031 if (ofs <= csize) break;
2032 bbc: e6 14 cp r14, r6
2033 bbe: f7 04 cpc r15, r7
2034 bc0: 08 05 cpc r16, r8
2035 bc2: 19 05 cpc r17, r9
2036 bc4: 50 f5 brcc .+84 ; 0xc1a <f_lseek+0x104>
2037 #if !_FS_READONLY
2038 if (fp->flag & FA_WRITE) /* Check if in write mode or not */
2039 bc6: 8a 81 ldd r24, Y+2 ; 0x02
2040 bc8: 81 ff sbrs r24, 1
2041 bca: 04 c0 rjmp .+8 ; 0xbd4 <f_lseek+0xbe>
2042 clust = create_chain(clust); /* Force streached if in write mode */
2043 bcc: c9 01 movw r24, r18
2044 bce: 0e 94 25 05 call 0xa4a ; 0xa4a <create_chain>
2045 bd2: 03 c0 rjmp .+6 ; 0xbda <f_lseek+0xc4>
2046 else
2047 #endif
2048 clust = get_cluster(clust); /* Only follow cluster chain if not in write mode */
2049 bd4: c9 01 movw r24, r18
2050 bd6: 0e 94 4f 04 call 0x89e ; 0x89e <get_cluster>
2051 bda: 9c 01 movw r18, r24
2052 if (clust == 0) { /* Stop if could not follow the cluster chain */
2053 bdc: 00 97 sbiw r24, 0x00 ; 0
2054 bde: d9 f0 breq .+54 ; 0xc16 <f_lseek+0x100>
2055 ofs = csize; break;
2056 }
2057 if (clust == 1 || clust >= fs->max_clust) goto fk_error;
2058 be0: 01 97 sbiw r24, 0x01 ; 1
2059 be2: 09 f4 brne .+2 ; 0xbe6 <f_lseek+0xd0>
2060 be4: 5e c0 rjmp .+188 ; 0xca2 <f_lseek+0x18c>
2061 be6: f2 01 movw r30, r4
2062 be8: 86 89 ldd r24, Z+22 ; 0x16
2063 bea: 97 89 ldd r25, Z+23 ; 0x17
2064 bec: 28 17 cp r18, r24
2065 bee: 39 07 cpc r19, r25
2066 bf0: 08 f0 brcs .+2 ; 0xbf4 <f_lseek+0xde>
2067 bf2: 57 c0 rjmp .+174 ; 0xca2 <f_lseek+0x18c>
2068 fp->fptr += csize; /* Update R/W pointer */
2069 bf4: 8e 81 ldd r24, Y+6 ; 0x06
2070 bf6: 9f 81 ldd r25, Y+7 ; 0x07
2071 bf8: a8 85 ldd r26, Y+8 ; 0x08
2072 bfa: b9 85 ldd r27, Y+9 ; 0x09
2073 bfc: 8e 0d add r24, r14
2074 bfe: 9f 1d adc r25, r15
2075 c00: a0 1f adc r26, r16
2076 c02: b1 1f adc r27, r17
2077 c04: 8e 83 std Y+6, r24 ; 0x06
2078 c06: 9f 83 std Y+7, r25 ; 0x07
2079 c08: a8 87 std Y+8, r26 ; 0x08
2080 c0a: b9 87 std Y+9, r27 ; 0x09
2081 ofs -= csize;
2082 c0c: 6e 18 sub r6, r14
2083 c0e: 7f 08 sbc r7, r15
2084 c10: 80 0a sbc r8, r16
2085 c12: 91 0a sbc r9, r17
2086 c14: d1 cf rjmp .-94 ; 0xbb8 <f_lseek+0xa2>
2087 }
2088 c16: 37 01 movw r6, r14
2089 c18: 48 01 movw r8, r16
2090 csect = (BYTE)((ofs - 1) / 512); /* Sector offset in the cluster */
2091 c1a: 64 01 movw r12, r8
2092 c1c: 53 01 movw r10, r6
2093 c1e: 08 94 sec
2094 c20: a1 08 sbc r10, r1
2095 c22: b1 08 sbc r11, r1
2096 c24: c1 08 sbc r12, r1
2097 c26: d1 08 sbc r13, r1
2098 c28: 09 e0 ldi r16, 0x09 ; 9
2099 c2a: d6 94 lsr r13
2100 c2c: c7 94 ror r12
2101 c2e: b7 94 ror r11
2102 c30: a7 94 ror r10
2103 c32: 0a 95 dec r16
2104 c34: d1 f7 brne .-12 ; 0xc2a <f_lseek+0x114>
2105 fp->curr_sect = clust2sect(clust) + csect; /* Current sector */
2106 c36: ea 2c mov r14, r10
2107 c38: ff 24 eor r15, r15
2108 c3a: 00 27 eor r16, r16
2109 c3c: 11 27 eor r17, r17
2110 c3e: c9 01 movw r24, r18
2111 c40: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
2112 c44: e6 0e add r14, r22
2113 c46: f7 1e adc r15, r23
2114 c48: 08 1f adc r16, r24
2115 c4a: 19 1f adc r17, r25
2116 c4c: ea 8a std Y+18, r14 ; 0x12
2117 c4e: fb 8a std Y+19, r15 ; 0x13
2118 c50: 0c 8b std Y+20, r16 ; 0x14
2119 c52: 1d 8b std Y+21, r17 ; 0x15
2120 fp->sect_clust = fs->sects_clust - csect; /* Left sector counter in the cluster */
2121 c54: f2 01 movw r30, r4
2122 c56: 85 8d ldd r24, Z+29 ; 0x1d
2123 c58: 8a 19 sub r24, r10
2124 c5a: 8b 83 std Y+3, r24 ; 0x03
2125 fp->fptr += ofs; /* Update file R/W pointer */
2126 c5c: 8e 81 ldd r24, Y+6 ; 0x06
2127 c5e: 9f 81 ldd r25, Y+7 ; 0x07
2128 c60: a8 85 ldd r26, Y+8 ; 0x08
2129 c62: b9 85 ldd r27, Y+9 ; 0x09
2130 c64: 86 0d add r24, r6
2131 c66: 97 1d adc r25, r7
2132 c68: a8 1d adc r26, r8
2133 c6a: b9 1d adc r27, r9
2134 c6c: 8e 83 std Y+6, r24 ; 0x06
2135 c6e: 9f 83 std Y+7, r25 ; 0x07
2136 c70: a8 87 std Y+8, r26 ; 0x08
2137 c72: b9 87 std Y+9, r27 ; 0x09
2138 }
2139 }
2140 #if !_FS_READONLY
2141 if ((fp->flag & FA_WRITE) && fp->fptr > fp->fsize) { /* Set updated flag if in write mode */
2142 c74: 6a 81 ldd r22, Y+2 ; 0x02
2143 c76: 61 ff sbrs r22, 1
2144 c78: 1a c0 rjmp .+52 ; 0xcae <f_lseek+0x198>
2145 c7a: 2e 81 ldd r18, Y+6 ; 0x06
2146 c7c: 3f 81 ldd r19, Y+7 ; 0x07
2147 c7e: 48 85 ldd r20, Y+8 ; 0x08
2148 c80: 59 85 ldd r21, Y+9 ; 0x09
2149 c82: 8a 85 ldd r24, Y+10 ; 0x0a
2150 c84: 9b 85 ldd r25, Y+11 ; 0x0b
2151 c86: ac 85 ldd r26, Y+12 ; 0x0c
2152 c88: bd 85 ldd r27, Y+13 ; 0x0d
2153 c8a: 82 17 cp r24, r18
2154 c8c: 93 07 cpc r25, r19
2155 c8e: a4 07 cpc r26, r20
2156 c90: b5 07 cpc r27, r21
2157 c92: 68 f4 brcc .+26 ; 0xcae <f_lseek+0x198>
2158 fp->fsize = fp->fptr;
2159 c94: 2a 87 std Y+10, r18 ; 0x0a
2160 c96: 3b 87 std Y+11, r19 ; 0x0b
2161 c98: 4c 87 std Y+12, r20 ; 0x0c
2162 c9a: 5d 87 std Y+13, r21 ; 0x0d
2163 fp->flag |= FA__WRITTEN;
2164 c9c: 60 62 ori r22, 0x20 ; 32
2165 c9e: 6a 83 std Y+2, r22 ; 0x02
2166 ca0: 06 c0 rjmp .+12 ; 0xcae <f_lseek+0x198>
2167 #endif
2168  
2169 return FR_OK;
2170  
2171 fk_error: /* Abort this function due to an unrecoverable error */
2172 fp->flag |= FA__ERROR;
2173 ca2: 8a 81 ldd r24, Y+2 ; 0x02
2174 ca4: 80 68 ori r24, 0x80 ; 128
2175 ca6: 8a 83 std Y+2, r24 ; 0x02
2176 ca8: 18 e0 ldi r17, 0x08 ; 8
2177 caa: 21 2e mov r2, r17
2178 cac: 31 2c mov r3, r1
2179 return FR_RW_ERROR;
2180 }
2181 cae: c1 01 movw r24, r2
2182 cb0: e2 e1 ldi r30, 0x12 ; 18
2183 cb2: cd b7 in r28, 0x3d ; 61
2184 cb4: de b7 in r29, 0x3e ; 62
2185 cb6: 0c 94 46 11 jmp 0x228c ; 0x228c <__epilogue_restores__>
2186  
2187 00000cba <f_sync>:
2188 /*-----------------------------------------------------------------------*/
2189  
2190 FRESULT f_sync (
2191 FIL *fp /* Pointer to the file object */
2192 )
2193 {
2194 cba: ef 92 push r14
2195 cbc: ff 92 push r15
2196 cbe: 0f 93 push r16
2197 cc0: 1f 93 push r17
2198 cc2: cf 93 push r28
2199 cc4: df 93 push r29
2200 cc6: ec 01 movw r28, r24
2201 BYTE *dir;
2202 FRESULT res;
2203 FATFS *fs = fp->fs;
2204  
2205  
2206 res = validate(fs, fp->id); /* Check validity of the object */
2207 cc8: 68 81 ld r22, Y
2208 cca: 79 81 ldd r23, Y+1 ; 0x01
2209 ccc: 8c 81 ldd r24, Y+4 ; 0x04
2210 cce: 9d 81 ldd r25, Y+5 ; 0x05
2211 cd0: 0e 94 43 03 call 0x686 ; 0x686 <validate>
2212 cd4: 7c 01 movw r14, r24
2213 if (res == FR_OK) {
2214 cd6: 89 2b or r24, r25
2215 cd8: 09 f0 breq .+2 ; 0xcdc <f_sync+0x22>
2216 cda: 40 c0 rjmp .+128 ; 0xd5c <f_sync+0xa2>
2217 if (fp->flag & FA__WRITTEN) { /* Has the file been written? */
2218 cdc: 8a 81 ldd r24, Y+2 ; 0x02
2219 cde: 85 ff sbrs r24, 5
2220 ce0: 3d c0 rjmp .+122 ; 0xd5c <f_sync+0xa2>
2221 /* Update the directory entry */
2222 if (!move_window(fp->dir_sect))
2223 ce2: 6e 89 ldd r22, Y+22 ; 0x16
2224 ce4: 7f 89 ldd r23, Y+23 ; 0x17
2225 ce6: 88 8d ldd r24, Y+24 ; 0x18
2226 ce8: 99 8d ldd r25, Y+25 ; 0x19
2227 cea: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
2228 cee: 88 23 and r24, r24
2229 cf0: 91 f1 breq .+100 ; 0xd56 <f_sync+0x9c>
2230 return FR_RW_ERROR;
2231 dir = fp->dir_ptr;
2232 cf2: 0a 8d ldd r16, Y+26 ; 0x1a
2233 cf4: 1b 8d ldd r17, Y+27 ; 0x1b
2234 dir[DIR_Attr] |= AM_ARC; /* Set archive bit */
2235 cf6: f8 01 movw r30, r16
2236 cf8: 83 85 ldd r24, Z+11 ; 0x0b
2237 cfa: 80 62 ori r24, 0x20 ; 32
2238 cfc: 83 87 std Z+11, r24 ; 0x0b
2239 ST_DWORD(&dir[DIR_FileSize], fp->fsize); /* Update file size */
2240 cfe: 8a 85 ldd r24, Y+10 ; 0x0a
2241 d00: 9b 85 ldd r25, Y+11 ; 0x0b
2242 d02: ac 85 ldd r26, Y+12 ; 0x0c
2243 d04: bd 85 ldd r27, Y+13 ; 0x0d
2244 d06: 84 8f std Z+28, r24 ; 0x1c
2245 d08: 95 8f std Z+29, r25 ; 0x1d
2246 d0a: a6 8f std Z+30, r26 ; 0x1e
2247 d0c: b7 8f std Z+31, r27 ; 0x1f
2248 ST_WORD(&dir[DIR_FstClusLO], fp->org_clust); /* Update start cluster */
2249 d0e: 8e 85 ldd r24, Y+14 ; 0x0e
2250 d10: 9f 85 ldd r25, Y+15 ; 0x0f
2251 d12: 93 8f std Z+27, r25 ; 0x1b
2252 d14: 82 8f std Z+26, r24 ; 0x1a
2253 #if _FAT32
2254 ST_WORD(&dir[DIR_FstClusHI], fp->org_clust >> 16);
2255 #endif
2256 tim = get_fattime(); /* Updated time */
2257 d16: 0e 94 bb 00 call 0x176 ; 0x176 <get_fattime>
2258 ST_DWORD(&dir[DIR_WrtTime], tim);
2259 d1a: f8 01 movw r30, r16
2260 d1c: 66 8b std Z+22, r22 ; 0x16
2261 d1e: 77 8b std Z+23, r23 ; 0x17
2262 d20: 80 8f std Z+24, r24 ; 0x18
2263 d22: 91 8f std Z+25, r25 ; 0x19
2264 fp->flag &= ~FA__WRITTEN;
2265 d24: 8a 81 ldd r24, Y+2 ; 0x02
2266 d26: 8f 7d andi r24, 0xDF ; 223
2267 d28: 8a 83 std Y+2, r24 ; 0x02
2268 FRESULT sync (void) /* FR_OK: successful, FR_RW_ERROR: failed */
2269 {
2270 FATFS *fs = FatFs;
2271  
2272  
2273 fs->winflag = 1;
2274 d2a: e0 91 0a 01 lds r30, 0x010A
2275 d2e: f0 91 0b 01 lds r31, 0x010B
2276 d32: 81 e0 ldi r24, 0x01 ; 1
2277 d34: 87 8f std Z+31, r24 ; 0x1f
2278 if (!move_window(0)) return FR_RW_ERROR;
2279 d36: 60 e0 ldi r22, 0x00 ; 0
2280 d38: 70 e0 ldi r23, 0x00 ; 0
2281 d3a: 80 e0 ldi r24, 0x00 ; 0
2282 d3c: 90 e0 ldi r25, 0x00 ; 0
2283 d3e: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
2284 d42: 88 23 and r24, r24
2285 d44: 41 f0 breq .+16 ; 0xd56 <f_sync+0x9c>
2286 ST_DWORD(&fs->win[FSI_Nxt_Free], fs->last_clust);
2287 disk_write(0, fs->win, fs->fsi_sector, 1);
2288 fs->fsi_flag = 0;
2289 }
2290 #endif
2291 if (disk_ioctl(0, CTRL_SYNC, NULL) != RES_OK) return FR_RW_ERROR;
2292 d46: 40 e0 ldi r20, 0x00 ; 0
2293 d48: 50 e0 ldi r21, 0x00 ; 0
2294 d4a: 63 e0 ldi r22, 0x03 ; 3
2295 d4c: 80 e0 ldi r24, 0x00 ; 0
2296 d4e: 0e 94 e8 0d call 0x1bd0 ; 0x1bd0 <disk_ioctl>
2297 d52: 89 2b or r24, r25
2298 d54: 19 f0 breq .+6 ; 0xd5c <f_sync+0xa2>
2299 d56: 98 e0 ldi r25, 0x08 ; 8
2300 d58: e9 2e mov r14, r25
2301 d5a: f1 2c mov r15, r1
2302 fp->flag &= ~FA__WRITTEN;
2303 res = sync();
2304 }
2305 }
2306 return res;
2307 }
2308 d5c: c7 01 movw r24, r14
2309 d5e: e6 e0 ldi r30, 0x06 ; 6
2310 d60: cd b7 in r28, 0x3d ; 61
2311 d62: de b7 in r29, 0x3e ; 62
2312 d64: 0c 94 52 11 jmp 0x22a4 ; 0x22a4 <__epilogue_restores__+0x18>
2313  
2314 00000d68 <f_close>:
2315 /*-----------------------------------------------------------------------*/
2316  
2317 FRESULT f_close (
2318 FIL *fp /* Pointer to the file object to be closed */
2319 )
2320 {
2321 d68: cf 93 push r28
2322 d6a: df 93 push r29
2323 d6c: ec 01 movw r28, r24
2324 FRESULT res;
2325  
2326  
2327 #if !_FS_READONLY
2328 res = f_sync(fp);
2329 d6e: 0e 94 5d 06 call 0xcba ; 0xcba <f_sync>
2330 #else
2331 res = validate(fp->fs, fp->id);
2332 #endif
2333 if (res == FR_OK)
2334 d72: 00 97 sbiw r24, 0x00 ; 0
2335 d74: 11 f4 brne .+4 ; 0xd7a <f_close+0x12>
2336 fp->fs = NULL;
2337 d76: 1d 82 std Y+5, r1 ; 0x05
2338 d78: 1c 82 std Y+4, r1 ; 0x04
2339 d7a: df 91 pop r29
2340 d7c: cf 91 pop r28
2341 d7e: 08 95 ret
2342  
2343 00000d80 <f_write>:
2344 FIL *fp, /* Pointer to the file object */
2345 const void *buff, /* Pointer to the data to be written */
2346 WORD btw, /* Number of bytes to write */
2347 WORD *bw /* Pointer to number of bytes written */
2348 )
2349 {
2350 d80: a0 e0 ldi r26, 0x00 ; 0
2351 d82: b0 e0 ldi r27, 0x00 ; 0
2352 d84: e6 ec ldi r30, 0xC6 ; 198
2353 d86: f6 e0 ldi r31, 0x06 ; 6
2354 d88: 0c 94 2c 11 jmp 0x2258 ; 0x2258 <__prologue_saves__+0x4>
2355 d8c: ec 01 movw r28, r24
2356 d8e: 8b 01 movw r16, r22
2357 d90: 7a 01 movw r14, r20
2358 d92: 39 01 movw r6, r18
2359 WORD wcnt;
2360 CLUST clust;
2361 BYTE cc;
2362 FRESULT res;
2363 const BYTE *wbuff = buff;
2364 FATFS *fs = fp->fs;
2365 d94: cc 80 ldd r12, Y+4 ; 0x04
2366 d96: dd 80 ldd r13, Y+5 ; 0x05
2367  
2368  
2369 *bw = 0;
2370 d98: f9 01 movw r30, r18
2371 d9a: 11 82 std Z+1, r1 ; 0x01
2372 d9c: 10 82 st Z, r1
2373 res = validate(fs, fp->id); /* Check validity of the object */
2374 d9e: 68 81 ld r22, Y
2375 da0: 79 81 ldd r23, Y+1 ; 0x01
2376 da2: c6 01 movw r24, r12
2377 da4: 0e 94 43 03 call 0x686 ; 0x686 <validate>
2378 da8: 4c 01 movw r8, r24
2379 if (res) return res;
2380 daa: 89 2b or r24, r25
2381 dac: 09 f0 breq .+2 ; 0xdb0 <f_write+0x30>
2382 dae: 1a c1 rjmp .+564 ; 0xfe4 <f_write+0x264>
2383 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
2384 db0: 8a 81 ldd r24, Y+2 ; 0x02
2385 db2: 88 23 and r24, r24
2386 db4: 0c f4 brge .+2 ; 0xdb8 <f_write+0x38>
2387 db6: 13 c1 rjmp .+550 ; 0xfde <f_write+0x25e>
2388 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2389 db8: 81 fd sbrc r24, 1
2390 dba: 04 c0 rjmp .+8 ; 0xdc4 <f_write+0x44>
2391 dbc: e6 e0 ldi r30, 0x06 ; 6
2392 dbe: 8e 2e mov r8, r30
2393 dc0: 91 2c mov r9, r1
2394 dc2: 10 c1 rjmp .+544 ; 0xfe4 <f_write+0x264>
2395 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2396 dc4: 2a 85 ldd r18, Y+10 ; 0x0a
2397 dc6: 3b 85 ldd r19, Y+11 ; 0x0b
2398 dc8: 4c 85 ldd r20, Y+12 ; 0x0c
2399 dca: 5d 85 ldd r21, Y+13 ; 0x0d
2400 dcc: c7 01 movw r24, r14
2401 dce: aa 27 eor r26, r26
2402 dd0: bb 27 eor r27, r27
2403 dd2: 82 0f add r24, r18
2404 dd4: 93 1f adc r25, r19
2405 dd6: a4 1f adc r26, r20
2406 dd8: b5 1f adc r27, r21
2407 dda: 82 17 cp r24, r18
2408 ddc: 93 07 cpc r25, r19
2409 dde: a4 07 cpc r26, r20
2410 de0: b5 07 cpc r27, r21
2411 de2: 08 f4 brcc .+2 ; 0xde6 <f_write+0x66>
2412 de4: ff c0 rjmp .+510 ; 0xfe4 <f_write+0x264>
2413 DWORD sect;
2414 WORD wcnt;
2415 CLUST clust;
2416 BYTE cc;
2417 FRESULT res;
2418 const BYTE *wbuff = buff;
2419 de6: 58 01 movw r10, r16
2420 }
2421 if (!move_window(fp->curr_sect)) /* Move sector window */
2422 goto fw_error;
2423 wcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes bytes to sector window */
2424 if (wcnt > btw) wcnt = btw;
2425 memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
2426 de8: 70 e2 ldi r23, 0x20 ; 32
2427 dea: 47 2e mov r4, r23
2428 dec: 51 2c mov r5, r1
2429 dee: 4c 0c add r4, r12
2430 df0: 5d 1c adc r5, r13
2431 df2: d9 c0 rjmp .+434 ; 0xfa6 <f_write+0x226>
2432 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2433 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2434  
2435 for ( ; btw; /* Repeat until all data transferred */
2436 wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
2437 if ((fp->fptr % 512) == 0) { /* On the sector boundary */
2438 df4: 2e 81 ldd r18, Y+6 ; 0x06
2439 df6: 3f 81 ldd r19, Y+7 ; 0x07
2440 df8: 48 85 ldd r20, Y+8 ; 0x08
2441 dfa: 59 85 ldd r21, Y+9 ; 0x09
2442 dfc: da 01 movw r26, r20
2443 dfe: c9 01 movw r24, r18
2444 e00: 91 70 andi r25, 0x01 ; 1
2445 e02: a0 70 andi r26, 0x00 ; 0
2446 e04: b0 70 andi r27, 0x00 ; 0
2447 e06: 00 97 sbiw r24, 0x00 ; 0
2448 e08: a1 05 cpc r26, r1
2449 e0a: b1 05 cpc r27, r1
2450 e0c: 09 f0 breq .+2 ; 0xe10 <f_write+0x90>
2451 e0e: 93 c0 rjmp .+294 ; 0xf36 <f_write+0x1b6>
2452 if (--(fp->sect_clust)) { /* Decrement left sector counter */
2453 e10: 8b 81 ldd r24, Y+3 ; 0x03
2454 e12: 81 50 subi r24, 0x01 ; 1
2455 e14: 8b 83 std Y+3, r24 ; 0x03
2456 e16: 88 23 and r24, r24
2457 e18: 49 f0 breq .+18 ; 0xe2c <f_write+0xac>
2458 sect = fp->curr_sect + 1; /* Get current sector */
2459 e1a: 2a 89 ldd r18, Y+18 ; 0x12
2460 e1c: 3b 89 ldd r19, Y+19 ; 0x13
2461 e1e: 4c 89 ldd r20, Y+20 ; 0x14
2462 e20: 5d 89 ldd r21, Y+21 ; 0x15
2463 e22: 2f 5f subi r18, 0xFF ; 255
2464 e24: 3f 4f sbci r19, 0xFF ; 255
2465 e26: 4f 4f sbci r20, 0xFF ; 255
2466 e28: 5f 4f sbci r21, 0xFF ; 255
2467 e2a: 30 c0 rjmp .+96 ; 0xe8c <f_write+0x10c>
2468 } else { /* On the cluster boundary, get next cluster */
2469 if (fp->fptr == 0) { /* Is top of the file */
2470 e2c: 21 15 cp r18, r1
2471 e2e: 31 05 cpc r19, r1
2472 e30: 41 05 cpc r20, r1
2473 e32: 51 05 cpc r21, r1
2474 e34: 69 f4 brne .+26 ; 0xe50 <f_write+0xd0>
2475 clust = fp->org_clust;
2476 e36: 2e 85 ldd r18, Y+14 ; 0x0e
2477 e38: 3f 85 ldd r19, Y+15 ; 0x0f
2478 if (clust == 0) /* No cluster is created yet */
2479 e3a: 21 15 cp r18, r1
2480 e3c: 31 05 cpc r19, r1
2481 e3e: 89 f4 brne .+34 ; 0xe62 <f_write+0xe2>
2482 fp->org_clust = clust = create_chain(0); /* Create a new cluster chain */
2483 e40: 80 e0 ldi r24, 0x00 ; 0
2484 e42: 90 e0 ldi r25, 0x00 ; 0
2485 e44: 0e 94 25 05 call 0xa4a ; 0xa4a <create_chain>
2486 e48: 9c 01 movw r18, r24
2487 e4a: 9f 87 std Y+15, r25 ; 0x0f
2488 e4c: 8e 87 std Y+14, r24 ; 0x0e
2489 e4e: 05 c0 rjmp .+10 ; 0xe5a <f_write+0xda>
2490 } else { /* Middle or end of file */
2491 clust = create_chain(fp->curr_clust); /* Trace or streach cluster chain */
2492 e50: 88 89 ldd r24, Y+16 ; 0x10
2493 e52: 99 89 ldd r25, Y+17 ; 0x11
2494 e54: 0e 94 25 05 call 0xa4a ; 0xa4a <create_chain>
2495 e58: 9c 01 movw r18, r24
2496 }
2497 if (clust == 0) break; /* Disk full */
2498 e5a: 21 15 cp r18, r1
2499 e5c: 31 05 cpc r19, r1
2500 e5e: 09 f4 brne .+2 ; 0xe62 <f_write+0xe2>
2501 e60: a6 c0 rjmp .+332 ; 0xfae <f_write+0x22e>
2502 if (clust == 1 || clust >= fs->max_clust) goto fw_error;
2503 e62: 21 30 cpi r18, 0x01 ; 1
2504 e64: 31 05 cpc r19, r1
2505 e66: 09 f4 brne .+2 ; 0xe6a <f_write+0xea>
2506 e68: b7 c0 rjmp .+366 ; 0xfd8 <f_write+0x258>
2507 e6a: f6 01 movw r30, r12
2508 e6c: 86 89 ldd r24, Z+22 ; 0x16
2509 e6e: 97 89 ldd r25, Z+23 ; 0x17
2510 e70: 28 17 cp r18, r24
2511 e72: 39 07 cpc r19, r25
2512 e74: 08 f0 brcs .+2 ; 0xe78 <f_write+0xf8>
2513 e76: b0 c0 rjmp .+352 ; 0xfd8 <f_write+0x258>
2514 fp->curr_clust = clust; /* Current cluster */
2515 e78: 39 8b std Y+17, r19 ; 0x11
2516 e7a: 28 8b std Y+16, r18 ; 0x10
2517 sect = clust2sect(clust); /* Get current sector */
2518 e7c: c9 01 movw r24, r18
2519 e7e: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
2520 e82: 9b 01 movw r18, r22
2521 e84: ac 01 movw r20, r24
2522 fp->sect_clust = fs->sects_clust; /* Re-initialize the left sector counter */
2523 e86: f6 01 movw r30, r12
2524 e88: 85 8d ldd r24, Z+29 ; 0x1d
2525 e8a: 8b 83 std Y+3, r24 ; 0x03
2526 }
2527 fp->curr_sect = sect; /* Update current sector */
2528 e8c: 2a 8b std Y+18, r18 ; 0x12
2529 e8e: 3b 8b std Y+19, r19 ; 0x13
2530 e90: 4c 8b std Y+20, r20 ; 0x14
2531 e92: 5d 8b std Y+21, r21 ; 0x15
2532 cc = btw / 512; /* When left bytes >= 512, */
2533 e94: 87 01 movw r16, r14
2534 e96: 01 2f mov r16, r17
2535 e98: 11 27 eor r17, r17
2536 e9a: 06 95 lsr r16
2537 if (cc) { /* Write maximum contiguous sectors directly */
2538 e9c: 00 23 and r16, r16
2539 e9e: 61 f1 breq .+88 ; 0xef8 <f_write+0x178>
2540 ea0: 8b 81 ldd r24, Y+3 ; 0x03
2541 ea2: 10 2f mov r17, r16
2542 ea4: 80 17 cp r24, r16
2543 ea6: 08 f4 brcc .+2 ; 0xeaa <f_write+0x12a>
2544 ea8: 18 2f mov r17, r24
2545 if (cc > fp->sect_clust) cc = fp->sect_clust;
2546 if (disk_write(0, wbuff, sect, cc) != RES_OK)
2547 eaa: 01 2f mov r16, r17
2548 eac: b5 01 movw r22, r10
2549 eae: 80 e0 ldi r24, 0x00 ; 0
2550 eb0: 0e 94 d3 0e call 0x1da6 ; 0x1da6 <disk_write>
2551 eb4: 89 2b or r24, r25
2552 eb6: 09 f0 breq .+2 ; 0xeba <f_write+0x13a>
2553 eb8: 8f c0 rjmp .+286 ; 0xfd8 <f_write+0x258>
2554 goto fw_error;
2555 fp->sect_clust -= cc - 1;
2556 eba: 8b 81 ldd r24, Y+3 ; 0x03
2557 ebc: 8f 5f subi r24, 0xFF ; 255
2558 ebe: 81 1b sub r24, r17
2559 ec0: 8b 83 std Y+3, r24 ; 0x03
2560 fp->curr_sect += cc - 1;
2561 ec2: 81 2f mov r24, r17
2562 ec4: 99 27 eor r25, r25
2563 ec6: 01 97 sbiw r24, 0x01 ; 1
2564 ec8: 9c 01 movw r18, r24
2565 eca: 44 27 eor r20, r20
2566 ecc: 37 fd sbrc r19, 7
2567 ece: 40 95 com r20
2568 ed0: 54 2f mov r21, r20
2569 ed2: 8c 01 movw r16, r24
2570 ed4: 0f 5f subi r16, 0xFF ; 255
2571 ed6: 1f 4f sbci r17, 0xFF ; 255
2572 ed8: 8a 89 ldd r24, Y+18 ; 0x12
2573 eda: 9b 89 ldd r25, Y+19 ; 0x13
2574 edc: ac 89 ldd r26, Y+20 ; 0x14
2575 ede: bd 89 ldd r27, Y+21 ; 0x15
2576 ee0: 82 0f add r24, r18
2577 ee2: 93 1f adc r25, r19
2578 ee4: a4 1f adc r26, r20
2579 ee6: b5 1f adc r27, r21
2580 ee8: 8a 8b std Y+18, r24 ; 0x12
2581 eea: 9b 8b std Y+19, r25 ; 0x13
2582 eec: ac 8b std Y+20, r26 ; 0x14
2583 eee: bd 8b std Y+21, r27 ; 0x15
2584 wcnt = cc * 512; continue;
2585 ef0: 10 2f mov r17, r16
2586 ef2: 00 27 eor r16, r16
2587 ef4: 11 0f add r17, r17
2588 ef6: 3d c0 rjmp .+122 ; 0xf72 <f_write+0x1f2>
2589 }
2590 if (fp->fptr >= fp->fsize) { /* Flush R/W window if needed */
2591 ef8: 2e 81 ldd r18, Y+6 ; 0x06
2592 efa: 3f 81 ldd r19, Y+7 ; 0x07
2593 efc: 48 85 ldd r20, Y+8 ; 0x08
2594 efe: 59 85 ldd r21, Y+9 ; 0x09
2595 f00: 8a 85 ldd r24, Y+10 ; 0x0a
2596 f02: 9b 85 ldd r25, Y+11 ; 0x0b
2597 f04: ac 85 ldd r26, Y+12 ; 0x0c
2598 f06: bd 85 ldd r27, Y+13 ; 0x0d
2599 f08: 28 17 cp r18, r24
2600 f0a: 39 07 cpc r19, r25
2601 f0c: 4a 07 cpc r20, r26
2602 f0e: 5b 07 cpc r21, r27
2603 f10: 90 f0 brcs .+36 ; 0xf36 <f_write+0x1b6>
2604 if (!move_window(0)) goto fw_error;
2605 f12: 60 e0 ldi r22, 0x00 ; 0
2606 f14: 70 e0 ldi r23, 0x00 ; 0
2607 f16: 80 e0 ldi r24, 0x00 ; 0
2608 f18: 90 e0 ldi r25, 0x00 ; 0
2609 f1a: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
2610 f1e: 88 23 and r24, r24
2611 f20: 09 f4 brne .+2 ; 0xf24 <f_write+0x1a4>
2612 f22: 5a c0 rjmp .+180 ; 0xfd8 <f_write+0x258>
2613 fs->winsect = fp->curr_sect;
2614 f24: 8a 89 ldd r24, Y+18 ; 0x12
2615 f26: 9b 89 ldd r25, Y+19 ; 0x13
2616 f28: ac 89 ldd r26, Y+20 ; 0x14
2617 f2a: bd 89 ldd r27, Y+21 ; 0x15
2618 f2c: f6 01 movw r30, r12
2619 f2e: 84 83 std Z+4, r24 ; 0x04
2620 f30: 95 83 std Z+5, r25 ; 0x05
2621 f32: a6 83 std Z+6, r26 ; 0x06
2622 f34: b7 83 std Z+7, r27 ; 0x07
2623 }
2624 }
2625 if (!move_window(fp->curr_sect)) /* Move sector window */
2626 f36: 6a 89 ldd r22, Y+18 ; 0x12
2627 f38: 7b 89 ldd r23, Y+19 ; 0x13
2628 f3a: 8c 89 ldd r24, Y+20 ; 0x14
2629 f3c: 9d 89 ldd r25, Y+21 ; 0x15
2630 f3e: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
2631 f42: 88 23 and r24, r24
2632 f44: 09 f4 brne .+2 ; 0xf48 <f_write+0x1c8>
2633 f46: 48 c0 rjmp .+144 ; 0xfd8 <f_write+0x258>
2634 goto fw_error;
2635 wcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes bytes to sector window */
2636 f48: 8e 81 ldd r24, Y+6 ; 0x06
2637 f4a: 9f 81 ldd r25, Y+7 ; 0x07
2638 f4c: 91 70 andi r25, 0x01 ; 1
2639 f4e: 20 e0 ldi r18, 0x00 ; 0
2640 f50: 32 e0 ldi r19, 0x02 ; 2
2641 f52: 28 1b sub r18, r24
2642 f54: 39 0b sbc r19, r25
2643 f56: 87 01 movw r16, r14
2644 f58: 2e 15 cp r18, r14
2645 f5a: 3f 05 cpc r19, r15
2646 f5c: 08 f4 brcc .+2 ; 0xf60 <f_write+0x1e0>
2647 f5e: 89 01 movw r16, r18
2648 if (wcnt > btw) wcnt = btw;
2649 memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
2650 f60: a8 01 movw r20, r16
2651 f62: b5 01 movw r22, r10
2652 f64: 84 0d add r24, r4
2653 f66: 95 1d adc r25, r5
2654 f68: 0e 94 a1 10 call 0x2142 ; 0x2142 <memcpy>
2655 fs->winflag = 1;
2656 f6c: 81 e0 ldi r24, 0x01 ; 1
2657 f6e: f6 01 movw r30, r12
2658 f70: 87 8f std Z+31, r24 ; 0x1f
2659 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
2660 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2661 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2662  
2663 for ( ; btw; /* Repeat until all data transferred */
2664 wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
2665 f72: a0 0e add r10, r16
2666 f74: b1 1e adc r11, r17
2667 f76: c8 01 movw r24, r16
2668 f78: aa 27 eor r26, r26
2669 f7a: bb 27 eor r27, r27
2670 f7c: 2e 81 ldd r18, Y+6 ; 0x06
2671 f7e: 3f 81 ldd r19, Y+7 ; 0x07
2672 f80: 48 85 ldd r20, Y+8 ; 0x08
2673 f82: 59 85 ldd r21, Y+9 ; 0x09
2674 f84: 28 0f add r18, r24
2675 f86: 39 1f adc r19, r25
2676 f88: 4a 1f adc r20, r26
2677 f8a: 5b 1f adc r21, r27
2678 f8c: 2e 83 std Y+6, r18 ; 0x06
2679 f8e: 3f 83 std Y+7, r19 ; 0x07
2680 f90: 48 87 std Y+8, r20 ; 0x08
2681 f92: 59 87 std Y+9, r21 ; 0x09
2682 f94: f3 01 movw r30, r6
2683 f96: 80 81 ld r24, Z
2684 f98: 91 81 ldd r25, Z+1 ; 0x01
2685 f9a: 80 0f add r24, r16
2686 f9c: 91 1f adc r25, r17
2687 f9e: 91 83 std Z+1, r25 ; 0x01
2688 fa0: 80 83 st Z, r24
2689 fa2: e0 1a sub r14, r16
2690 fa4: f1 0a sbc r15, r17
2691 if (res) return res;
2692 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
2693 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2694 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2695  
2696 for ( ; btw; /* Repeat until all data transferred */
2697 fa6: e1 14 cp r14, r1
2698 fa8: f1 04 cpc r15, r1
2699 faa: 09 f0 breq .+2 ; 0xfae <f_write+0x22e>
2700 fac: 23 cf rjmp .-442 ; 0xdf4 <f_write+0x74>
2701 if (wcnt > btw) wcnt = btw;
2702 memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
2703 fs->winflag = 1;
2704 }
2705  
2706 if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */
2707 fae: 2e 81 ldd r18, Y+6 ; 0x06
2708 fb0: 3f 81 ldd r19, Y+7 ; 0x07
2709 fb2: 48 85 ldd r20, Y+8 ; 0x08
2710 fb4: 59 85 ldd r21, Y+9 ; 0x09
2711 fb6: 8a 85 ldd r24, Y+10 ; 0x0a
2712 fb8: 9b 85 ldd r25, Y+11 ; 0x0b
2713 fba: ac 85 ldd r26, Y+12 ; 0x0c
2714 fbc: bd 85 ldd r27, Y+13 ; 0x0d
2715 fbe: 82 17 cp r24, r18
2716 fc0: 93 07 cpc r25, r19
2717 fc2: a4 07 cpc r26, r20
2718 fc4: b5 07 cpc r27, r21
2719 fc6: 20 f4 brcc .+8 ; 0xfd0 <f_write+0x250>
2720 fc8: 2a 87 std Y+10, r18 ; 0x0a
2721 fca: 3b 87 std Y+11, r19 ; 0x0b
2722 fcc: 4c 87 std Y+12, r20 ; 0x0c
2723 fce: 5d 87 std Y+13, r21 ; 0x0d
2724 fp->flag |= FA__WRITTEN; /* Set file changed flag */
2725 fd0: 8a 81 ldd r24, Y+2 ; 0x02
2726 fd2: 80 62 ori r24, 0x20 ; 32
2727 fd4: 8a 83 std Y+2, r24 ; 0x02
2728 fd6: 06 c0 rjmp .+12 ; 0xfe4 <f_write+0x264>
2729 return FR_OK;
2730  
2731 fw_error: /* Abort this function due to an unrecoverable error */
2732 fp->flag |= FA__ERROR;
2733 fd8: 8a 81 ldd r24, Y+2 ; 0x02
2734 fda: 80 68 ori r24, 0x80 ; 128
2735 fdc: 8a 83 std Y+2, r24 ; 0x02
2736 fde: 28 e0 ldi r18, 0x08 ; 8
2737 fe0: 82 2e mov r8, r18
2738 fe2: 91 2c mov r9, r1
2739 return FR_RW_ERROR;
2740 }
2741 fe4: c4 01 movw r24, r8
2742 fe6: e0 e1 ldi r30, 0x10 ; 16
2743 fe8: cd b7 in r28, 0x3d ; 61
2744 fea: de b7 in r29, 0x3e ; 62
2745 fec: 0c 94 48 11 jmp 0x2290 ; 0x2290 <__epilogue_restores__+0x4>
2746  
2747 00000ff0 <f_read>:
2748 FIL *fp, /* Pointer to the file object */
2749 void *buff, /* Pointer to data buffer */
2750 WORD btr, /* Number of bytes to read */
2751 WORD *br /* Pointer to number of bytes read */
2752 )
2753 {
2754 ff0: a0 e0 ldi r26, 0x00 ; 0
2755 ff2: b0 e0 ldi r27, 0x00 ; 0
2756 ff4: ee ef ldi r30, 0xFE ; 254
2757 ff6: f7 e0 ldi r31, 0x07 ; 7
2758 ff8: 0c 94 2c 11 jmp 0x2258 ; 0x2258 <__prologue_saves__+0x4>
2759 ffc: ec 01 movw r28, r24
2760 ffe: 8b 01 movw r16, r22
2761 1000: 7a 01 movw r14, r20
2762 1002: 39 01 movw r6, r18
2763 DWORD sect, remain;
2764 WORD rcnt;
2765 CLUST clust;
2766 BYTE cc, *rbuff = buff;
2767 FRESULT res;
2768 FATFS *fs = fp->fs;
2769 1004: 8c 80 ldd r8, Y+4 ; 0x04
2770 1006: 9d 80 ldd r9, Y+5 ; 0x05
2771  
2772  
2773 *br = 0;
2774 1008: f9 01 movw r30, r18
2775 100a: 11 82 std Z+1, r1 ; 0x01
2776 100c: 10 82 st Z, r1
2777 res = validate(fs, fp->id); /* Check validity of the object */
2778 100e: 68 81 ld r22, Y
2779 1010: 79 81 ldd r23, Y+1 ; 0x01
2780 1012: c4 01 movw r24, r8
2781 1014: 0e 94 43 03 call 0x686 ; 0x686 <validate>
2782 1018: 5c 01 movw r10, r24
2783 if (res) return res;
2784 101a: 89 2b or r24, r25
2785 101c: 09 f0 breq .+2 ; 0x1020 <f_read+0x30>
2786 101e: d9 c0 rjmp .+434 ; 0x11d2 <f_read+0x1e2>
2787 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
2788 1020: 8a 81 ldd r24, Y+2 ; 0x02
2789 1022: 88 23 and r24, r24
2790 1024: 0c f4 brge .+2 ; 0x1028 <f_read+0x38>
2791 1026: d2 c0 rjmp .+420 ; 0x11cc <f_read+0x1dc>
2792 if (!(fp->flag & FA_READ)) return FR_DENIED; /* Check access mode */
2793 1028: 80 fd sbrc r24, 0
2794 102a: 04 c0 rjmp .+8 ; 0x1034 <f_read+0x44>
2795 102c: 06 e0 ldi r16, 0x06 ; 6
2796 102e: a0 2e mov r10, r16
2797 1030: b1 2c mov r11, r1
2798 1032: cf c0 rjmp .+414 ; 0x11d2 <f_read+0x1e2>
2799 remain = fp->fsize - fp->fptr;
2800 1034: 2a 85 ldd r18, Y+10 ; 0x0a
2801 1036: 3b 85 ldd r19, Y+11 ; 0x0b
2802 1038: 4c 85 ldd r20, Y+12 ; 0x0c
2803 103a: 5d 85 ldd r21, Y+13 ; 0x0d
2804 103c: 8e 81 ldd r24, Y+6 ; 0x06
2805 103e: 9f 81 ldd r25, Y+7 ; 0x07
2806 1040: a8 85 ldd r26, Y+8 ; 0x08
2807 1042: b9 85 ldd r27, Y+9 ; 0x09
2808 1044: 28 1b sub r18, r24
2809 1046: 39 0b sbc r19, r25
2810 1048: 4a 0b sbc r20, r26
2811 104a: 5b 0b sbc r21, r27
2812 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
2813 104c: c7 01 movw r24, r14
2814 104e: aa 27 eor r26, r26
2815 1050: bb 27 eor r27, r27
2816 1052: 28 17 cp r18, r24
2817 1054: 39 07 cpc r19, r25
2818 1056: 4a 07 cpc r20, r26
2819 1058: 5b 07 cpc r21, r27
2820 105a: 08 f4 brcc .+2 ; 0x105e <f_read+0x6e>
2821 105c: 79 01 movw r14, r18
2822 )
2823 {
2824 DWORD sect, remain;
2825 WORD rcnt;
2826 CLUST clust;
2827 BYTE cc, *rbuff = buff;
2828 105e: 68 01 movw r12, r16
2829 }
2830 }
2831 if (!move_window(fp->curr_sect)) goto fr_error; /* Move sector window */
2832 rcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes from sector window */
2833 if (rcnt > btr) rcnt = btr;
2834 memcpy(rbuff, &fs->win[(WORD)fp->fptr % 512], rcnt);
2835 1060: 10 e2 ldi r17, 0x20 ; 32
2836 1062: 41 2e mov r4, r17
2837 1064: 51 2c mov r5, r1
2838 1066: 48 0c add r4, r8
2839 1068: 59 1c adc r5, r9
2840 106a: a8 c0 rjmp .+336 ; 0x11bc <f_read+0x1cc>
2841 remain = fp->fsize - fp->fptr;
2842 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
2843  
2844 for ( ; btr; /* Repeat until all data transferred */
2845 rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
2846 if ((fp->fptr % 512) == 0) { /* On the sector boundary */
2847 106c: 2e 81 ldd r18, Y+6 ; 0x06
2848 106e: 3f 81 ldd r19, Y+7 ; 0x07
2849 1070: 48 85 ldd r20, Y+8 ; 0x08
2850 1072: 59 85 ldd r21, Y+9 ; 0x09
2851 1074: da 01 movw r26, r20
2852 1076: c9 01 movw r24, r18
2853 1078: 91 70 andi r25, 0x01 ; 1
2854 107a: a0 70 andi r26, 0x00 ; 0
2855 107c: b0 70 andi r27, 0x00 ; 0
2856 107e: 00 97 sbiw r24, 0x00 ; 0
2857 1080: a1 05 cpc r26, r1
2858 1082: b1 05 cpc r27, r1
2859 1084: 09 f0 breq .+2 ; 0x1088 <f_read+0x98>
2860 1086: 66 c0 rjmp .+204 ; 0x1154 <f_read+0x164>
2861 if (--fp->sect_clust) { /* Decrement left sector counter */
2862 1088: 8b 81 ldd r24, Y+3 ; 0x03
2863 108a: 81 50 subi r24, 0x01 ; 1
2864 108c: 8b 83 std Y+3, r24 ; 0x03
2865 108e: 88 23 and r24, r24
2866 1090: 49 f0 breq .+18 ; 0x10a4 <f_read+0xb4>
2867 sect = fp->curr_sect + 1; /* Get current sector */
2868 1092: 2a 89 ldd r18, Y+18 ; 0x12
2869 1094: 3b 89 ldd r19, Y+19 ; 0x13
2870 1096: 4c 89 ldd r20, Y+20 ; 0x14
2871 1098: 5d 89 ldd r21, Y+21 ; 0x15
2872 109a: 2f 5f subi r18, 0xFF ; 255
2873 109c: 3f 4f sbci r19, 0xFF ; 255
2874 109e: 4f 4f sbci r20, 0xFF ; 255
2875 10a0: 5f 4f sbci r21, 0xFF ; 255
2876 10a2: 22 c0 rjmp .+68 ; 0x10e8 <f_read+0xf8>
2877 } else { /* On the cluster boundary, get next cluster */
2878 clust = (fp->fptr == 0) ?
2879 10a4: 21 15 cp r18, r1
2880 10a6: 31 05 cpc r19, r1
2881 10a8: 41 05 cpc r20, r1
2882 10aa: 51 05 cpc r21, r1
2883 10ac: 19 f4 brne .+6 ; 0x10b4 <f_read+0xc4>
2884 10ae: 2e 85 ldd r18, Y+14 ; 0x0e
2885 10b0: 3f 85 ldd r19, Y+15 ; 0x0f
2886 10b2: 05 c0 rjmp .+10 ; 0x10be <f_read+0xce>
2887 10b4: 88 89 ldd r24, Y+16 ; 0x10
2888 10b6: 99 89 ldd r25, Y+17 ; 0x11
2889 10b8: 0e 94 4f 04 call 0x89e ; 0x89e <get_cluster>
2890 10bc: 9c 01 movw r18, r24
2891 fp->org_clust : get_cluster(fp->curr_clust);
2892 if (clust < 2 || clust >= fs->max_clust)
2893 10be: 22 30 cpi r18, 0x02 ; 2
2894 10c0: 31 05 cpc r19, r1
2895 10c2: 08 f4 brcc .+2 ; 0x10c6 <f_read+0xd6>
2896 10c4: 80 c0 rjmp .+256 ; 0x11c6 <f_read+0x1d6>
2897 10c6: f4 01 movw r30, r8
2898 10c8: 86 89 ldd r24, Z+22 ; 0x16
2899 10ca: 97 89 ldd r25, Z+23 ; 0x17
2900 10cc: 28 17 cp r18, r24
2901 10ce: 39 07 cpc r19, r25
2902 10d0: 08 f0 brcs .+2 ; 0x10d4 <f_read+0xe4>
2903 10d2: 79 c0 rjmp .+242 ; 0x11c6 <f_read+0x1d6>
2904 goto fr_error;
2905 fp->curr_clust = clust; /* Current cluster */
2906 10d4: 39 8b std Y+17, r19 ; 0x11
2907 10d6: 28 8b std Y+16, r18 ; 0x10
2908 sect = clust2sect(clust); /* Get current sector */
2909 10d8: c9 01 movw r24, r18
2910 10da: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
2911 10de: 9b 01 movw r18, r22
2912 10e0: ac 01 movw r20, r24
2913 fp->sect_clust = fs->sects_clust; /* Re-initialize the left sector counter */
2914 10e2: f4 01 movw r30, r8
2915 10e4: 85 8d ldd r24, Z+29 ; 0x1d
2916 10e6: 8b 83 std Y+3, r24 ; 0x03
2917 }
2918 fp->curr_sect = sect; /* Update current sector */
2919 10e8: 2a 8b std Y+18, r18 ; 0x12
2920 10ea: 3b 8b std Y+19, r19 ; 0x13
2921 10ec: 4c 8b std Y+20, r20 ; 0x14
2922 10ee: 5d 8b std Y+21, r21 ; 0x15
2923 cc = btr / 512; /* When left bytes >= 512, */
2924 10f0: 87 01 movw r16, r14
2925 10f2: 01 2f mov r16, r17
2926 10f4: 11 27 eor r17, r17
2927 10f6: 06 95 lsr r16
2928 if (cc) { /* Read maximum contiguous sectors directly */
2929 10f8: 00 23 and r16, r16
2930 10fa: 61 f1 breq .+88 ; 0x1154 <f_read+0x164>
2931 10fc: 8b 81 ldd r24, Y+3 ; 0x03
2932 10fe: 10 2f mov r17, r16
2933 1100: 80 17 cp r24, r16
2934 1102: 08 f4 brcc .+2 ; 0x1106 <f_read+0x116>
2935 1104: 18 2f mov r17, r24
2936 if (cc > fp->sect_clust) cc = fp->sect_clust;
2937 if (disk_read(0, rbuff, sect, cc) != RES_OK)
2938 1106: 01 2f mov r16, r17
2939 1108: b6 01 movw r22, r12
2940 110a: 80 e0 ldi r24, 0x00 ; 0
2941 110c: 0e 94 51 0f call 0x1ea2 ; 0x1ea2 <disk_read>
2942 1110: 89 2b or r24, r25
2943 1112: 09 f0 breq .+2 ; 0x1116 <f_read+0x126>
2944 1114: 58 c0 rjmp .+176 ; 0x11c6 <f_read+0x1d6>
2945 goto fr_error;
2946 fp->sect_clust -= cc - 1;
2947 1116: 8b 81 ldd r24, Y+3 ; 0x03
2948 1118: 8f 5f subi r24, 0xFF ; 255
2949 111a: 81 1b sub r24, r17
2950 111c: 8b 83 std Y+3, r24 ; 0x03
2951 fp->curr_sect += cc - 1;
2952 111e: 81 2f mov r24, r17
2953 1120: 99 27 eor r25, r25
2954 1122: 01 97 sbiw r24, 0x01 ; 1
2955 1124: 9c 01 movw r18, r24
2956 1126: 44 27 eor r20, r20
2957 1128: 37 fd sbrc r19, 7
2958 112a: 40 95 com r20
2959 112c: 54 2f mov r21, r20
2960 112e: 8c 01 movw r16, r24
2961 1130: 0f 5f subi r16, 0xFF ; 255
2962 1132: 1f 4f sbci r17, 0xFF ; 255
2963 1134: 8a 89 ldd r24, Y+18 ; 0x12
2964 1136: 9b 89 ldd r25, Y+19 ; 0x13
2965 1138: ac 89 ldd r26, Y+20 ; 0x14
2966 113a: bd 89 ldd r27, Y+21 ; 0x15
2967 113c: 82 0f add r24, r18
2968 113e: 93 1f adc r25, r19
2969 1140: a4 1f adc r26, r20
2970 1142: b5 1f adc r27, r21
2971 1144: 8a 8b std Y+18, r24 ; 0x12
2972 1146: 9b 8b std Y+19, r25 ; 0x13
2973 1148: ac 8b std Y+20, r26 ; 0x14
2974 114a: bd 8b std Y+21, r27 ; 0x15
2975 rcnt = cc * 512; continue;
2976 114c: 10 2f mov r17, r16
2977 114e: 00 27 eor r16, r16
2978 1150: 11 0f add r17, r17
2979 1152: 1a c0 rjmp .+52 ; 0x1188 <f_read+0x198>
2980 }
2981 }
2982 if (!move_window(fp->curr_sect)) goto fr_error; /* Move sector window */
2983 1154: 6a 89 ldd r22, Y+18 ; 0x12
2984 1156: 7b 89 ldd r23, Y+19 ; 0x13
2985 1158: 8c 89 ldd r24, Y+20 ; 0x14
2986 115a: 9d 89 ldd r25, Y+21 ; 0x15
2987 115c: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
2988 1160: 88 23 and r24, r24
2989 1162: 89 f1 breq .+98 ; 0x11c6 <f_read+0x1d6>
2990 rcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes from sector window */
2991 1164: 6e 81 ldd r22, Y+6 ; 0x06
2992 1166: 7f 81 ldd r23, Y+7 ; 0x07
2993 1168: 71 70 andi r23, 0x01 ; 1
2994 116a: 80 e0 ldi r24, 0x00 ; 0
2995 116c: 92 e0 ldi r25, 0x02 ; 2
2996 116e: 86 1b sub r24, r22
2997 1170: 97 0b sbc r25, r23
2998 1172: 87 01 movw r16, r14
2999 1174: 8e 15 cp r24, r14
3000 1176: 9f 05 cpc r25, r15
3001 1178: 08 f4 brcc .+2 ; 0x117c <f_read+0x18c>
3002 117a: 8c 01 movw r16, r24
3003 if (rcnt > btr) rcnt = btr;
3004 memcpy(rbuff, &fs->win[(WORD)fp->fptr % 512], rcnt);
3005 117c: 64 0d add r22, r4
3006 117e: 75 1d adc r23, r5
3007 1180: a8 01 movw r20, r16
3008 1182: c6 01 movw r24, r12
3009 1184: 0e 94 a1 10 call 0x2142 ; 0x2142 <memcpy>
3010 if (!(fp->flag & FA_READ)) return FR_DENIED; /* Check access mode */
3011 remain = fp->fsize - fp->fptr;
3012 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
3013  
3014 for ( ; btr; /* Repeat until all data transferred */
3015 rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
3016 1188: c0 0e add r12, r16
3017 118a: d1 1e adc r13, r17
3018 118c: c8 01 movw r24, r16
3019 118e: aa 27 eor r26, r26
3020 1190: bb 27 eor r27, r27
3021 1192: 2e 81 ldd r18, Y+6 ; 0x06
3022 1194: 3f 81 ldd r19, Y+7 ; 0x07
3023 1196: 48 85 ldd r20, Y+8 ; 0x08
3024 1198: 59 85 ldd r21, Y+9 ; 0x09
3025 119a: 28 0f add r18, r24
3026 119c: 39 1f adc r19, r25
3027 119e: 4a 1f adc r20, r26
3028 11a0: 5b 1f adc r21, r27
3029 11a2: 2e 83 std Y+6, r18 ; 0x06
3030 11a4: 3f 83 std Y+7, r19 ; 0x07
3031 11a6: 48 87 std Y+8, r20 ; 0x08
3032 11a8: 59 87 std Y+9, r21 ; 0x09
3033 11aa: f3 01 movw r30, r6
3034 11ac: 80 81 ld r24, Z
3035 11ae: 91 81 ldd r25, Z+1 ; 0x01
3036 11b0: 80 0f add r24, r16
3037 11b2: 91 1f adc r25, r17
3038 11b4: 91 83 std Z+1, r25 ; 0x01
3039 11b6: 80 83 st Z, r24
3040 11b8: e0 1a sub r14, r16
3041 11ba: f1 0a sbc r15, r17
3042 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
3043 if (!(fp->flag & FA_READ)) return FR_DENIED; /* Check access mode */
3044 remain = fp->fsize - fp->fptr;
3045 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
3046  
3047 for ( ; btr; /* Repeat until all data transferred */
3048 11bc: e1 14 cp r14, r1
3049 11be: f1 04 cpc r15, r1
3050 11c0: 09 f0 breq .+2 ; 0x11c4 <f_read+0x1d4>
3051 11c2: 54 cf rjmp .-344 ; 0x106c <f_read+0x7c>
3052 11c4: 06 c0 rjmp .+12 ; 0x11d2 <f_read+0x1e2>
3053 }
3054  
3055 return FR_OK;
3056  
3057 fr_error: /* Abort this function due to an unrecoverable error */
3058 fp->flag |= FA__ERROR;
3059 11c6: 8a 81 ldd r24, Y+2 ; 0x02
3060 11c8: 80 68 ori r24, 0x80 ; 128
3061 11ca: 8a 83 std Y+2, r24 ; 0x02
3062 11cc: f8 e0 ldi r31, 0x08 ; 8
3063 11ce: af 2e mov r10, r31
3064 11d0: b1 2c mov r11, r1
3065 return FR_RW_ERROR;
3066 }
3067 11d2: c5 01 movw r24, r10
3068 11d4: e0 e1 ldi r30, 0x10 ; 16
3069 11d6: cd b7 in r28, 0x3d ; 61
3070 11d8: de b7 in r29, 0x3e ; 62
3071 11da: 0c 94 48 11 jmp 0x2290 ; 0x2290 <__epilogue_restores__+0x4>
3072  
3073 000011de <f_mount>:
3074  
3075 FRESULT f_mount (
3076 BYTE drv, /* Logical drive number to be mounted/unmounted */
3077 FATFS *fs /* Pointer to new file system object (NULL for unmount)*/
3078 )
3079 {
3080 11de: fb 01 movw r30, r22
3081 FATFS *fsobj;
3082  
3083  
3084 if (drv) return FR_INVALID_DRIVE;
3085 11e0: 88 23 and r24, r24
3086 11e2: 19 f0 breq .+6 ; 0x11ea <f_mount+0xc>
3087 11e4: 85 e0 ldi r24, 0x05 ; 5
3088 11e6: 90 e0 ldi r25, 0x00 ; 0
3089 11e8: 08 95 ret
3090 fsobj = FatFs;
3091 11ea: a0 91 0a 01 lds r26, 0x010A
3092 11ee: b0 91 0b 01 lds r27, 0x010B
3093 FatFs = fs;
3094 11f2: 70 93 0b 01 sts 0x010B, r23
3095 11f6: 60 93 0a 01 sts 0x010A, r22
3096 if (fsobj) memset(fsobj, 0, sizeof(FATFS));
3097 11fa: 10 97 sbiw r26, 0x00 ; 0
3098 11fc: 29 f0 breq .+10 ; 0x1208 <f_mount+0x2a>
3099 11fe: 80 e2 ldi r24, 0x20 ; 32
3100 1200: 92 e0 ldi r25, 0x02 ; 2
3101 1202: 1d 92 st X+, r1
3102 1204: 01 97 sbiw r24, 0x01 ; 1
3103 1206: e9 f7 brne .-6 ; 0x1202 <f_mount+0x24>
3104 if (fs) memset(fs, 0, sizeof(FATFS));
3105 1208: 30 97 sbiw r30, 0x00 ; 0
3106 120a: 19 f4 brne .+6 ; 0x1212 <f_mount+0x34>
3107 120c: 80 e0 ldi r24, 0x00 ; 0
3108 120e: 90 e0 ldi r25, 0x00 ; 0
3109 1210: 08 95 ret
3110 1212: 80 e2 ldi r24, 0x20 ; 32
3111 1214: 92 e0 ldi r25, 0x02 ; 2
3112 1216: 11 92 st Z+, r1
3113 1218: 01 97 sbiw r24, 0x01 ; 1
3114 121a: e9 f7 brne .-6 ; 0x1216 <f_mount+0x38>
3115 121c: 80 e0 ldi r24, 0x00 ; 0
3116 121e: 90 e0 ldi r25, 0x00 ; 0
3117  
3118 return FR_OK;
3119 }
3120 1220: 08 95 ret
3121  
3122 00001222 <check_fs>:
3123  
3124 static
3125 BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record or error */
3126 DWORD sect /* Sector# to check if it is a FAT boot record or not */
3127 )
3128 {
3129 1222: 0f 93 push r16
3130 1224: cf 93 push r28
3131 1226: df 93 push r29
3132 1228: 9b 01 movw r18, r22
3133 122a: ac 01 movw r20, r24
3134 FATFS *fs = FatFs;
3135 122c: c0 91 0a 01 lds r28, 0x010A
3136 1230: d0 91 0b 01 lds r29, 0x010B
3137  
3138 if (disk_read(0, fs->win, sect, 1) != RES_OK) /* Load boot record */
3139 1234: be 01 movw r22, r28
3140 1236: 60 5e subi r22, 0xE0 ; 224
3141 1238: 7f 4f sbci r23, 0xFF ; 255
3142 123a: 01 e0 ldi r16, 0x01 ; 1
3143 123c: 80 e0 ldi r24, 0x00 ; 0
3144 123e: 0e 94 51 0f call 0x1ea2 ; 0x1ea2 <disk_read>
3145 1242: 89 2b or r24, r25
3146 1244: d9 f4 brne .+54 ; 0x127c <check_fs+0x5a>
3147 return 2;
3148 if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature */
3149 1246: c2 5e subi r28, 0xE2 ; 226
3150 1248: dd 4f sbci r29, 0xFD ; 253
3151 124a: 88 81 ld r24, Y
3152 124c: 99 81 ldd r25, Y+1 ; 0x01
3153 124e: ce 51 subi r28, 0x1E ; 30
3154 1250: d2 40 sbci r29, 0x02 ; 2
3155 1252: 85 55 subi r24, 0x55 ; 85
3156 1254: 9a 4a sbci r25, 0xAA ; 170
3157 1256: 91 f4 brne .+36 ; 0x127c <check_fs+0x5a>
3158 1258: 00 e0 ldi r16, 0x00 ; 0
3159 return 2;
3160  
3161 if (!memcmp(&fs->win[BS_FilSysType], "FAT", 3)) /* Check FAT signature */
3162 125a: 43 e0 ldi r20, 0x03 ; 3
3163 125c: 50 e0 ldi r21, 0x00 ; 0
3164 125e: 60 e0 ldi r22, 0x00 ; 0
3165 1260: 71 e0 ldi r23, 0x01 ; 1
3166 1262: ce 01 movw r24, r28
3167 1264: 8a 5a subi r24, 0xAA ; 170
3168 1266: 9f 4f sbci r25, 0xFF ; 255
3169 1268: 0e 94 94 10 call 0x2128 ; 0x2128 <memcmp>
3170 126c: 89 2b or r24, r25
3171 126e: 09 f4 brne .+2 ; 0x1272 <check_fs+0x50>
3172 1270: 01 e0 ldi r16, 0x01 ; 1
3173 1272: 81 e0 ldi r24, 0x01 ; 1
3174 1274: 08 27 eor r16, r24
3175 1276: 80 2f mov r24, r16
3176 1278: 99 27 eor r25, r25
3177 127a: 02 c0 rjmp .+4 ; 0x1280 <check_fs+0x5e>
3178 127c: 82 e0 ldi r24, 0x02 ; 2
3179 127e: 90 e0 ldi r25, 0x00 ; 0
3180 1280: df 91 pop r29
3181 1282: cf 91 pop r28
3182 1284: 0f 91 pop r16
3183 1286: 08 95 ret
3184  
3185 00001288 <f_open>:
3186 FRESULT f_open (
3187 FIL *fp, /* Pointer to the blank file object */
3188 const char *path, /* Pointer to the file name */
3189 BYTE mode /* Access mode and file open mode flags */
3190 )
3191 {
3192 1288: ad e1 ldi r26, 0x1D ; 29
3193 128a: b0 e0 ldi r27, 0x00 ; 0
3194 128c: ea e4 ldi r30, 0x4A ; 74
3195 128e: f9 e0 ldi r31, 0x09 ; 9
3196 1290: 0c 94 2a 11 jmp 0x2254 ; 0x2254 <__prologue_saves__>
3197 1294: 9d 8f std Y+29, r25 ; 0x1d
3198 1296: 8c 8f std Y+28, r24 ; 0x1c
3199 1298: 6b 01 movw r12, r22
3200 FRESULT res;
3201 BYTE *dir;
3202 DIR dirobj;
3203 char fn[8+3+1];
3204 FATFS *fs = FatFs;
3205 129a: a0 90 0a 01 lds r10, 0x010A
3206 129e: b0 90 0b 01 lds r11, 0x010B
3207  
3208  
3209 fp->fs = NULL;
3210 12a2: fc 01 movw r30, r24
3211 12a4: 15 82 std Z+5, r1 ; 0x05
3212 12a6: 14 82 std Z+4, r1 ; 0x04
3213 #if !_FS_READONLY
3214 mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW);
3215 12a8: f4 2f mov r31, r20
3216 12aa: ff 71 andi r31, 0x1F ; 31
3217 12ac: fb 8f std Y+27, r31 ; 0x1b
3218 12ae: 03 c0 rjmp .+6 ; 0x12b6 <f_open+0x2e>
3219 const char *p = *path;
3220 FATFS *fs = FatFs;
3221  
3222  
3223  
3224 while (*p == ' ') p++; /* Strip leading spaces */
3225 12b0: 08 94 sec
3226 12b2: c1 1c adc r12, r1
3227 12b4: d1 1c adc r13, r1
3228 12b6: d6 01 movw r26, r12
3229 12b8: 8c 91 ld r24, X
3230 12ba: 80 32 cpi r24, 0x20 ; 32
3231 12bc: c9 f3 breq .-14 ; 0x12b0 <f_open+0x28>
3232 if (*p == '/') p++; /* Strip heading slash */
3233 12be: 8f 32 cpi r24, 0x2F ; 47
3234 12c0: 19 f4 brne .+6 ; 0x12c8 <f_open+0x40>
3235 12c2: 08 94 sec
3236 12c4: c1 1c adc r12, r1
3237 12c6: d1 1c adc r13, r1
3238 *path = p; /* Return pointer to the path name */
3239  
3240 /* Is the file system object registered? */
3241 if (!fs) return FR_NOT_ENABLED;
3242 12c8: a1 14 cp r10, r1
3243 12ca: b1 04 cpc r11, r1
3244 12cc: 09 f4 brne .+2 ; 0x12d0 <f_open+0x48>
3245 12ce: 15 c1 rjmp .+554 ; 0x14fa <f_open+0x272>
3246  
3247  
3248 fp->fs = NULL;
3249 #if !_FS_READONLY
3250 mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW);
3251 res = auto_mount(&path, (BYTE)(mode & (FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)));
3252 12d0: 1b 8d ldd r17, Y+27 ; 0x1b
3253 12d2: 1e 71 andi r17, 0x1E ; 30
3254  
3255 /* Is the file system object registered? */
3256 if (!fs) return FR_NOT_ENABLED;
3257  
3258 /* Chekck if the logical drive has been mounted or not */
3259 if (fs->fs_type) {
3260 12d4: f5 01 movw r30, r10
3261 12d6: 84 8d ldd r24, Z+28 ; 0x1c
3262 12d8: 88 23 and r24, r24
3263 12da: 61 f0 breq .+24 ; 0x12f4 <f_open+0x6c>
3264 stat = disk_status(0);
3265 12dc: 80 e0 ldi r24, 0x00 ; 0
3266 12de: 0e 94 bf 0d call 0x1b7e ; 0x1b7e <disk_status>
3267 if (!(stat & STA_NOINIT)) { /* If the physical drive is kept initialized */
3268 12e2: 99 27 eor r25, r25
3269 12e4: 80 fd sbrc r24, 0
3270 12e6: 06 c0 rjmp .+12 ; 0x12f4 <f_open+0x6c>
3271 #if !_FS_READONLY
3272 if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
3273 12e8: 11 23 and r17, r17
3274 12ea: 09 f4 brne .+2 ; 0x12ee <f_open+0x66>
3275 12ec: 29 c3 rjmp .+1618 ; 0x1940 <f_open+0x6b8>
3276 12ee: 82 fd sbrc r24, 2
3277 12f0: 07 c1 rjmp .+526 ; 0x1500 <f_open+0x278>
3278 12f2: 26 c3 rjmp .+1612 ; 0x1940 <f_open+0x6b8>
3279 }
3280 }
3281  
3282 /* The logical drive has not been mounted, following code attempts to mount the logical drive */
3283  
3284 memset(fs, 0, sizeof(FATFS)); /* Clean-up the file system object */
3285 12f4: 80 e2 ldi r24, 0x20 ; 32
3286 12f6: 92 e0 ldi r25, 0x02 ; 2
3287 12f8: d5 01 movw r26, r10
3288 12fa: 1d 92 st X+, r1
3289 12fc: 01 97 sbiw r24, 0x01 ; 1
3290 12fe: e9 f7 brne .-6 ; 0x12fa <f_open+0x72>
3291 stat = disk_initialize(0); /* Initialize low level disk I/O layer */
3292 1300: 80 e0 ldi r24, 0x00 ; 0
3293 1302: 0e 94 ae 0f call 0x1f5c ; 0x1f5c <disk_initialize>
3294 if (stat & STA_NOINIT) /* Check if the drive is ready */
3295 1306: 99 27 eor r25, r25
3296 1308: 80 ff sbrs r24, 0
3297 130a: 03 c0 rjmp .+6 ; 0x1312 <f_open+0x8a>
3298 130c: 21 e0 ldi r18, 0x01 ; 1
3299 130e: 30 e0 ldi r19, 0x00 ; 0
3300 1310: 45 c3 rjmp .+1674 ; 0x199c <f_open+0x714>
3301 return FR_NOT_READY;
3302 #if !_FS_READONLY
3303 if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
3304 1312: 11 23 and r17, r17
3305 1314: 11 f0 breq .+4 ; 0x131a <f_open+0x92>
3306 1316: 82 fd sbrc r24, 2
3307 1318: f3 c0 rjmp .+486 ; 0x1500 <f_open+0x278>
3308 return FR_WRITE_PROTECTED;
3309 #endif
3310  
3311 /* Search FAT partition on the drive */
3312 fmt = check_fs(bootsect = 0); /* Check sector 0 as an SFD format */
3313 131a: 60 e0 ldi r22, 0x00 ; 0
3314 131c: 70 e0 ldi r23, 0x00 ; 0
3315 131e: 80 e0 ldi r24, 0x00 ; 0
3316 1320: 90 e0 ldi r25, 0x00 ; 0
3317 1322: 0e 94 11 09 call 0x1222 ; 0x1222 <check_fs>
3318 if (fmt == 1) { /* Not a FAT boot record, it may be patitioned */
3319 1326: 81 30 cpi r24, 0x01 ; 1
3320 1328: 21 f0 breq .+8 ; 0x1332 <f_open+0xaa>
3321 132a: ee 24 eor r14, r14
3322 132c: ff 24 eor r15, r15
3323 132e: 87 01 movw r16, r14
3324 1330: 1e c0 rjmp .+60 ; 0x136e <f_open+0xe6>
3325 /* Check a partition listed in top of the partition table */
3326 if (fs->win[MBR_Table+4]) { /* Is the 1st partition existing? */
3327 1332: e2 ee ldi r30, 0xE2 ; 226
3328 1334: f1 e0 ldi r31, 0x01 ; 1
3329 1336: ae 0e add r10, r30
3330 1338: bf 1e adc r11, r31
3331 133a: d5 01 movw r26, r10
3332 133c: 8c 91 ld r24, X
3333 133e: ee e1 ldi r30, 0x1E ; 30
3334 1340: fe ef ldi r31, 0xFE ; 254
3335 1342: ae 0e add r10, r30
3336 1344: bf 1e adc r11, r31
3337 1346: 88 23 and r24, r24
3338 1348: 09 f4 brne .+2 ; 0x134c <f_open+0xc4>
3339 134a: dd c0 rjmp .+442 ; 0x1506 <f_open+0x27e>
3340 bootsect = LD_DWORD(&fs->win[MBR_Table+8]); /* Partition offset in LBA */
3341 134c: 26 ee ldi r18, 0xE6 ; 230
3342 134e: 31 e0 ldi r19, 0x01 ; 1
3343 1350: a2 0e add r10, r18
3344 1352: b3 1e adc r11, r19
3345 1354: d5 01 movw r26, r10
3346 1356: ed 90 ld r14, X+
3347 1358: fd 90 ld r15, X+
3348 135a: 0d 91 ld r16, X+
3349 135c: 1c 91 ld r17, X
3350 135e: ea e1 ldi r30, 0x1A ; 26
3351 1360: fe ef ldi r31, 0xFE ; 254
3352 1362: ae 0e add r10, r30
3353 1364: bf 1e adc r11, r31
3354 fmt = check_fs(bootsect); /* Check the partition */
3355 1366: c8 01 movw r24, r16
3356 1368: b7 01 movw r22, r14
3357 136a: 0e 94 11 09 call 0x1222 ; 0x1222 <check_fs>
3358 }
3359 }
3360 if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512) /* No valid FAT patition is found */
3361 136e: 88 23 and r24, r24
3362 1370: 09 f0 breq .+2 ; 0x1374 <f_open+0xec>
3363 1372: c9 c0 rjmp .+402 ; 0x1506 <f_open+0x27e>
3364 1374: f5 01 movw r30, r10
3365 1376: 83 a5 ldd r24, Z+43 ; 0x2b
3366 1378: 94 a5 ldd r25, Z+44 ; 0x2c
3367 137a: 80 50 subi r24, 0x00 ; 0
3368 137c: 92 40 sbci r25, 0x02 ; 2
3369 137e: 09 f0 breq .+2 ; 0x1382 <f_open+0xfa>
3370 1380: c2 c0 rjmp .+388 ; 0x1506 <f_open+0x27e>
3371 return FR_NO_FILESYSTEM;
3372  
3373 /* Initialize the file system object */
3374 fatsize = LD_WORD(&fs->win[BPB_FATSz16]); /* Number of sectors per FAT */
3375 1382: f5 01 movw r30, r10
3376 1384: 66 a9 ldd r22, Z+54 ; 0x36
3377 1386: 77 a9 ldd r23, Z+55 ; 0x37
3378 if (!fatsize) fatsize = LD_DWORD(&fs->win[BPB_FATSz32]);
3379 1388: 61 15 cp r22, r1
3380 138a: 71 05 cpc r23, r1
3381 138c: 19 f0 breq .+6 ; 0x1394 <f_open+0x10c>
3382 }
3383 if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512) /* No valid FAT patition is found */
3384 return FR_NO_FILESYSTEM;
3385  
3386 /* Initialize the file system object */
3387 fatsize = LD_WORD(&fs->win[BPB_FATSz16]); /* Number of sectors per FAT */
3388 138e: 88 27 eor r24, r24
3389 1390: 99 27 eor r25, r25
3390 1392: 0d c0 rjmp .+26 ; 0x13ae <f_open+0x126>
3391 if (!fatsize) fatsize = LD_DWORD(&fs->win[BPB_FATSz32]);
3392 1394: 24 e4 ldi r18, 0x44 ; 68
3393 1396: 30 e0 ldi r19, 0x00 ; 0
3394 1398: a2 0e add r10, r18
3395 139a: b3 1e adc r11, r19
3396 139c: d5 01 movw r26, r10
3397 139e: 6d 91 ld r22, X+
3398 13a0: 7d 91 ld r23, X+
3399 13a2: 8d 91 ld r24, X+
3400 13a4: 9c 91 ld r25, X
3401 13a6: ec eb ldi r30, 0xBC ; 188
3402 13a8: ff ef ldi r31, 0xFF ; 255
3403 13aa: ae 0e add r10, r30
3404 13ac: bf 1e adc r11, r31
3405 fs->sects_fat = (CLUST)fatsize;
3406 13ae: f5 01 movw r30, r10
3407 13b0: 75 8b std Z+21, r23 ; 0x15
3408 13b2: 64 8b std Z+20, r22 ; 0x14
3409 fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */
3410 13b4: 20 a9 ldd r18, Z+48 ; 0x30
3411 13b6: 26 8f std Z+30, r18 ; 0x1e
3412 fatsize *= fs->n_fats; /* (Number of sectors in FAT area) */
3413 13b8: 33 27 eor r19, r19
3414 13ba: 44 27 eor r20, r20
3415 13bc: 55 27 eor r21, r21
3416 13be: 0e 94 e9 10 call 0x21d2 ; 0x21d2 <__mulsi3>
3417 13c2: 3b 01 movw r6, r22
3418 13c4: 4c 01 movw r8, r24
3419 fs->fatbase = bootsect + LD_WORD(&fs->win[BPB_RsvdSecCnt]); /* FAT start sector (lba) */
3420 13c6: a5 01 movw r20, r10
3421 13c8: 42 5d subi r20, 0xD2 ; 210
3422 13ca: 5f 4f sbci r21, 0xFF ; 255
3423 13cc: f5 01 movw r30, r10
3424 13ce: 86 a5 ldd r24, Z+46 ; 0x2e
3425 13d0: 97 a5 ldd r25, Z+47 ; 0x2f
3426 13d2: aa 27 eor r26, r26
3427 13d4: bb 27 eor r27, r27
3428 13d6: e8 0e add r14, r24
3429 13d8: f9 1e adc r15, r25
3430 13da: 0a 1f adc r16, r26
3431 13dc: 1b 1f adc r17, r27
3432 13de: e0 86 std Z+8, r14 ; 0x08
3433 13e0: f1 86 std Z+9, r15 ; 0x09
3434 13e2: 02 87 std Z+10, r16 ; 0x0a
3435 13e4: 13 87 std Z+11, r17 ; 0x0b
3436 fs->sects_clust = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */
3437 13e6: 85 a5 ldd r24, Z+45 ; 0x2d
3438 13e8: 85 8f std Z+29, r24 ; 0x1d
3439 fs->n_rootdir = LD_WORD(&fs->win[BPB_RootEntCnt]); /* Nmuber of root directory entries */
3440 13ea: 21 a9 ldd r18, Z+49 ; 0x31
3441 13ec: 32 a9 ldd r19, Z+50 ; 0x32
3442 13ee: 33 83 std Z+3, r19 ; 0x03
3443 13f0: 22 83 std Z+2, r18 ; 0x02
3444 totalsect = LD_WORD(&fs->win[BPB_TotSec16]); /* Number of sectors on the file system */
3445 13f2: 63 a9 ldd r22, Z+51 ; 0x33
3446 13f4: 74 a9 ldd r23, Z+52 ; 0x34
3447 if (!totalsect) totalsect = LD_DWORD(&fs->win[BPB_TotSec32]);
3448 13f6: 61 15 cp r22, r1
3449 13f8: 71 05 cpc r23, r1
3450 13fa: 21 f0 breq .+8 ; 0x1404 <f_open+0x17c>
3451 fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */
3452 fatsize *= fs->n_fats; /* (Number of sectors in FAT area) */
3453 fs->fatbase = bootsect + LD_WORD(&fs->win[BPB_RsvdSecCnt]); /* FAT start sector (lba) */
3454 fs->sects_clust = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */
3455 fs->n_rootdir = LD_WORD(&fs->win[BPB_RootEntCnt]); /* Nmuber of root directory entries */
3456 totalsect = LD_WORD(&fs->win[BPB_TotSec16]); /* Number of sectors on the file system */
3457 13fc: 7b 01 movw r14, r22
3458 13fe: 00 27 eor r16, r16
3459 1400: 11 27 eor r17, r17
3460 1402: 0d c0 rjmp .+26 ; 0x141e <f_open+0x196>
3461 if (!totalsect) totalsect = LD_DWORD(&fs->win[BPB_TotSec32]);
3462 1404: 80 e4 ldi r24, 0x40 ; 64
3463 1406: 90 e0 ldi r25, 0x00 ; 0
3464 1408: a8 0e add r10, r24
3465 140a: b9 1e adc r11, r25
3466 140c: d5 01 movw r26, r10
3467 140e: ed 90 ld r14, X+
3468 1410: fd 90 ld r15, X+
3469 1412: 0d 91 ld r16, X+
3470 1414: 1c 91 ld r17, X
3471 1416: e0 ec ldi r30, 0xC0 ; 192
3472 1418: ff ef ldi r31, 0xFF ; 255
3473 141a: ae 0e add r10, r30
3474 141c: bf 1e adc r11, r31
3475 fs->max_clust = maxclust = (totalsect /* Last cluster# + 1 */
3476 141e: da 01 movw r26, r20
3477 1420: 8d 91 ld r24, X+
3478 1422: 9c 91 ld r25, X
3479 1424: aa 27 eor r26, r26
3480 1426: bb 27 eor r27, r27
3481 1428: e8 1a sub r14, r24
3482 142a: f9 0a sbc r15, r25
3483 142c: 0a 0b sbc r16, r26
3484 142e: 1b 0b sbc r17, r27
3485 1430: e6 18 sub r14, r6
3486 1432: f7 08 sbc r15, r7
3487 1434: 08 09 sbc r16, r8
3488 1436: 19 09 sbc r17, r9
3489 1438: e4 e0 ldi r30, 0x04 ; 4
3490 143a: 36 95 lsr r19
3491 143c: 27 95 ror r18
3492 143e: ea 95 dec r30
3493 1440: e1 f7 brne .-8 ; 0x143a <f_open+0x1b2>
3494 1442: c9 01 movw r24, r18
3495 1444: aa 27 eor r26, r26
3496 1446: bb 27 eor r27, r27
3497 1448: e8 1a sub r14, r24
3498 144a: f9 0a sbc r15, r25
3499 144c: 0a 0b sbc r16, r26
3500 144e: 1b 0b sbc r17, r27
3501 1450: f5 01 movw r30, r10
3502 1452: 25 8d ldd r18, Z+29 ; 0x1d
3503 1454: 33 27 eor r19, r19
3504 1456: 44 27 eor r20, r20
3505 1458: 55 27 eor r21, r21
3506 145a: c8 01 movw r24, r16
3507 145c: b7 01 movw r22, r14
3508 145e: 0e 94 08 11 call 0x2210 ; 0x2210 <__udivmodsi4>
3509 1462: 2e 5f subi r18, 0xFE ; 254
3510 1464: 3f 4f sbci r19, 0xFF ; 255
3511 1466: 4f 4f sbci r20, 0xFF ; 255
3512 1468: 5f 4f sbci r21, 0xFF ; 255
3513 146a: f5 01 movw r30, r10
3514 146c: 37 8b std Z+23, r19 ; 0x17
3515 146e: 26 8b std Z+22, r18 ; 0x16
3516 - LD_WORD(&fs->win[BPB_RsvdSecCnt]) - fatsize - fs->n_rootdir / 16
3517 ) / fs->sects_clust + 2;
3518  
3519 fmt = FS_FAT12; /* Determine the FAT sub type */
3520 if (maxclust > 0xFF7) fmt = FS_FAT16;
3521 1470: 28 3f cpi r18, 0xF8 ; 248
3522 1472: ff e0 ldi r31, 0x0F ; 15
3523 1474: 3f 07 cpc r19, r31
3524 1476: f0 e0 ldi r31, 0x00 ; 0
3525 1478: 4f 07 cpc r20, r31
3526 147a: f0 e0 ldi r31, 0x00 ; 0
3527 147c: 5f 07 cpc r21, r31
3528 147e: 10 f4 brcc .+4 ; 0x1484 <f_open+0x1fc>
3529 1480: 61 e0 ldi r22, 0x01 ; 1
3530 1482: 06 c0 rjmp .+12 ; 0x1490 <f_open+0x208>
3531 if (maxclust > 0xFFF7)
3532 1484: 28 5f subi r18, 0xF8 ; 248
3533 1486: 3f 4f sbci r19, 0xFF ; 255
3534 1488: 40 40 sbci r20, 0x00 ; 0
3535 148a: 50 40 sbci r21, 0x00 ; 0
3536 148c: e0 f5 brcc .+120 ; 0x1506 <f_open+0x27e>
3537 148e: 62 e0 ldi r22, 0x02 ; 2
3538 fmt = FS_FAT32;
3539 if (fmt == FS_FAT32)
3540 fs->dirbase = LD_DWORD(&fs->win[BPB_RootClus]); /* Root directory start cluster */
3541 else
3542 #endif
3543 fs->dirbase = fs->fatbase + fatsize; /* Root directory start sector (lba) */
3544 1490: f5 01 movw r30, r10
3545 1492: 20 85 ldd r18, Z+8 ; 0x08
3546 1494: 31 85 ldd r19, Z+9 ; 0x09
3547 1496: 42 85 ldd r20, Z+10 ; 0x0a
3548 1498: 53 85 ldd r21, Z+11 ; 0x0b
3549 149a: d4 01 movw r26, r8
3550 149c: c3 01 movw r24, r6
3551 149e: 82 0f add r24, r18
3552 14a0: 93 1f adc r25, r19
3553 14a2: a4 1f adc r26, r20
3554 14a4: b5 1f adc r27, r21
3555 14a6: 84 87 std Z+12, r24 ; 0x0c
3556 14a8: 95 87 std Z+13, r25 ; 0x0d
3557 14aa: a6 87 std Z+14, r26 ; 0x0e
3558 14ac: b7 87 std Z+15, r27 ; 0x0f
3559 fs->database = fs->fatbase + fatsize + fs->n_rootdir / 16; /* Data start sector (lba) */
3560 14ae: 82 81 ldd r24, Z+2 ; 0x02
3561 14b0: 93 81 ldd r25, Z+3 ; 0x03
3562 14b2: 74 e0 ldi r23, 0x04 ; 4
3563 14b4: 96 95 lsr r25
3564 14b6: 87 95 ror r24
3565 14b8: 7a 95 dec r23
3566 14ba: e1 f7 brne .-8 ; 0x14b4 <f_open+0x22c>
3567 14bc: aa 27 eor r26, r26
3568 14be: bb 27 eor r27, r27
3569 14c0: 82 0f add r24, r18
3570 14c2: 93 1f adc r25, r19
3571 14c4: a4 1f adc r26, r20
3572 14c6: b5 1f adc r27, r21
3573 14c8: 86 0d add r24, r6
3574 14ca: 97 1d adc r25, r7
3575 14cc: a8 1d adc r26, r8
3576 14ce: b9 1d adc r27, r9
3577 14d0: 80 8b std Z+16, r24 ; 0x10
3578 14d2: 91 8b std Z+17, r25 ; 0x11
3579 14d4: a2 8b std Z+18, r26 ; 0x12
3580 14d6: b3 8b std Z+19, r27 ; 0x13
3581 fs->fs_type = fmt; /* FAT sub-type */
3582 14d8: 64 8f std Z+28, r22 ; 0x1c
3583  
3584 #if !_FS_READONLY
3585 fs->free_clust = (CLUST)0xFFFFFFFF;
3586 14da: 8f ef ldi r24, 0xFF ; 255
3587 14dc: 9f ef ldi r25, 0xFF ; 255
3588 14de: 93 8f std Z+27, r25 ; 0x1b
3589 14e0: 82 8f std Z+26, r24 ; 0x1a
3590 fs->free_clust = LD_DWORD(&fs->win[FSI_Free_Count]);
3591 }
3592 }
3593 #endif
3594 #endif
3595 fs->id = ++fsid; /* File system mount ID */
3596 14e2: 80 91 0c 01 lds r24, 0x010C
3597 14e6: 90 91 0d 01 lds r25, 0x010D
3598 14ea: 01 96 adiw r24, 0x01 ; 1
3599 14ec: 90 93 0d 01 sts 0x010D, r25
3600 14f0: 80 93 0c 01 sts 0x010C, r24
3601 14f4: 91 83 std Z+1, r25 ; 0x01
3602 14f6: 80 83 st Z, r24
3603 14f8: 23 c2 rjmp .+1094 ; 0x1940 <f_open+0x6b8>
3604 14fa: 2a e0 ldi r18, 0x0A ; 10
3605 14fc: 30 e0 ldi r19, 0x00 ; 0
3606 14fe: 4e c2 rjmp .+1180 ; 0x199c <f_open+0x714>
3607 1500: 29 e0 ldi r18, 0x09 ; 9
3608 1502: 30 e0 ldi r19, 0x00 ; 0
3609 1504: 4b c2 rjmp .+1174 ; 0x199c <f_open+0x714>
3610 1506: 2b e0 ldi r18, 0x0B ; 11
3611 1508: 30 e0 ldi r19, 0x00 ; 0
3612 150a: 48 c2 rjmp .+1168 ; 0x199c <f_open+0x714>
3613 150c: 36 01 movw r6, r12
3614 )
3615 {
3616 BYTE n, t, c, a, b;
3617  
3618  
3619 memset(dirname, ' ', 8+3); /* Fill buffer with spaces */
3620 150e: 4e 01 movw r8, r28
3621 1510: 08 94 sec
3622 1512: 81 1c adc r8, r1
3623 1514: 91 1c adc r9, r1
3624 for (;;) {
3625 ds = make_dirfile(&path, fn); /* Get a paragraph into fn[] */
3626 if (ds == 1) return FR_INVALID_NAME;
3627 for (;;) {
3628 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
3629 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
3630 1516: 50 e2 ldi r21, 0x20 ; 32
3631 1518: 45 2e mov r4, r21
3632 151a: 51 2c mov r5, r1
3633 151c: 4e 0e add r4, r30
3634 151e: 5f 1e adc r5, r31
3635 if (dptr[DIR_Name] == 0) /* Has it reached to end of dir? */
3636 return !ds ? FR_NO_FILE : FR_NO_PATH;
3637 if (dptr[DIR_Name] != 0xE5 /* Matched? */
3638 && !(dptr[DIR_Attr] & AM_VOL)
3639 && !memcmp(&dptr[DIR_Name], fn, 8+3) ) break;
3640 if (!next_dir_entry(dirobj)) /* Next directory pointer */
3641 1520: 4d e0 ldi r20, 0x0D ; 13
3642 1522: 24 2e mov r2, r20
3643 1524: 31 2c mov r3, r1
3644 1526: 2c 0e add r2, r28
3645 1528: 3d 1e adc r3, r29
3646 )
3647 {
3648 BYTE n, t, c, a, b;
3649  
3650  
3651 memset(dirname, ' ', 8+3); /* Fill buffer with spaces */
3652 152a: 4b e0 ldi r20, 0x0B ; 11
3653 152c: 50 e0 ldi r21, 0x00 ; 0
3654 152e: 60 e2 ldi r22, 0x20 ; 32
3655 1530: 70 e0 ldi r23, 0x00 ; 0
3656 1532: c4 01 movw r24, r8
3657 1534: 0e 94 aa 10 call 0x2154 ; 0x2154 <memset>
3658 1538: 40 e0 ldi r20, 0x00 ; 0
3659 153a: 68 e0 ldi r22, 0x08 ; 8
3660 153c: 30 e0 ldi r19, 0x00 ; 0
3661 153e: 58 e1 ldi r21, 0x18 ; 24
3662 1540: 02 c0 rjmp .+4 ; 0x1546 <f_open+0x2be>
3663 1542: 48 e0 ldi r20, 0x08 ; 8
3664 1544: 6b e0 ldi r22, 0x0B ; 11
3665 a = 0; b = 0x18; /* NT flag */
3666 n = 0; t = 8;
3667 for (;;) {
3668 c = *(*path)++;
3669 1546: d3 01 movw r26, r6
3670 1548: 2d 91 ld r18, X+
3671 154a: 3d 01 movw r6, r26
3672 if (c == '\0' || c == '/') { /* Reached to end of str or directory separator */
3673 154c: 22 23 and r18, r18
3674 154e: 11 f0 breq .+4 ; 0x1554 <f_open+0x2cc>
3675 1550: 2f 32 cpi r18, 0x2F ; 47
3676 1552: 51 f4 brne .+20 ; 0x1568 <f_open+0x2e0>
3677 if (n == 0) break;
3678 1554: 44 23 and r20, r20
3679 1556: 09 f4 brne .+2 ; 0x155a <f_open+0x2d2>
3680 1558: 43 c0 rjmp .+134 ; 0x15e0 <f_open+0x358>
3681 dirname[11] = _USE_NTFLAG ? (a & b) : 0;
3682 155a: 53 23 and r21, r19
3683 155c: 5c 87 std Y+12, r21 ; 0x0c
3684 return c;
3685 155e: 82 2f mov r24, r18
3686 1560: 99 27 eor r25, r25
3687 1562: 87 fd sbrc r24, 7
3688 1564: 90 95 com r25
3689 1566: 3e c0 rjmp .+124 ; 0x15e4 <f_open+0x35c>
3690  
3691 memset(dirname, ' ', 8+3); /* Fill buffer with spaces */
3692 a = 0; b = 0x18; /* NT flag */
3693 n = 0; t = 8;
3694 for (;;) {
3695 c = *(*path)++;
3696 1568: 92 2f mov r25, r18
3697 if (c == '\0' || c == '/') { /* Reached to end of str or directory separator */
3698 if (n == 0) break;
3699 dirname[11] = _USE_NTFLAG ? (a & b) : 0;
3700 return c;
3701 }
3702 if (c <= ' ' || c == 0x7F) break; /* Reject invisible chars */
3703 156a: 21 32 cpi r18, 0x21 ; 33
3704 156c: c8 f1 brcs .+114 ; 0x15e0 <f_open+0x358>
3705 156e: 2f 37 cpi r18, 0x7F ; 127
3706 1570: b9 f1 breq .+110 ; 0x15e0 <f_open+0x358>
3707 if (c == '.') {
3708 1572: 2e 32 cpi r18, 0x2E ; 46
3709 1574: 39 f4 brne .+14 ; 0x1584 <f_open+0x2fc>
3710 if (!(a & 1) && n >= 1 && n <= 8) { /* Enter extension part */
3711 1576: 30 fd sbrc r19, 0
3712 1578: 33 c0 rjmp .+102 ; 0x15e0 <f_open+0x358>
3713 157a: 44 23 and r20, r20
3714 157c: 89 f1 breq .+98 ; 0x15e0 <f_open+0x358>
3715 157e: 49 30 cpi r20, 0x09 ; 9
3716 1580: 00 f3 brcs .-64 ; 0x1542 <f_open+0x2ba>
3717 1582: 2e c0 rjmp .+92 ; 0x15e0 <f_open+0x358>
3718 (c >= 0xE0 && c <= 0xFC))) {
3719 if (n == 0 && c == 0xE5) /* Change heading \xE5 to \x05 */
3720 c = 0x05;
3721 a ^= 1; goto md_l2;
3722 }
3723 if (c == '"') break; /* Reject " */
3724 1584: 22 32 cpi r18, 0x22 ; 34
3725 1586: 61 f1 breq .+88 ; 0x15e0 <f_open+0x358>
3726 if (c <= ')') goto md_l1; /* Accept ! # $ % & ' ( ) */
3727 1588: 2a 32 cpi r18, 0x2A ; 42
3728 158a: 08 f1 brcs .+66 ; 0x15ce <f_open+0x346>
3729 if (c <= ',') break; /* Reject * + , */
3730 158c: 2d 32 cpi r18, 0x2D ; 45
3731 158e: 40 f1 brcs .+80 ; 0x15e0 <f_open+0x358>
3732 if (c <= '9') goto md_l1; /* Accept - 0-9 */
3733 1590: 2a 33 cpi r18, 0x3A ; 58
3734 1592: e8 f0 brcs .+58 ; 0x15ce <f_open+0x346>
3735 if (c <= '?') break; /* Reject : ; < = > ? */
3736 1594: 20 34 cpi r18, 0x40 ; 64
3737 1596: 20 f1 brcs .+72 ; 0x15e0 <f_open+0x358>
3738 if (!(a & 1)) { /* These checks are not applied to S-JIS 2nd byte */
3739 1598: 30 fd sbrc r19, 0
3740 159a: 19 c0 rjmp .+50 ; 0x15ce <f_open+0x346>
3741 if (c == '|') break; /* Reject | */
3742 159c: 2c 37 cpi r18, 0x7C ; 124
3743 159e: 01 f1 breq .+64 ; 0x15e0 <f_open+0x358>
3744 if (c >= '[' && c <= ']') break;/* Reject [ \ ] */
3745 15a0: 82 2f mov r24, r18
3746 15a2: 8b 55 subi r24, 0x5B ; 91
3747 15a4: 83 30 cpi r24, 0x03 ; 3
3748 15a6: e0 f0 brcs .+56 ; 0x15e0 <f_open+0x358>
3749 if (_USE_NTFLAG && c >= 'A' && c <= 'Z')
3750 15a8: 86 5e subi r24, 0xE6 ; 230
3751 15aa: 8a 31 cpi r24, 0x1A ; 26
3752 15ac: 28 f4 brcc .+10 ; 0x15b8 <f_open+0x330>
3753 (t == 8) ? (b &= ~0x08) : (b &= ~0x10);
3754 15ae: 68 30 cpi r22, 0x08 ; 8
3755 15b0: 11 f4 brne .+4 ; 0x15b6 <f_open+0x32e>
3756 15b2: 57 7f andi r21, 0xF7 ; 247
3757 15b4: 01 c0 rjmp .+2 ; 0x15b8 <f_open+0x330>
3758 15b6: 5f 7e andi r21, 0xEF ; 239
3759 if (c >= 'a' && c <= 'z') { /* Convert to upper case */
3760 15b8: 82 2f mov r24, r18
3761 15ba: 81 56 subi r24, 0x61 ; 97
3762 15bc: 8a 31 cpi r24, 0x1A ; 26
3763 15be: 38 f4 brcc .+14 ; 0x15ce <f_open+0x346>
3764 c -= 0x20;
3765 15c0: 92 2f mov r25, r18
3766 15c2: 90 52 subi r25, 0x20 ; 32
3767 if (_USE_NTFLAG) (t == 8) ? (a |= 0x08) : (a |= 0x10);
3768 15c4: 68 30 cpi r22, 0x08 ; 8
3769 15c6: 11 f4 brne .+4 ; 0x15cc <f_open+0x344>
3770 15c8: 38 60 ori r19, 0x08 ; 8
3771 15ca: 01 c0 rjmp .+2 ; 0x15ce <f_open+0x346>
3772 15cc: 30 61 ori r19, 0x10 ; 16
3773 }
3774 }
3775 md_l1:
3776 a &= ~1;
3777 md_l2:
3778 if (n >= t) break;
3779 15ce: 46 17 cp r20, r22
3780 15d0: 38 f4 brcc .+14 ; 0x15e0 <f_open+0x358>
3781 c -= 0x20;
3782 if (_USE_NTFLAG) (t == 8) ? (a |= 0x08) : (a |= 0x10);
3783 }
3784 }
3785 md_l1:
3786 a &= ~1;
3787 15d2: 3e 7f andi r19, 0xFE ; 254
3788 md_l2:
3789 if (n >= t) break;
3790 dirname[n++] = c;
3791 15d4: f4 01 movw r30, r8
3792 15d6: e4 0f add r30, r20
3793 15d8: f1 1d adc r31, r1
3794 15da: 90 83 st Z, r25
3795 15dc: 4f 5f subi r20, 0xFF ; 255
3796 15de: b3 cf rjmp .-154 ; 0x1546 <f_open+0x2be>
3797 15e0: 81 e0 ldi r24, 0x01 ; 1
3798 15e2: 90 e0 ldi r25, 0x00 ; 0
3799 if (*path == '\0') { /* Null path means the root directory */
3800 *dir = NULL; return FR_OK;
3801 }
3802  
3803 for (;;) {
3804 ds = make_dirfile(&path, fn); /* Get a paragraph into fn[] */
3805 15e4: d8 2e mov r13, r24
3806 if (ds == 1) return FR_INVALID_NAME;
3807 15e6: b1 e0 ldi r27, 0x01 ; 1
3808 15e8: 8b 17 cp r24, r27
3809 15ea: 19 f4 brne .+6 ; 0x15f2 <f_open+0x36a>
3810 15ec: 24 e0 ldi r18, 0x04 ; 4
3811 15ee: 30 e0 ldi r19, 0x00 ; 0
3812 15f0: 55 c0 rjmp .+170 ; 0x169c <f_open+0x414>
3813 for (;;) {
3814 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
3815 15f2: 6f 89 ldd r22, Y+23 ; 0x17
3816 15f4: 78 8d ldd r23, Y+24 ; 0x18
3817 15f6: 89 8d ldd r24, Y+25 ; 0x19
3818 15f8: 9a 8d ldd r25, Y+26 ; 0x1a
3819 15fa: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
3820 15fe: 88 23 and r24, r24
3821 1600: 19 f4 brne .+6 ; 0x1608 <f_open+0x380>
3822 1602: 28 e0 ldi r18, 0x08 ; 8
3823 1604: 30 e0 ldi r19, 0x00 ; 0
3824 1606: 4a c0 rjmp .+148 ; 0x169c <f_open+0x414>
3825 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
3826 1608: 0f 85 ldd r16, Y+15 ; 0x0f
3827 160a: 18 89 ldd r17, Y+16 ; 0x10
3828 160c: 0f 70 andi r16, 0x0F ; 15
3829 160e: 10 70 andi r17, 0x00 ; 0
3830 1610: 35 e0 ldi r19, 0x05 ; 5
3831 1612: 00 0f add r16, r16
3832 1614: 11 1f adc r17, r17
3833 1616: 3a 95 dec r19
3834 1618: e1 f7 brne .-8 ; 0x1612 <f_open+0x38a>
3835 161a: 04 0d add r16, r4
3836 161c: 15 1d adc r17, r5
3837 if (dptr[DIR_Name] == 0) /* Has it reached to end of dir? */
3838 161e: f8 01 movw r30, r16
3839 1620: 80 81 ld r24, Z
3840 1622: 88 23 and r24, r24
3841 1624: a9 f0 breq .+42 ; 0x1650 <f_open+0x3c8>
3842 return !ds ? FR_NO_FILE : FR_NO_PATH;
3843 if (dptr[DIR_Name] != 0xE5 /* Matched? */
3844 1626: 85 3e cpi r24, 0xE5 ; 229
3845 1628: 71 f0 breq .+28 ; 0x1646 <f_open+0x3be>
3846 162a: f8 01 movw r30, r16
3847 162c: 83 85 ldd r24, Z+11 ; 0x0b
3848 162e: e8 2e mov r14, r24
3849 1630: ff 24 eor r15, r15
3850 1632: e3 fc sbrc r14, 3
3851 1634: 08 c0 rjmp .+16 ; 0x1646 <f_open+0x3be>
3852 1636: 4b e0 ldi r20, 0x0B ; 11
3853 1638: 50 e0 ldi r21, 0x00 ; 0
3854 163a: b4 01 movw r22, r8
3855 163c: c8 01 movw r24, r16
3856 163e: 0e 94 94 10 call 0x2128 ; 0x2128 <memcmp>
3857 1642: 89 2b or r24, r25
3858 1644: 51 f0 breq .+20 ; 0x165a <f_open+0x3d2>
3859 && !(dptr[DIR_Attr] & AM_VOL)
3860 && !memcmp(&dptr[DIR_Name], fn, 8+3) ) break;
3861 if (!next_dir_entry(dirobj)) /* Next directory pointer */
3862 1646: c1 01 movw r24, r2
3863 1648: 0e 94 cb 04 call 0x996 ; 0x996 <next_dir_entry>
3864 164c: 88 23 and r24, r24
3865 164e: 89 f6 brne .-94 ; 0x15f2 <f_open+0x36a>
3866 return !ds ? FR_NO_FILE : FR_NO_PATH;
3867 1650: dd 20 and r13, r13
3868 1652: 59 f4 brne .+22 ; 0x166a <f_open+0x3e2>
3869 1654: 22 e0 ldi r18, 0x02 ; 2
3870 1656: 30 e0 ldi r19, 0x00 ; 0
3871 1658: 21 c0 rjmp .+66 ; 0x169c <f_open+0x414>
3872 }
3873 if (!ds) { *dir = dptr; return FR_OK; } /* Matched with end of path */
3874 165a: dd 20 and r13, r13
3875 165c: 21 f4 brne .+8 ; 0x1666 <f_open+0x3de>
3876 165e: 68 01 movw r12, r16
3877 1660: 20 e0 ldi r18, 0x00 ; 0
3878 1662: 30 e0 ldi r19, 0x00 ; 0
3879 1664: 1b c0 rjmp .+54 ; 0x169c <f_open+0x414>
3880 if (!(dptr[DIR_Attr] & AM_DIR)) return FR_NO_PATH; /* Cannot trace because it is a file */
3881 1666: e4 fc sbrc r14, 4
3882 1668: 03 c0 rjmp .+6 ; 0x1670 <f_open+0x3e8>
3883 166a: 23 e0 ldi r18, 0x03 ; 3
3884 166c: 30 e0 ldi r19, 0x00 ; 0
3885 166e: 16 c0 rjmp .+44 ; 0x169c <f_open+0x414>
3886 clust = /* Get cluster# of the directory */
3887 1670: f8 01 movw r30, r16
3888 1672: 82 8d ldd r24, Z+26 ; 0x1a
3889 1674: 93 8d ldd r25, Z+27 ; 0x1b
3890 #if _FAT32
3891 ((DWORD)LD_WORD(&dptr[DIR_FstClusHI]) << 16) |
3892 #endif
3893 LD_WORD(&dptr[DIR_FstClusLO]);
3894 dirobj->clust = dirobj->sclust = clust; /* Restart scannig with the new directory */
3895 1676: 9c 8b std Y+20, r25 ; 0x14
3896 1678: 8b 8b std Y+19, r24 ; 0x13
3897 167a: 9e 8b std Y+22, r25 ; 0x16
3898 167c: 8d 8b std Y+21, r24 ; 0x15
3899 dirobj->sect = clust2sect(clust);
3900 167e: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
3901 1682: 6f 8b std Y+23, r22 ; 0x17
3902 1684: 78 8f std Y+24, r23 ; 0x18
3903 1686: 89 8f std Y+25, r24 ; 0x19
3904 1688: 9a 8f std Y+26, r25 ; 0x1a
3905 dirobj->index = 2;
3906 168a: 82 e0 ldi r24, 0x02 ; 2
3907 168c: 90 e0 ldi r25, 0x00 ; 0
3908 168e: 98 8b std Y+16, r25 ; 0x10
3909 1690: 8f 87 std Y+15, r24 ; 0x0f
3910 1692: 4b cf rjmp .-362 ; 0x152a <f_open+0x2a2>
3911 1694: 20 e0 ldi r18, 0x00 ; 0
3912 1696: 30 e0 ldi r19, 0x00 ; 0
3913 1698: cc 24 eor r12, r12
3914 169a: dd 24 eor r13, r13
3915 /* Trace the file path */
3916 res = trace_path(&dirobj, fn, path, &dir); /* Trace the file path */
3917  
3918 #if !_FS_READONLY
3919 /* Create or Open a File */
3920 if (mode & (FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)) {
3921 169c: fb 8d ldd r31, Y+27 ; 0x1b
3922 169e: 4f 2f mov r20, r31
3923 16a0: 55 27 eor r21, r21
3924 16a2: ca 01 movw r24, r20
3925 16a4: 8c 71 andi r24, 0x1C ; 28
3926 16a6: 90 70 andi r25, 0x00 ; 0
3927 16a8: 89 2b or r24, r25
3928 16aa: 09 f4 brne .+2 ; 0x16ae <f_open+0x426>
3929 16ac: fe c0 rjmp .+508 ; 0x18aa <f_open+0x622>
3930 CLUST rs;
3931 DWORD dw;
3932 if (res != FR_OK) { /* No file, create new */
3933 16ae: 21 15 cp r18, r1
3934 16b0: 31 05 cpc r19, r1
3935 16b2: 09 f4 brne .+2 ; 0x16b6 <f_open+0x42e>
3936 16b4: 8f c0 rjmp .+286 ; 0x17d4 <f_open+0x54c>
3937 if (res != FR_NO_FILE) return res;
3938 16b6: 22 30 cpi r18, 0x02 ; 2
3939 16b8: 31 05 cpc r19, r1
3940 16ba: 09 f0 breq .+2 ; 0x16be <f_open+0x436>
3941 16bc: 6f c1 rjmp .+734 ; 0x199c <f_open+0x714>
3942 )
3943 {
3944 CLUST clust;
3945 DWORD sector;
3946 BYTE c, n, *dptr;
3947 FATFS *fs = FatFs;
3948 16be: 60 90 0a 01 lds r6, 0x010A
3949 16c2: 70 90 0b 01 lds r7, 0x010B
3950  
3951  
3952 /* Re-initialize directory object */
3953 clust = dirobj->sclust;
3954 16c6: 0b 89 ldd r16, Y+19 ; 0x13
3955 16c8: 1c 89 ldd r17, Y+20 ; 0x14
3956 if (clust) { /* Dyanmic directory table */
3957 16ca: 01 15 cp r16, r1
3958 16cc: 11 05 cpc r17, r1
3959 16ce: 51 f0 breq .+20 ; 0x16e4 <f_open+0x45c>
3960 dirobj->clust = clust;
3961 16d0: 1e 8b std Y+22, r17 ; 0x16
3962 16d2: 0d 8b std Y+21, r16 ; 0x15
3963 dirobj->sect = clust2sect(clust);
3964 16d4: c8 01 movw r24, r16
3965 16d6: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
3966 16da: 6f 8b std Y+23, r22 ; 0x17
3967 16dc: 78 8f std Y+24, r23 ; 0x18
3968 16de: 89 8f std Y+25, r24 ; 0x19
3969 16e0: 9a 8f std Y+26, r25 ; 0x1a
3970 16e2: 09 c0 rjmp .+18 ; 0x16f6 <f_open+0x46e>
3971 } else { /* Static directory table */
3972 dirobj->sect = fs->dirbase;
3973 16e4: f3 01 movw r30, r6
3974 16e6: 84 85 ldd r24, Z+12 ; 0x0c
3975 16e8: 95 85 ldd r25, Z+13 ; 0x0d
3976 16ea: a6 85 ldd r26, Z+14 ; 0x0e
3977 16ec: b7 85 ldd r27, Z+15 ; 0x0f
3978 16ee: 8f 8b std Y+23, r24 ; 0x17
3979 16f0: 98 8f std Y+24, r25 ; 0x18
3980 16f2: a9 8f std Y+25, r26 ; 0x19
3981 16f4: ba 8f std Y+26, r27 ; 0x1a
3982 }
3983 dirobj->index = 0;
3984 16f6: 18 8a std Y+16, r1 ; 0x10
3985 16f8: 1f 86 std Y+15, r1 ; 0x0f
3986  
3987 do {
3988 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
3989 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
3990 16fa: 20 e2 ldi r18, 0x20 ; 32
3991 16fc: e2 2e mov r14, r18
3992 16fe: f1 2c mov r15, r1
3993 1700: e6 0c add r14, r6
3994 1702: f7 1c adc r15, r7
3995 c = dptr[DIR_Name];
3996 if (c == 0 || c == 0xE5) { /* Found an empty entry! */
3997 *dir = dptr; return FR_OK;
3998 }
3999 } while (next_dir_entry(dirobj)); /* Next directory pointer */
4000 1704: 9d e0 ldi r25, 0x0D ; 13
4001 1706: 49 2e mov r4, r25
4002 1708: 51 2c mov r5, r1
4003 170a: 4c 0e add r4, r28
4004 170c: 5d 1e adc r5, r29
4005 dirobj->sect = fs->dirbase;
4006 }
4007 dirobj->index = 0;
4008  
4009 do {
4010 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
4011 170e: 6f 89 ldd r22, Y+23 ; 0x17
4012 1710: 78 8d ldd r23, Y+24 ; 0x18
4013 1712: 89 8d ldd r24, Y+25 ; 0x19
4014 1714: 9a 8d ldd r25, Y+26 ; 0x1a
4015 1716: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
4016 171a: 88 23 and r24, r24
4017 171c: 09 f4 brne .+2 ; 0x1720 <f_open+0x498>
4018 171e: 0a c1 rjmp .+532 ; 0x1934 <f_open+0x6ac>
4019 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
4020 1720: 47 01 movw r8, r14
4021 1722: cf 84 ldd r12, Y+15 ; 0x0f
4022 1724: d8 88 ldd r13, Y+16 ; 0x10
4023 1726: ff e0 ldi r31, 0x0F ; 15
4024 1728: cf 22 and r12, r31
4025 172a: dd 24 eor r13, r13
4026 172c: 85 e0 ldi r24, 0x05 ; 5
4027 172e: cc 0c add r12, r12
4028 1730: dd 1c adc r13, r13
4029 1732: 8a 95 dec r24
4030 1734: e1 f7 brne .-8 ; 0x172e <f_open+0x4a6>
4031 1736: ce 0c add r12, r14
4032 1738: df 1c adc r13, r15
4033 c = dptr[DIR_Name];
4034 173a: d6 01 movw r26, r12
4035 173c: 8c 91 ld r24, X
4036 if (c == 0 || c == 0xE5) { /* Found an empty entry! */
4037 173e: 88 23 and r24, r24
4038 1740: 09 f4 brne .+2 ; 0x1744 <f_open+0x4bc>
4039 1742: 18 c1 rjmp .+560 ; 0x1974 <f_open+0x6ec>
4040 1744: 85 3e cpi r24, 0xE5 ; 229
4041 1746: 09 f4 brne .+2 ; 0x174a <f_open+0x4c2>
4042 1748: 15 c1 rjmp .+554 ; 0x1974 <f_open+0x6ec>
4043 *dir = dptr; return FR_OK;
4044 }
4045 } while (next_dir_entry(dirobj)); /* Next directory pointer */
4046 174a: c2 01 movw r24, r4
4047 174c: 0e 94 cb 04 call 0x996 ; 0x996 <next_dir_entry>
4048 1750: 88 23 and r24, r24
4049 1752: e9 f6 brne .-70 ; 0x170e <f_open+0x486>
4050 /* Reached to end of the directory table */
4051  
4052 /* Abort when static table or could not stretch dynamic table */
4053 if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
4054 1754: 01 2b or r16, r17
4055 1756: 09 f4 brne .+2 ; 0x175a <f_open+0x4d2>
4056 1758: ea c0 rjmp .+468 ; 0x192e <f_open+0x6a6>
4057 175a: 8d 89 ldd r24, Y+21 ; 0x15
4058 175c: 9e 89 ldd r25, Y+22 ; 0x16
4059 175e: 0e 94 25 05 call 0xa4a ; 0xa4a <create_chain>
4060 1762: 8c 01 movw r16, r24
4061 1764: 00 97 sbiw r24, 0x00 ; 0
4062 1766: 09 f4 brne .+2 ; 0x176a <f_open+0x4e2>
4063 1768: e2 c0 rjmp .+452 ; 0x192e <f_open+0x6a6>
4064 if (clust == 1 || !move_window(0)) return FR_RW_ERROR;
4065 176a: 01 97 sbiw r24, 0x01 ; 1
4066 176c: 09 f4 brne .+2 ; 0x1770 <f_open+0x4e8>
4067 176e: e2 c0 rjmp .+452 ; 0x1934 <f_open+0x6ac>
4068 1770: 60 e0 ldi r22, 0x00 ; 0
4069 1772: 70 e0 ldi r23, 0x00 ; 0
4070 1774: 80 e0 ldi r24, 0x00 ; 0
4071 1776: 90 e0 ldi r25, 0x00 ; 0
4072 1778: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
4073 177c: 88 23 and r24, r24
4074 177e: 09 f4 brne .+2 ; 0x1782 <f_open+0x4fa>
4075 1780: d9 c0 rjmp .+434 ; 0x1934 <f_open+0x6ac>
4076  
4077 fs->winsect = sector = clust2sect(clust); /* Cleanup the expanded table */
4078 1782: c8 01 movw r24, r16
4079 1784: 0e 94 18 03 call 0x630 ; 0x630 <clust2sect>
4080 1788: 6b 01 movw r12, r22
4081 178a: 7c 01 movw r14, r24
4082 178c: f3 01 movw r30, r6
4083 178e: 64 83 std Z+4, r22 ; 0x04
4084 1790: 75 83 std Z+5, r23 ; 0x05
4085 1792: 86 83 std Z+6, r24 ; 0x06
4086 1794: 97 83 std Z+7, r25 ; 0x07
4087 memset(fs->win, 0, 512);
4088 1796: 80 e0 ldi r24, 0x00 ; 0
4089 1798: 92 e0 ldi r25, 0x02 ; 2
4090 179a: d4 01 movw r26, r8
4091 179c: 1d 92 st X+, r1
4092 179e: 01 97 sbiw r24, 0x01 ; 1
4093 17a0: e9 f7 brne .-6 ; 0x179c <f_open+0x514>
4094 for (n = fs->sects_clust; n; n--) {
4095 17a2: 15 8d ldd r17, Z+29 ; 0x1d
4096 17a4: 10 c0 rjmp .+32 ; 0x17c6 <f_open+0x53e>
4097 if (disk_write(0, fs->win, sector, 1) != RES_OK)
4098 17a6: 01 e0 ldi r16, 0x01 ; 1
4099 17a8: a7 01 movw r20, r14
4100 17aa: 96 01 movw r18, r12
4101 17ac: b4 01 movw r22, r8
4102 17ae: 80 e0 ldi r24, 0x00 ; 0
4103 17b0: 0e 94 d3 0e call 0x1da6 ; 0x1da6 <disk_write>
4104 17b4: 89 2b or r24, r25
4105 17b6: 09 f0 breq .+2 ; 0x17ba <f_open+0x532>
4106 17b8: bd c0 rjmp .+378 ; 0x1934 <f_open+0x6ac>
4107 return FR_RW_ERROR;
4108 sector++;
4109 17ba: 08 94 sec
4110 17bc: c1 1c adc r12, r1
4111 17be: d1 1c adc r13, r1
4112 17c0: e1 1c adc r14, r1
4113 17c2: f1 1c adc r15, r1
4114 if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
4115 if (clust == 1 || !move_window(0)) return FR_RW_ERROR;
4116  
4117 fs->winsect = sector = clust2sect(clust); /* Cleanup the expanded table */
4118 memset(fs->win, 0, 512);
4119 for (n = fs->sects_clust; n; n--) {
4120 17c4: 11 50 subi r17, 0x01 ; 1
4121 17c6: 11 23 and r17, r17
4122 17c8: 71 f7 brne .-36 ; 0x17a6 <f_open+0x51e>
4123 if (disk_write(0, fs->win, sector, 1) != RES_OK)
4124 return FR_RW_ERROR;
4125 sector++;
4126 }
4127 fs->winflag = 1;
4128 17ca: 81 e0 ldi r24, 0x01 ; 1
4129 17cc: f3 01 movw r30, r6
4130 17ce: 87 8f std Z+31, r24 ; 0x1f
4131 17d0: 64 01 movw r12, r8
4132 17d2: d0 c0 rjmp .+416 ; 0x1974 <f_open+0x6ec>
4133 memset(dir, 0, 32); /* Initialize the new entry */
4134 memcpy(&dir[DIR_Name], fn, 8+3);
4135 dir[DIR_NTres] = fn[11];
4136 mode |= FA_CREATE_ALWAYS;
4137 } else { /* Any object is already existing */
4138 if (mode & FA_CREATE_NEW) /* Cannot create new */
4139 17d4: 42 ff sbrs r20, 2
4140 17d6: 03 c0 rjmp .+6 ; 0x17de <f_open+0x556>
4141 17d8: 27 e0 ldi r18, 0x07 ; 7
4142 17da: 30 e0 ldi r19, 0x00 ; 0
4143 17dc: df c0 rjmp .+446 ; 0x199c <f_open+0x714>
4144 return FR_EXIST;
4145 if (dir == NULL || (dir[DIR_Attr] & (AM_RDO|AM_DIR))) /* Cannot overwrite (R/O or DIR) */
4146 17de: c1 14 cp r12, r1
4147 17e0: d1 04 cpc r13, r1
4148 17e2: 09 f4 brne .+2 ; 0x17e6 <f_open+0x55e>
4149 17e4: a4 c0 rjmp .+328 ; 0x192e <f_open+0x6a6>
4150 17e6: f6 01 movw r30, r12
4151 17e8: 83 85 ldd r24, Z+11 ; 0x0b
4152 17ea: 81 71 andi r24, 0x11 ; 17
4153 17ec: 09 f0 breq .+2 ; 0x17f0 <f_open+0x568>
4154 17ee: 9f c0 rjmp .+318 ; 0x192e <f_open+0x6a6>
4155 return FR_DENIED;
4156 if (mode & FA_CREATE_ALWAYS) { /* Resize it to zero */
4157 17f0: 43 ff sbrs r20, 3
4158 17f2: 46 c0 rjmp .+140 ; 0x1880 <f_open+0x5f8>
4159 #if _FAT32
4160 rs = ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) | LD_WORD(&dir[DIR_FstClusLO]);
4161 ST_WORD(&dir[DIR_FstClusHI], 0);
4162 #else
4163 rs = LD_WORD(&dir[DIR_FstClusLO]);
4164 17f4: 82 8c ldd r8, Z+26 ; 0x1a
4165 17f6: 93 8c ldd r9, Z+27 ; 0x1b
4166 #endif
4167 ST_WORD(&dir[DIR_FstClusLO], 0); /* cluster = 0 */
4168 17f8: 13 8e std Z+27, r1 ; 0x1b
4169 17fa: 12 8e std Z+26, r1 ; 0x1a
4170 ST_DWORD(&dir[DIR_FileSize], 0); /* size = 0 */
4171 17fc: 14 8e std Z+28, r1 ; 0x1c
4172 17fe: 15 8e std Z+29, r1 ; 0x1d
4173 1800: 16 8e std Z+30, r1 ; 0x1e
4174 1802: 17 8e std Z+31, r1 ; 0x1f
4175 fs->winflag = 1;
4176 1804: 81 e0 ldi r24, 0x01 ; 1
4177 1806: f5 01 movw r30, r10
4178 1808: 87 8f std Z+31, r24 ; 0x1f
4179 dw = fs->winsect; /* Remove the cluster chain */
4180 180a: 24 80 ldd r2, Z+4 ; 0x04
4181 180c: 35 80 ldd r3, Z+5 ; 0x05
4182 180e: 46 80 ldd r4, Z+6 ; 0x06
4183 1810: 57 80 ldd r5, Z+7 ; 0x07
4184 BOOL remove_chain ( /* TRUE: successful, FALSE: failed */
4185 CLUST clust /* Cluster# to remove chain from */
4186 )
4187 {
4188 CLUST nxt;
4189 FATFS *fs = FatFs;
4190 1812: e0 90 0a 01 lds r14, 0x010A
4191 1816: f0 90 0b 01 lds r15, 0x010B
4192 181a: 84 01 movw r16, r8
4193 181c: 1b c0 rjmp .+54 ; 0x1854 <f_open+0x5cc>
4194  
4195  
4196 while (clust >= 2 && clust < fs->max_clust) {
4197 nxt = get_cluster(clust);
4198 181e: c8 01 movw r24, r16
4199 1820: 0e 94 4f 04 call 0x89e ; 0x89e <get_cluster>
4200 1824: 3c 01 movw r6, r24
4201 if (nxt == 1) return FALSE;
4202 1826: 01 97 sbiw r24, 0x01 ; 1
4203 1828: 09 f4 brne .+2 ; 0x182c <f_open+0x5a4>
4204 182a: 84 c0 rjmp .+264 ; 0x1934 <f_open+0x6ac>
4205 if (!put_cluster(clust, 0)) return FALSE;
4206 182c: 60 e0 ldi r22, 0x00 ; 0
4207 182e: 70 e0 ldi r23, 0x00 ; 0
4208 1830: c8 01 movw r24, r16
4209 1832: 0e 94 c1 03 call 0x782 ; 0x782 <put_cluster>
4210 1836: 88 23 and r24, r24
4211 1838: 09 f4 brne .+2 ; 0x183c <f_open+0x5b4>
4212 183a: 7c c0 rjmp .+248 ; 0x1934 <f_open+0x6ac>
4213 if (fs->free_clust != (CLUST)0xFFFFFFFF) {
4214 183c: f7 01 movw r30, r14
4215 183e: 82 8d ldd r24, Z+26 ; 0x1a
4216 1840: 93 8d ldd r25, Z+27 ; 0x1b
4217 1842: ff ef ldi r31, 0xFF ; 255
4218 1844: 8f 3f cpi r24, 0xFF ; 255
4219 1846: 9f 07 cpc r25, r31
4220 1848: 21 f0 breq .+8 ; 0x1852 <f_open+0x5ca>
4221 fs->free_clust++;
4222 184a: 01 96 adiw r24, 0x01 ; 1
4223 184c: f7 01 movw r30, r14
4224 184e: 93 8f std Z+27, r25 ; 0x1b
4225 1850: 82 8f std Z+26, r24 ; 0x1a
4226 1852: 83 01 movw r16, r6
4227 {
4228 CLUST nxt;
4229 FATFS *fs = FatFs;
4230  
4231  
4232 while (clust >= 2 && clust < fs->max_clust) {
4233 1854: 02 30 cpi r16, 0x02 ; 2
4234 1856: 11 05 cpc r17, r1
4235 1858: 30 f0 brcs .+12 ; 0x1866 <f_open+0x5de>
4236 185a: f7 01 movw r30, r14
4237 185c: 86 89 ldd r24, Z+22 ; 0x16
4238 185e: 97 89 ldd r25, Z+23 ; 0x17
4239 1860: 08 17 cp r16, r24
4240 1862: 19 07 cpc r17, r25
4241 1864: e0 f2 brcs .-72 ; 0x181e <f_open+0x596>
4242 #endif
4243 ST_WORD(&dir[DIR_FstClusLO], 0); /* cluster = 0 */
4244 ST_DWORD(&dir[DIR_FileSize], 0); /* size = 0 */
4245 fs->winflag = 1;
4246 dw = fs->winsect; /* Remove the cluster chain */
4247 if (!remove_chain(rs) || !move_window(dw))
4248 1866: c2 01 movw r24, r4
4249 1868: b1 01 movw r22, r2
4250 186a: 0e 94 55 03 call 0x6aa ; 0x6aa <move_window>
4251 186e: 88 23 and r24, r24
4252 1870: 09 f4 brne .+2 ; 0x1874 <f_open+0x5ec>
4253 1872: 60 c0 rjmp .+192 ; 0x1934 <f_open+0x6ac>
4254 return FR_RW_ERROR;
4255 fs->last_clust = rs - 1; /* Reuse the cluster hole */
4256 1874: 08 94 sec
4257 1876: 81 08 sbc r8, r1
4258 1878: 91 08 sbc r9, r1
4259 187a: f5 01 movw r30, r10
4260 187c: 91 8e std Z+25, r9 ; 0x19
4261 187e: 80 8e std Z+24, r8 ; 0x18
4262 }
4263 }
4264 if (mode & FA_CREATE_ALWAYS) {
4265 1880: fb 8d ldd r31, Y+27 ; 0x1b
4266 1882: f3 ff sbrs r31, 3
4267 1884: 23 c0 rjmp .+70 ; 0x18cc <f_open+0x644>
4268 dir[DIR_Attr] = AM_ARC; /* New attribute */
4269 1886: 80 e2 ldi r24, 0x20 ; 32
4270 1888: f6 01 movw r30, r12
4271 188a: 83 87 std Z+11, r24 ; 0x0b
4272 dw = get_fattime();
4273 188c: 0e 94 bb 00 call 0x176 ; 0x176 <get_fattime>
4274 ST_DWORD(&dir[DIR_WrtTime], dw); /* Updated time */
4275 1890: f6 01 movw r30, r12
4276 1892: 66 8b std Z+22, r22 ; 0x16
4277 1894: 77 8b std Z+23, r23 ; 0x17
4278 1896: 80 8f std Z+24, r24 ; 0x18
4279 1898: 91 8f std Z+25, r25 ; 0x19
4280 ST_DWORD(&dir[DIR_CrtTime], dw); /* Created time */
4281 189a: 66 87 std Z+14, r22 ; 0x0e
4282 189c: 77 87 std Z+15, r23 ; 0x0f
4283 189e: 80 8b std Z+16, r24 ; 0x10
4284 18a0: 91 8b std Z+17, r25 ; 0x11
4285 fs->winflag = 1;
4286 18a2: 81 e0 ldi r24, 0x01 ; 1
4287 18a4: f5 01 movw r30, r10
4288 18a6: 87 8f std Z+31, r24 ; 0x1f
4289 18a8: 11 c0 rjmp .+34 ; 0x18cc <f_open+0x644>
4290 }
4291 }
4292 /* Open a File */
4293 else {
4294 #endif /* !_FS_READONLY */
4295 if (res != FR_OK) return res; /* Trace failed */
4296 18aa: 21 15 cp r18, r1
4297 18ac: 31 05 cpc r19, r1
4298 18ae: 09 f0 breq .+2 ; 0x18b2 <f_open+0x62a>
4299 18b0: 75 c0 rjmp .+234 ; 0x199c <f_open+0x714>
4300 if (dir == NULL || (dir[DIR_Attr] & AM_DIR)) /* It is a directory */
4301 18b2: c1 14 cp r12, r1
4302 18b4: d1 04 cpc r13, r1
4303 18b6: 09 f4 brne .+2 ; 0x18ba <f_open+0x632>
4304 18b8: 40 c0 rjmp .+128 ; 0x193a <f_open+0x6b2>
4305 18ba: f6 01 movw r30, r12
4306 18bc: 83 85 ldd r24, Z+11 ; 0x0b
4307 18be: 99 27 eor r25, r25
4308 18c0: 84 fd sbrc r24, 4
4309 18c2: 3b c0 rjmp .+118 ; 0x193a <f_open+0x6b2>
4310 return FR_NO_FILE;
4311 #if !_FS_READONLY
4312 if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */
4313 18c4: 41 ff sbrs r20, 1
4314 18c6: 02 c0 rjmp .+4 ; 0x18cc <f_open+0x644>
4315 18c8: 80 fd sbrc r24, 0
4316 18ca: 31 c0 rjmp .+98 ; 0x192e <f_open+0x6a6>
4317 return FR_DENIED;
4318 }
4319  
4320 fp->dir_sect = fs->winsect; /* Pointer to the directory entry */
4321 18cc: f5 01 movw r30, r10
4322 18ce: 84 81 ldd r24, Z+4 ; 0x04
4323 18d0: 95 81 ldd r25, Z+5 ; 0x05
4324 18d2: a6 81 ldd r26, Z+6 ; 0x06
4325 18d4: b7 81 ldd r27, Z+7 ; 0x07
4326 18d6: ec 8d ldd r30, Y+28 ; 0x1c
4327 18d8: fd 8d ldd r31, Y+29 ; 0x1d
4328 18da: 86 8b std Z+22, r24 ; 0x16
4329 18dc: 97 8b std Z+23, r25 ; 0x17
4330 18de: a0 8f std Z+24, r26 ; 0x18
4331 18e0: b1 8f std Z+25, r27 ; 0x19
4332 fp->dir_ptr = dir;
4333 18e2: d3 8e std Z+27, r13 ; 0x1b
4334 18e4: c2 8e std Z+26, r12 ; 0x1a
4335 #endif
4336 fp->flag = mode; /* File access mode */
4337 18e6: 2b 8d ldd r18, Y+27 ; 0x1b
4338 18e8: 22 83 std Z+2, r18 ; 0x02
4339 fp->org_clust = /* File start cluster */
4340 18ea: f6 01 movw r30, r12
4341 18ec: 82 8d ldd r24, Z+26 ; 0x1a
4342 18ee: 93 8d ldd r25, Z+27 ; 0x1b
4343 18f0: ec 8d ldd r30, Y+28 ; 0x1c
4344 18f2: fd 8d ldd r31, Y+29 ; 0x1d
4345 18f4: 97 87 std Z+15, r25 ; 0x0f
4346 18f6: 86 87 std Z+14, r24 ; 0x0e
4347 #if _FAT32
4348 ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) |
4349 #endif
4350 LD_WORD(&dir[DIR_FstClusLO]);
4351 fp->fsize = LD_DWORD(&dir[DIR_FileSize]); /* File size */
4352 18f8: f6 01 movw r30, r12
4353 18fa: 84 8d ldd r24, Z+28 ; 0x1c
4354 18fc: 95 8d ldd r25, Z+29 ; 0x1d
4355 18fe: a6 8d ldd r26, Z+30 ; 0x1e
4356 1900: b7 8d ldd r27, Z+31 ; 0x1f
4357 1902: ec 8d ldd r30, Y+28 ; 0x1c
4358 1904: fd 8d ldd r31, Y+29 ; 0x1d
4359 1906: 82 87 std Z+10, r24 ; 0x0a
4360 1908: 93 87 std Z+11, r25 ; 0x0b
4361 190a: a4 87 std Z+12, r26 ; 0x0c
4362 190c: b5 87 std Z+13, r27 ; 0x0d
4363 fp->fptr = 0; /* File ptr */
4364 190e: 16 82 std Z+6, r1 ; 0x06
4365 1910: 17 82 std Z+7, r1 ; 0x07
4366 1912: 10 86 std Z+8, r1 ; 0x08
4367 1914: 11 86 std Z+9, r1 ; 0x09
4368 fp->sect_clust = 1; /* Sector counter */
4369 1916: 81 e0 ldi r24, 0x01 ; 1
4370 1918: 83 83 std Z+3, r24 ; 0x03
4371 fp->fs = fs; fp->id = fs->id; /* Owner file system object of the file */
4372 191a: b5 82 std Z+5, r11 ; 0x05
4373 191c: a4 82 std Z+4, r10 ; 0x04
4374 191e: d5 01 movw r26, r10
4375 1920: 8d 91 ld r24, X+
4376 1922: 9c 91 ld r25, X
4377 1924: 91 83 std Z+1, r25 ; 0x01
4378 1926: 80 83 st Z, r24
4379 1928: 20 e0 ldi r18, 0x00 ; 0
4380 192a: 30 e0 ldi r19, 0x00 ; 0
4381 192c: 37 c0 rjmp .+110 ; 0x199c <f_open+0x714>
4382  
4383 return FR_OK;
4384 192e: 26 e0 ldi r18, 0x06 ; 6
4385 1930: 30 e0 ldi r19, 0x00 ; 0
4386 1932: 34 c0 rjmp .+104 ; 0x199c <f_open+0x714>
4387 1934: 28 e0 ldi r18, 0x08 ; 8
4388 1936: 30 e0 ldi r19, 0x00 ; 0
4389 1938: 31 c0 rjmp .+98 ; 0x199c <f_open+0x714>
4390 193a: 22 e0 ldi r18, 0x02 ; 2
4391 193c: 30 e0 ldi r19, 0x00 ; 0
4392 193e: 2e c0 rjmp .+92 ; 0x199c <f_open+0x714>
4393 )
4394 {
4395 CLUST clust;
4396 char ds;
4397 BYTE *dptr = NULL;
4398 FATFS *fs = FatFs;
4399 1940: e0 91 0a 01 lds r30, 0x010A
4400 1944: f0 91 0b 01 lds r31, 0x010B
4401  
4402 /* Initialize directory object */
4403 clust = fs->dirbase;
4404 1948: 84 85 ldd r24, Z+12 ; 0x0c
4405 194a: 95 85 ldd r25, Z+13 ; 0x0d
4406 dirobj->clust = dirobj->sclust = clust;
4407 dirobj->sect = clust2sect(clust);
4408 } else
4409 #endif
4410 {
4411 dirobj->clust = dirobj->sclust = 0;
4412 194c: 1c 8a std Y+20, r1 ; 0x14
4413 194e: 1b 8a std Y+19, r1 ; 0x13
4414 1950: 1e 8a std Y+22, r1 ; 0x16
4415 1952: 1d 8a std Y+21, r1 ; 0x15
4416 dirobj->sect = clust;
4417 1954: aa 27 eor r26, r26
4418 1956: bb 27 eor r27, r27
4419 1958: 8f 8b std Y+23, r24 ; 0x17
4420 195a: 98 8f std Y+24, r25 ; 0x18
4421 195c: a9 8f std Y+25, r26 ; 0x19
4422 195e: ba 8f std Y+26, r27 ; 0x1a
4423 }
4424 dirobj->index = 0;
4425 1960: 18 8a std Y+16, r1 ; 0x10
4426 1962: 1f 86 std Y+15, r1 ; 0x0f
4427 dirobj->fs = fs;
4428 1964: fa 8b std Y+18, r31 ; 0x12
4429 1966: e9 8b std Y+17, r30 ; 0x11
4430  
4431 if (*path == '\0') { /* Null path means the root directory */
4432 1968: d6 01 movw r26, r12
4433 196a: 8c 91 ld r24, X
4434 196c: 88 23 and r24, r24
4435 196e: 09 f4 brne .+2 ; 0x1972 <f_open+0x6ea>
4436 1970: 91 ce rjmp .-734 ; 0x1694 <f_open+0x40c>
4437 1972: cc cd rjmp .-1128 ; 0x150c <f_open+0x284>
4438 DWORD dw;
4439 if (res != FR_OK) { /* No file, create new */
4440 if (res != FR_NO_FILE) return res;
4441 res = reserve_direntry(&dirobj, &dir);
4442 if (res != FR_OK) return res;
4443 memset(dir, 0, 32); /* Initialize the new entry */
4444 1974: 80 e2 ldi r24, 0x20 ; 32
4445 1976: f6 01 movw r30, r12
4446 1978: 11 92 st Z+, r1
4447 197a: 8a 95 dec r24
4448 197c: e9 f7 brne .-6 ; 0x1978 <f_open+0x6f0>
4449 memcpy(&dir[DIR_Name], fn, 8+3);
4450 197e: f6 01 movw r30, r12
4451 1980: de 01 movw r26, r28
4452 1982: 11 96 adiw r26, 0x01 ; 1
4453 1984: 8b e0 ldi r24, 0x0B ; 11
4454 1986: 0d 90 ld r0, X+
4455 1988: 01 92 st Z+, r0
4456 198a: 81 50 subi r24, 0x01 ; 1
4457 198c: e1 f7 brne .-8 ; 0x1986 <f_open+0x6fe>
4458 dir[DIR_NTres] = fn[11];
4459 198e: 8c 85 ldd r24, Y+12 ; 0x0c
4460 1990: f6 01 movw r30, r12
4461 1992: 84 87 std Z+12, r24 ; 0x0c
4462 mode |= FA_CREATE_ALWAYS;
4463 1994: fb 8d ldd r31, Y+27 ; 0x1b
4464 1996: f8 60 ori r31, 0x08 ; 8
4465 1998: fb 8f std Y+27, r31 ; 0x1b
4466 199a: 72 cf rjmp .-284 ; 0x1880 <f_open+0x5f8>
4467 fp->fptr = 0; /* File ptr */
4468 fp->sect_clust = 1; /* Sector counter */
4469 fp->fs = fs; fp->id = fs->id; /* Owner file system object of the file */
4470  
4471 return FR_OK;
4472 }
4473 199c: c9 01 movw r24, r18
4474 199e: e2 e1 ldi r30, 0x12 ; 18
4475 19a0: 6d 96 adiw r28, 0x1d ; 29
4476 19a2: 0c 94 46 11 jmp 0x228c ; 0x228c <__epilogue_restores__>
4477  
4478 000019a6 <wait_ready>:
4479 /* Wait for card ready */
4480 /*-----------------------------------------------------------------------*/
4481  
4482 static
4483 BYTE wait_ready (void)
4484 {
4485 19a6: 82 e3 ldi r24, 0x32 ; 50
4486 19a8: 80 93 10 01 sts 0x0110, r24
4487 /*-----------------------------------------------------------------------*/
4488  
4489 static
4490 BYTE rcvr_spi (void)
4491 {
4492 SPDR = 0xFF;
4493 19ac: 8f ef ldi r24, 0xFF ; 255
4494 19ae: 8e bd out 0x2e, r24 ; 46
4495 loop_until_bit_is_set(SPSR, SPIF);
4496 19b0: 0d b4 in r0, 0x2d ; 45
4497 19b2: 07 fe sbrs r0, 7
4498 19b4: fd cf rjmp .-6 ; 0x19b0 <wait_ready+0xa>
4499 return SPDR;
4500 19b6: 8e b5 in r24, 0x2e ; 46
4501 /*-----------------------------------------------------------------------*/
4502  
4503 static
4504 BYTE rcvr_spi (void)
4505 {
4506 SPDR = 0xFF;
4507 19b8: 8f ef ldi r24, 0xFF ; 255
4508 19ba: 8e bd out 0x2e, r24 ; 46
4509 loop_until_bit_is_set(SPSR, SPIF);
4510 19bc: 0d b4 in r0, 0x2d ; 45
4511 19be: 07 fe sbrs r0, 7
4512 19c0: fd cf rjmp .-6 ; 0x19bc <wait_ready+0x16>
4513 return SPDR;
4514 19c2: 8e b5 in r24, 0x2e ; 46
4515 19c4: 28 2f mov r18, r24
4516 19c6: 33 27 eor r19, r19
4517  
4518 Timer2 = 50; /* Wait for ready in timeout of 500ms */
4519 rcvr_spi();
4520 do
4521 res = rcvr_spi();
4522 while ((res != 0xFF) && Timer2);
4523 19c8: 8f 3f cpi r24, 0xFF ; 255
4524 19ca: 21 f0 breq .+8 ; 0x19d4 <wait_ready+0x2e>
4525 19cc: 80 91 10 01 lds r24, 0x0110
4526 19d0: 88 23 and r24, r24
4527 19d2: 91 f7 brne .-28 ; 0x19b8 <wait_ready+0x12>
4528  
4529 return res;
4530 }
4531 19d4: c9 01 movw r24, r18
4532 19d6: 08 95 ret
4533  
4534 000019d8 <rcvr_datablock>:
4535 static
4536 BOOL rcvr_datablock (
4537 BYTE *buff, /* Data buffer to store received data */
4538 UINT btr /* Byte count (must be even number) */
4539 )
4540 {
4541 19d8: fc 01 movw r30, r24
4542 BYTE token;
4543  
4544  
4545 Timer1 = 10;
4546 19da: 8a e0 ldi r24, 0x0A ; 10
4547 19dc: 80 93 0f 01 sts 0x010F, r24
4548 /*-----------------------------------------------------------------------*/
4549  
4550 static
4551 BYTE rcvr_spi (void)
4552 {
4553 SPDR = 0xFF;
4554 19e0: 8f ef ldi r24, 0xFF ; 255
4555 19e2: 8e bd out 0x2e, r24 ; 46
4556 loop_until_bit_is_set(SPSR, SPIF);
4557 19e4: 0d b4 in r0, 0x2d ; 45
4558 19e6: 07 fe sbrs r0, 7
4559 19e8: fd cf rjmp .-6 ; 0x19e4 <rcvr_datablock+0xc>
4560 return SPDR;
4561 19ea: 8e b5 in r24, 0x2e ; 46
4562  
4563  
4564 Timer1 = 10;
4565 do { /* Wait for data packet in timeout of 100ms */
4566 token = rcvr_spi();
4567 } while ((token == 0xFF) && Timer1);
4568 19ec: 8f 3f cpi r24, 0xFF ; 255
4569 19ee: 29 f4 brne .+10 ; 0x19fa <rcvr_datablock+0x22>
4570 19f0: 80 91 0f 01 lds r24, 0x010F
4571 19f4: 88 23 and r24, r24
4572 19f6: 29 f1 breq .+74 ; 0x1a42 <rcvr_datablock+0x6a>
4573 19f8: f3 cf rjmp .-26 ; 0x19e0 <rcvr_datablock+0x8>
4574 if(token != 0xFE) return FALSE; /* If not valid data token, retutn with error */
4575 19fa: 8e 3f cpi r24, 0xFE ; 254
4576 19fc: 11 f5 brne .+68 ; 0x1a42 <rcvr_datablock+0x6a>
4577  
4578 do { /* Receive the data block into buffer */
4579 rcvr_spi_m(buff++);
4580 19fe: 8f ef ldi r24, 0xFF ; 255
4581 1a00: 8e bd out 0x2e, r24 ; 46
4582 1a02: 0d b4 in r0, 0x2d ; 45
4583 1a04: 07 fe sbrs r0, 7
4584 1a06: fd cf rjmp .-6 ; 0x1a02 <rcvr_datablock+0x2a>
4585 1a08: 8e b5 in r24, 0x2e ; 46
4586 1a0a: 80 83 st Z, r24
4587 rcvr_spi_m(buff++);
4588 1a0c: 8f ef ldi r24, 0xFF ; 255
4589 1a0e: 8e bd out 0x2e, r24 ; 46
4590 1a10: 0d b4 in r0, 0x2d ; 45
4591 1a12: 07 fe sbrs r0, 7
4592 1a14: fd cf rjmp .-6 ; 0x1a10 <rcvr_datablock+0x38>
4593 1a16: 8e b5 in r24, 0x2e ; 46
4594 1a18: 81 83 std Z+1, r24 ; 0x01
4595 } while (btr -= 2);
4596 1a1a: 62 50 subi r22, 0x02 ; 2
4597 1a1c: 70 40 sbci r23, 0x00 ; 0
4598 1a1e: 11 f0 breq .+4 ; 0x1a24 <rcvr_datablock+0x4c>
4599 1a20: 32 96 adiw r30, 0x02 ; 2
4600 1a22: ed cf rjmp .-38 ; 0x19fe <rcvr_datablock+0x26>
4601 /*-----------------------------------------------------------------------*/
4602  
4603 static
4604 BYTE rcvr_spi (void)
4605 {
4606 SPDR = 0xFF;
4607 1a24: 8f ef ldi r24, 0xFF ; 255
4608 1a26: 8e bd out 0x2e, r24 ; 46
4609 loop_until_bit_is_set(SPSR, SPIF);
4610 1a28: 0d b4 in r0, 0x2d ; 45
4611 1a2a: 07 fe sbrs r0, 7
4612 1a2c: fd cf rjmp .-6 ; 0x1a28 <rcvr_datablock+0x50>
4613 return SPDR;
4614 1a2e: 8e b5 in r24, 0x2e ; 46
4615 /*-----------------------------------------------------------------------*/
4616  
4617 static
4618 BYTE rcvr_spi (void)
4619 {
4620 SPDR = 0xFF;
4621 1a30: 8f ef ldi r24, 0xFF ; 255
4622 1a32: 8e bd out 0x2e, r24 ; 46
4623 loop_until_bit_is_set(SPSR, SPIF);
4624 1a34: 0d b4 in r0, 0x2d ; 45
4625 1a36: 07 fe sbrs r0, 7
4626 1a38: fd cf rjmp .-6 ; 0x1a34 <rcvr_datablock+0x5c>
4627 return SPDR;
4628 1a3a: 8e b5 in r24, 0x2e ; 46
4629 1a3c: 81 e0 ldi r24, 0x01 ; 1
4630 1a3e: 90 e0 ldi r25, 0x00 ; 0
4631 1a40: 08 95 ret
4632 rcvr_spi_m(buff++);
4633 } while (btr -= 2);
4634 rcvr_spi(); /* Discard CRC */
4635 rcvr_spi();
4636  
4637 return TRUE; /* Return with success */
4638 1a42: 80 e0 ldi r24, 0x00 ; 0
4639 1a44: 90 e0 ldi r25, 0x00 ; 0
4640 }
4641 1a46: 08 95 ret
4642  
4643 00001a48 <xmit_datablock>:
4644 static
4645 BOOL xmit_datablock (
4646 const BYTE *buff, /* 512 byte data block to be transmitted */
4647 BYTE token /* Data/Stop token */
4648 )
4649 {
4650 1a48: 1f 93 push r17
4651 1a4a: cf 93 push r28
4652 1a4c: df 93 push r29
4653 1a4e: ec 01 movw r28, r24
4654 1a50: 16 2f mov r17, r22
4655 BYTE resp, wc;
4656  
4657  
4658 if (wait_ready() != 0xFF) return FALSE;
4659 1a52: 0e 94 d3 0c call 0x19a6 ; 0x19a6 <wait_ready>
4660 1a56: 8f 3f cpi r24, 0xFF ; 255
4661 1a58: 19 f0 breq .+6 ; 0x1a60 <xmit_datablock+0x18>
4662 1a5a: 80 e0 ldi r24, 0x00 ; 0
4663 1a5c: 90 e0 ldi r25, 0x00 ; 0
4664 1a5e: 31 c0 rjmp .+98 ; 0x1ac2 <xmit_datablock+0x7a>
4665  
4666 xmit_spi(token); /* Xmit data token */
4667 1a60: 1e bd out 0x2e, r17 ; 46
4668 1a62: 0d b4 in r0, 0x2d ; 45
4669 1a64: 07 fe sbrs r0, 7
4670 1a66: fd cf rjmp .-6 ; 0x1a62 <xmit_datablock+0x1a>
4671 if (token != 0xFD) { /* Is data token */
4672 1a68: 1d 3f cpi r17, 0xFD ; 253
4673 1a6a: 19 f4 brne .+6 ; 0x1a72 <xmit_datablock+0x2a>
4674 1a6c: 81 e0 ldi r24, 0x01 ; 1
4675 1a6e: 90 e0 ldi r25, 0x00 ; 0
4676 1a70: 28 c0 rjmp .+80 ; 0x1ac2 <xmit_datablock+0x7a>
4677 1a72: 90 e0 ldi r25, 0x00 ; 0
4678 wc = 0;
4679 do { /* Xmit the 512 byte data block to MMC */
4680 xmit_spi(*buff++);
4681 1a74: 88 81 ld r24, Y
4682 1a76: 8e bd out 0x2e, r24 ; 46
4683 1a78: 0d b4 in r0, 0x2d ; 45
4684 1a7a: 07 fe sbrs r0, 7
4685 1a7c: fd cf rjmp .-6 ; 0x1a78 <xmit_datablock+0x30>
4686 xmit_spi(*buff++);
4687 1a7e: 89 81 ldd r24, Y+1 ; 0x01
4688 1a80: 8e bd out 0x2e, r24 ; 46
4689 1a82: 0d b4 in r0, 0x2d ; 45
4690 1a84: 07 fe sbrs r0, 7
4691 1a86: fd cf rjmp .-6 ; 0x1a82 <xmit_datablock+0x3a>
4692 } while (--wc);
4693 1a88: 91 50 subi r25, 0x01 ; 1
4694 1a8a: 11 f0 breq .+4 ; 0x1a90 <xmit_datablock+0x48>
4695 1a8c: 22 96 adiw r28, 0x02 ; 2
4696 1a8e: f2 cf rjmp .-28 ; 0x1a74 <xmit_datablock+0x2c>
4697 xmit_spi(0xFF); /* CRC (Dummy) */
4698 1a90: 8f ef ldi r24, 0xFF ; 255
4699 1a92: 8e bd out 0x2e, r24 ; 46
4700 1a94: 0d b4 in r0, 0x2d ; 45
4701 1a96: 07 fe sbrs r0, 7
4702 1a98: fd cf rjmp .-6 ; 0x1a94 <xmit_datablock+0x4c>
4703 xmit_spi(0xFF);
4704 1a9a: 8f ef ldi r24, 0xFF ; 255
4705 1a9c: 8e bd out 0x2e, r24 ; 46
4706 1a9e: 0d b4 in r0, 0x2d ; 45
4707 1aa0: 07 fe sbrs r0, 7
4708 1aa2: fd cf rjmp .-6 ; 0x1a9e <xmit_datablock+0x56>
4709 /*-----------------------------------------------------------------------*/
4710  
4711 static
4712 BYTE rcvr_spi (void)
4713 {
4714 SPDR = 0xFF;
4715 1aa4: 8f ef ldi r24, 0xFF ; 255
4716 1aa6: 8e bd out 0x2e, r24 ; 46
4717 loop_until_bit_is_set(SPSR, SPIF);
4718 1aa8: 0d b4 in r0, 0x2d ; 45
4719 1aaa: 07 fe sbrs r0, 7
4720 1aac: fd cf rjmp .-6 ; 0x1aa8 <xmit_datablock+0x60>
4721 return SPDR;
4722 1aae: 8e b5 in r24, 0x2e ; 46
4723 1ab0: 90 e0 ldi r25, 0x00 ; 0
4724 1ab2: 8f 71 andi r24, 0x1F ; 31
4725 1ab4: 85 30 cpi r24, 0x05 ; 5
4726 1ab6: 09 f0 breq .+2 ; 0x1aba <xmit_datablock+0x72>
4727 1ab8: 91 e0 ldi r25, 0x01 ; 1
4728 1aba: 81 e0 ldi r24, 0x01 ; 1
4729 1abc: 98 27 eor r25, r24
4730 1abe: 89 2f mov r24, r25
4731 1ac0: 99 27 eor r25, r25
4732 1ac2: df 91 pop r29
4733 1ac4: cf 91 pop r28
4734 1ac6: 1f 91 pop r17
4735 1ac8: 08 95 ret
4736  
4737 00001aca <send_cmd>:
4738 static
4739 BYTE send_cmd (
4740 BYTE cmd, /* Command byte */
4741 DWORD arg /* Argument */
4742 )
4743 {
4744 1aca: df 92 push r13
4745 1acc: ef 92 push r14
4746 1ace: ff 92 push r15
4747 1ad0: 0f 93 push r16
4748 1ad2: 1f 93 push r17
4749 1ad4: d8 2e mov r13, r24
4750 1ad6: 7a 01 movw r14, r20
4751 1ad8: 8b 01 movw r16, r22
4752 BYTE n, res;
4753  
4754  
4755 if (wait_ready() != 0xFF) return 0xFF;
4756 1ada: 0e 94 d3 0c call 0x19a6 ; 0x19a6 <wait_ready>
4757 1ade: 8f 3f cpi r24, 0xFF ; 255
4758 1ae0: 19 f0 breq .+6 ; 0x1ae8 <send_cmd+0x1e>
4759 1ae2: 2f ef ldi r18, 0xFF ; 255
4760 1ae4: 30 e0 ldi r19, 0x00 ; 0
4761 1ae6: 44 c0 rjmp .+136 ; 0x1b70 <send_cmd+0xa6>
4762  
4763 /* Send command packet */
4764 xmit_spi(cmd); /* Command */
4765 1ae8: de bc out 0x2e, r13 ; 46
4766 1aea: 0d b4 in r0, 0x2d ; 45
4767 1aec: 07 fe sbrs r0, 7
4768 1aee: fd cf rjmp .-6 ; 0x1aea <send_cmd+0x20>
4769 xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
4770 1af0: 81 2f mov r24, r17
4771 1af2: 99 27 eor r25, r25
4772 1af4: aa 27 eor r26, r26
4773 1af6: bb 27 eor r27, r27
4774 1af8: 8e bd out 0x2e, r24 ; 46
4775 1afa: 0d b4 in r0, 0x2d ; 45
4776 1afc: 07 fe sbrs r0, 7
4777 1afe: fd cf rjmp .-6 ; 0x1afa <send_cmd+0x30>
4778 xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */
4779 1b00: c8 01 movw r24, r16
4780 1b02: aa 27 eor r26, r26
4781 1b04: bb 27 eor r27, r27
4782 1b06: 8e bd out 0x2e, r24 ; 46
4783 1b08: 0d b4 in r0, 0x2d ; 45
4784 1b0a: 07 fe sbrs r0, 7
4785 1b0c: fd cf rjmp .-6 ; 0x1b08 <send_cmd+0x3e>
4786 xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */
4787 1b0e: bb 27 eor r27, r27
4788 1b10: a1 2f mov r26, r17
4789 1b12: 90 2f mov r25, r16
4790 1b14: 8f 2d mov r24, r15
4791 1b16: 8e bd out 0x2e, r24 ; 46
4792 1b18: 0d b4 in r0, 0x2d ; 45
4793 1b1a: 07 fe sbrs r0, 7
4794 1b1c: fd cf rjmp .-6 ; 0x1b18 <send_cmd+0x4e>
4795 xmit_spi((BYTE)arg); /* Argument[7..0] */
4796 1b1e: ee bc out 0x2e, r14 ; 46
4797 1b20: 0d b4 in r0, 0x2d ; 45
4798 1b22: 07 fe sbrs r0, 7
4799 1b24: fd cf rjmp .-6 ; 0x1b20 <send_cmd+0x56>
4800 n = 0;
4801 if (cmd == CMD0) n = 0x95; /* CRC for CMD0(0) */
4802 1b26: 80 e4 ldi r24, 0x40 ; 64
4803 1b28: d8 16 cp r13, r24
4804 1b2a: 11 f4 brne .+4 ; 0x1b30 <send_cmd+0x66>
4805 1b2c: 85 e9 ldi r24, 0x95 ; 149
4806 1b2e: 06 c0 rjmp .+12 ; 0x1b3c <send_cmd+0x72>
4807 if (cmd == CMD8) n = 0x87; /* CRC for CMD8(0x1AA) */
4808 1b30: 88 e4 ldi r24, 0x48 ; 72
4809 1b32: d8 16 cp r13, r24
4810 1b34: 11 f4 brne .+4 ; 0x1b3a <send_cmd+0x70>
4811 1b36: 87 e8 ldi r24, 0x87 ; 135
4812 1b38: 01 c0 rjmp .+2 ; 0x1b3c <send_cmd+0x72>
4813 1b3a: 80 e0 ldi r24, 0x00 ; 0
4814 xmit_spi(n);
4815 1b3c: 8e bd out 0x2e, r24 ; 46
4816 1b3e: 0d b4 in r0, 0x2d ; 45
4817 1b40: 07 fe sbrs r0, 7
4818 1b42: fd cf rjmp .-6 ; 0x1b3e <send_cmd+0x74>
4819  
4820 /* Receive command response */
4821 if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */
4822 1b44: 8c e4 ldi r24, 0x4C ; 76
4823 1b46: d8 16 cp r13, r24
4824 1b48: 31 f4 brne .+12 ; 0x1b56 <send_cmd+0x8c>
4825 /*-----------------------------------------------------------------------*/
4826  
4827 static
4828 BYTE rcvr_spi (void)
4829 {
4830 SPDR = 0xFF;
4831 1b4a: 8f ef ldi r24, 0xFF ; 255
4832 1b4c: 8e bd out 0x2e, r24 ; 46
4833 loop_until_bit_is_set(SPSR, SPIF);
4834 1b4e: 0d b4 in r0, 0x2d ; 45
4835 1b50: 07 fe sbrs r0, 7
4836 1b52: fd cf rjmp .-6 ; 0x1b4e <send_cmd+0x84>
4837 return SPDR;
4838 1b54: 8e b5 in r24, 0x2e ; 46
4839 1b56: 9a e0 ldi r25, 0x0A ; 10
4840 /*-----------------------------------------------------------------------*/
4841  
4842 static
4843 BYTE rcvr_spi (void)
4844 {
4845 SPDR = 0xFF;
4846 1b58: 8f ef ldi r24, 0xFF ; 255
4847 1b5a: 8e bd out 0x2e, r24 ; 46
4848 loop_until_bit_is_set(SPSR, SPIF);
4849 1b5c: 0d b4 in r0, 0x2d ; 45
4850 1b5e: 07 fe sbrs r0, 7
4851 1b60: fd cf rjmp .-6 ; 0x1b5c <send_cmd+0x92>
4852 return SPDR;
4853 1b62: 8e b5 in r24, 0x2e ; 46
4854 1b64: 28 2f mov r18, r24
4855 1b66: 33 27 eor r19, r19
4856 /* Receive command response */
4857 if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */
4858 n = 10; /* Wait for a valid response in timeout of 10 attempts */
4859 do
4860 res = rcvr_spi();
4861 while ((res & 0x80) && --n);
4862 1b68: 87 ff sbrs r24, 7
4863 1b6a: 02 c0 rjmp .+4 ; 0x1b70 <send_cmd+0xa6>
4864 1b6c: 91 50 subi r25, 0x01 ; 1
4865 1b6e: a1 f7 brne .-24 ; 0x1b58 <send_cmd+0x8e>
4866  
4867 return res; /* Return with the response value */
4868 }
4869 1b70: c9 01 movw r24, r18
4870 1b72: 1f 91 pop r17
4871 1b74: 0f 91 pop r16
4872 1b76: ff 90 pop r15
4873 1b78: ef 90 pop r14
4874 1b7a: df 90 pop r13
4875 1b7c: 08 95 ret
4876  
4877 00001b7e <disk_status>:
4878 /*-----------------------------------------------------------------------*/
4879  
4880 DSTATUS disk_status (
4881 BYTE drv /* Physical drive nmuber (0) */
4882 )
4883 {
4884 1b7e: 88 23 and r24, r24
4885 1b80: 19 f0 breq .+6 ; 0x1b88 <disk_status+0xa>
4886 if (drv) return STA_NOINIT; /* Supports only single drive */
4887 1b82: 81 e0 ldi r24, 0x01 ; 1
4888 1b84: 90 e0 ldi r25, 0x00 ; 0
4889 1b86: 08 95 ret
4890 return Stat;
4891 1b88: 80 91 04 01 lds r24, 0x0104
4892 1b8c: 99 27 eor r25, r25
4893 }
4894 1b8e: 08 95 ret
4895  
4896 00001b90 <disk_timerproc>:
4897 /* Device timer interrupt procedure */
4898 /* This must be called in period of 10ms */
4899 /* (Platform dependent) */
4900  
4901 void disk_timerproc (void)
4902 {
4903 1b90: 80 91 0f 01 lds r24, 0x010F
4904 static BYTE pv;
4905 BYTE n, s;
4906  
4907  
4908 n = Timer1; /* 100Hz decrement timer */
4909 if (n) Timer1 = --n;
4910 1b94: 88 23 and r24, r24
4911 1b96: 19 f0 breq .+6 ; 0x1b9e <disk_timerproc+0xe>
4912 1b98: 81 50 subi r24, 0x01 ; 1
4913 1b9a: 80 93 0f 01 sts 0x010F, r24
4914 n = Timer2;
4915 1b9e: 80 91 10 01 lds r24, 0x0110
4916 if (n) Timer2 = --n;
4917 1ba2: 88 23 and r24, r24
4918 1ba4: 19 f0 breq .+6 ; 0x1bac <disk_timerproc+0x1c>
4919 1ba6: 81 50 subi r24, 0x01 ; 1
4920 1ba8: 80 93 10 01 sts 0x0110, r24
4921  
4922 n = pv;
4923 1bac: 90 91 0e 01 lds r25, 0x010E
4924 pv = SOCKPORT & (SOCKINS); /* Sample socket switch */
4925 1bb0: 83 b1 in r24, 0x03 ; 3
4926 1bb2: 81 70 andi r24, 0x01 ; 1
4927 1bb4: 80 93 0e 01 sts 0x010E, r24
4928  
4929 if (n == pv) { /* Have contacts stabled? */
4930 1bb8: 98 17 cp r25, r24
4931 1bba: 49 f4 brne .+18 ; 0x1bce <disk_timerproc+0x3e>
4932 s = Stat;
4933 1bbc: 80 91 04 01 lds r24, 0x0104
4934 if (pv & SOCKINS) /* INS = H (Socket empty) */
4935 1bc0: 90 ff sbrs r25, 0
4936 1bc2: 02 c0 rjmp .+4 ; 0x1bc8 <disk_timerproc+0x38>
4937 s |= (STA_NODISK | STA_NOINIT);
4938 1bc4: 83 60 ori r24, 0x03 ; 3
4939 1bc6: 01 c0 rjmp .+2 ; 0x1bca <disk_timerproc+0x3a>
4940 else /* INS = L (Card inserted) */
4941 s &= ~STA_NODISK;
4942 1bc8: 8d 7f andi r24, 0xFD ; 253
4943  
4944 Stat = s;
4945 1bca: 80 93 04 01 sts 0x0104, r24
4946 1bce: 08 95 ret
4947  
4948 00001bd0 <disk_ioctl>:
4949 DRESULT disk_ioctl (
4950 BYTE drv, /* Physical drive nmuber (0) */
4951 BYTE ctrl, /* Control code */
4952 void *buff /* Buffer to send/receive data block */
4953 )
4954 {
4955 1bd0: a0 e1 ldi r26, 0x10 ; 16
4956 1bd2: b0 e0 ldi r27, 0x00 ; 0
4957 1bd4: ee ee ldi r30, 0xEE ; 238
4958 1bd6: fd e0 ldi r31, 0x0D ; 13
4959 1bd8: 0c 94 38 11 jmp 0x2270 ; 0x2270 <__prologue_saves__+0x1c>
4960 1bdc: fa 01 movw r30, r20
4961 DRESULT res;
4962 BYTE n, csd[16], *ptr = buff;
4963 WORD csize;
4964  
4965  
4966 if (drv) return RES_PARERR;
4967 1bde: 88 23 and r24, r24
4968 1be0: 19 f0 breq .+6 ; 0x1be8 <disk_ioctl+0x18>
4969 1be2: 24 e0 ldi r18, 0x04 ; 4
4970 1be4: 30 e0 ldi r19, 0x00 ; 0
4971 1be6: da c0 rjmp .+436 ; 0x1d9c <disk_ioctl+0x1cc>
4972 BYTE ctrl, /* Control code */
4973 void *buff /* Buffer to send/receive data block */
4974 )
4975 {
4976 DRESULT res;
4977 BYTE n, csd[16], *ptr = buff;
4978 1be8: 8a 01 movw r16, r20
4979 WORD csize;
4980  
4981  
4982 if (drv) return RES_PARERR;
4983  
4984 SELECT(); /* CS = L */
4985 1bea: 2a 98 cbi 0x05, 2 ; 5
4986  
4987 res = RES_ERROR;
4988 switch (ctrl) {
4989 1bec: 63 30 cpi r22, 0x03 ; 3
4990 1bee: 09 f4 brne .+2 ; 0x1bf2 <disk_ioctl+0x22>
4991 1bf0: 82 c0 rjmp .+260 ; 0x1cf6 <disk_ioctl+0x126>
4992 1bf2: 64 30 cpi r22, 0x04 ; 4
4993 1bf4: 28 f4 brcc .+10 ; 0x1c00 <disk_ioctl+0x30>
4994 1bf6: 61 30 cpi r22, 0x01 ; 1
4995 1bf8: 79 f0 breq .+30 ; 0x1c18 <disk_ioctl+0x48>
4996 1bfa: 62 30 cpi r22, 0x02 ; 2
4997 1bfc: 51 f4 brne .+20 ; 0x1c12 <disk_ioctl+0x42>
4998 1bfe: 74 c0 rjmp .+232 ; 0x1ce8 <disk_ioctl+0x118>
4999 1c00: 6b 30 cpi r22, 0x0B ; 11
5000 1c02: 09 f4 brne .+2 ; 0x1c06 <disk_ioctl+0x36>
5001 1c04: 88 c0 rjmp .+272 ; 0x1d16 <disk_ioctl+0x146>
5002 1c06: 6c 30 cpi r22, 0x0C ; 12
5003 1c08: 09 f4 brne .+2 ; 0x1c0c <disk_ioctl+0x3c>
5004 1c0a: 9f c0 rjmp .+318 ; 0x1d4a <disk_ioctl+0x17a>
5005 1c0c: 6a 30 cpi r22, 0x0A ; 10
5006 1c0e: 09 f4 brne .+2 ; 0x1c12 <disk_ioctl+0x42>
5007 1c10: 78 c0 rjmp .+240 ; 0x1d02 <disk_ioctl+0x132>
5008 1c12: 24 e0 ldi r18, 0x04 ; 4
5009 1c14: 30 e0 ldi r19, 0x00 ; 0
5010 1c16: b8 c0 rjmp .+368 ; 0x1d88 <disk_ioctl+0x1b8>
5011 case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
5012 if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
5013 1c18: 40 e0 ldi r20, 0x00 ; 0
5014 1c1a: 50 e0 ldi r21, 0x00 ; 0
5015 1c1c: 60 e0 ldi r22, 0x00 ; 0
5016 1c1e: 70 e0 ldi r23, 0x00 ; 0
5017 1c20: 89 e4 ldi r24, 0x49 ; 73
5018 1c22: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5019 1c26: 88 23 and r24, r24
5020 1c28: 09 f0 breq .+2 ; 0x1c2c <disk_ioctl+0x5c>
5021 1c2a: ac c0 rjmp .+344 ; 0x1d84 <disk_ioctl+0x1b4>
5022 1c2c: 60 e1 ldi r22, 0x10 ; 16
5023 1c2e: 70 e0 ldi r23, 0x00 ; 0
5024 1c30: ce 01 movw r24, r28
5025 1c32: 01 96 adiw r24, 0x01 ; 1
5026 1c34: 0e 94 ec 0c call 0x19d8 ; 0x19d8 <rcvr_datablock>
5027 1c38: 88 23 and r24, r24
5028 1c3a: 09 f4 brne .+2 ; 0x1c3e <disk_ioctl+0x6e>
5029 1c3c: a3 c0 rjmp .+326 ; 0x1d84 <disk_ioctl+0x1b4>
5030 if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
5031 1c3e: 89 81 ldd r24, Y+1 ; 0x01
5032 1c40: 82 95 swap r24
5033 1c42: 86 95 lsr r24
5034 1c44: 86 95 lsr r24
5035 1c46: 83 70 andi r24, 0x03 ; 3
5036 1c48: 7a 85 ldd r23, Y+10 ; 0x0a
5037 1c4a: 49 85 ldd r20, Y+9 ; 0x09
5038 1c4c: 81 30 cpi r24, 0x01 ; 1
5039 1c4e: c1 f4 brne .+48 ; 0x1c80 <disk_ioctl+0xb0>
5040 csize = csd[9] + ((WORD)csd[8] << 8) + 1;
5041 *(DWORD*)buff = (DWORD)csize << 10;
5042 1c50: 87 2f mov r24, r23
5043 1c52: 99 27 eor r25, r25
5044 1c54: 01 96 adiw r24, 0x01 ; 1
5045 1c56: 24 2f mov r18, r20
5046 1c58: 33 27 eor r19, r19
5047 1c5a: 32 2f mov r19, r18
5048 1c5c: 22 27 eor r18, r18
5049 1c5e: 82 0f add r24, r18
5050 1c60: 93 1f adc r25, r19
5051 1c62: aa 27 eor r26, r26
5052 1c64: bb 27 eor r27, r27
5053 1c66: 6a e0 ldi r22, 0x0A ; 10
5054 1c68: 88 0f add r24, r24
5055 1c6a: 99 1f adc r25, r25
5056 1c6c: aa 1f adc r26, r26
5057 1c6e: bb 1f adc r27, r27
5058 1c70: 6a 95 dec r22
5059 1c72: d1 f7 brne .-12 ; 0x1c68 <disk_ioctl+0x98>
5060 1c74: f8 01 movw r30, r16
5061 1c76: 80 83 st Z, r24
5062 1c78: 91 83 std Z+1, r25 ; 0x01
5063 1c7a: a2 83 std Z+2, r26 ; 0x02
5064 1c7c: b3 83 std Z+3, r27 ; 0x03
5065 1c7e: 38 c0 rjmp .+112 ; 0x1cf0 <disk_ioctl+0x120>
5066 } else { /* MMC or SDC ver 1.XX */
5067 n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
5068 csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
5069 *(DWORD*)buff = (DWORD)csize << (n - 9);
5070 1c80: 42 95 swap r20
5071 1c82: 46 95 lsr r20
5072 1c84: 46 95 lsr r20
5073 1c86: 43 70 andi r20, 0x03 ; 3
5074 1c88: 28 85 ldd r18, Y+8 ; 0x08
5075 1c8a: 33 27 eor r19, r19
5076 1c8c: 22 0f add r18, r18
5077 1c8e: 33 1f adc r19, r19
5078 1c90: 22 0f add r18, r18
5079 1c92: 33 1f adc r19, r19
5080 1c94: 24 0f add r18, r20
5081 1c96: 31 1d adc r19, r1
5082 1c98: 2f 5f subi r18, 0xFF ; 255
5083 1c9a: 3f 4f sbci r19, 0xFF ; 255
5084 1c9c: 8f 81 ldd r24, Y+7 ; 0x07
5085 1c9e: 99 27 eor r25, r25
5086 1ca0: 83 70 andi r24, 0x03 ; 3
5087 1ca2: 90 70 andi r25, 0x00 ; 0
5088 1ca4: 98 2f mov r25, r24
5089 1ca6: 88 27 eor r24, r24
5090 1ca8: 99 0f add r25, r25
5091 1caa: 99 0f add r25, r25
5092 1cac: 28 0f add r18, r24
5093 1cae: 39 1f adc r19, r25
5094 1cb0: 44 27 eor r20, r20
5095 1cb2: 55 27 eor r21, r21
5096 1cb4: 6e 81 ldd r22, Y+6 ; 0x06
5097 1cb6: 6f 70 andi r22, 0x0F ; 15
5098 1cb8: 6e 5f subi r22, 0xFE ; 254
5099 1cba: 73 70 andi r23, 0x03 ; 3
5100 1cbc: 77 0f add r23, r23
5101 1cbe: 67 0f add r22, r23
5102 1cc0: 8b 85 ldd r24, Y+11 ; 0x0b
5103 1cc2: 88 1f adc r24, r24
5104 1cc4: 88 27 eor r24, r24
5105 1cc6: 88 1f adc r24, r24
5106 1cc8: 86 0f add r24, r22
5107 1cca: 99 27 eor r25, r25
5108 1ccc: 09 97 sbiw r24, 0x09 ; 9
5109 1cce: 04 c0 rjmp .+8 ; 0x1cd8 <disk_ioctl+0x108>
5110 1cd0: 22 0f add r18, r18
5111 1cd2: 33 1f adc r19, r19
5112 1cd4: 44 1f adc r20, r20
5113 1cd6: 55 1f adc r21, r21
5114 1cd8: 8a 95 dec r24
5115 1cda: d2 f7 brpl .-12 ; 0x1cd0 <disk_ioctl+0x100>
5116 1cdc: f8 01 movw r30, r16
5117 1cde: 20 83 st Z, r18
5118 1ce0: 31 83 std Z+1, r19 ; 0x01
5119 1ce2: 42 83 std Z+2, r20 ; 0x02
5120 1ce4: 53 83 std Z+3, r21 ; 0x03
5121 1ce6: 04 c0 rjmp .+8 ; 0x1cf0 <disk_ioctl+0x120>
5122 res = RES_OK;
5123 }
5124 break;
5125  
5126 case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
5127 *(WORD*)buff = 512;
5128 1ce8: 80 e0 ldi r24, 0x00 ; 0
5129 1cea: 92 e0 ldi r25, 0x02 ; 2
5130 1cec: 91 83 std Z+1, r25 ; 0x01
5131 1cee: 80 83 st Z, r24
5132 1cf0: 20 e0 ldi r18, 0x00 ; 0
5133 1cf2: 30 e0 ldi r19, 0x00 ; 0
5134 1cf4: 49 c0 rjmp .+146 ; 0x1d88 <disk_ioctl+0x1b8>
5135 res = RES_OK;
5136 break;
5137  
5138 case CTRL_SYNC : /* Make sure that data has been written */
5139 if (wait_ready() == 0xFF)
5140 1cf6: 0e 94 d3 0c call 0x19a6 ; 0x19a6 <wait_ready>
5141 1cfa: 90 e0 ldi r25, 0x00 ; 0
5142 1cfc: 8f 3f cpi r24, 0xFF ; 255
5143 1cfe: 01 f5 brne .+64 ; 0x1d40 <disk_ioctl+0x170>
5144 1d00: 1e c0 rjmp .+60 ; 0x1d3e <disk_ioctl+0x16e>
5145 res = RES_OK;
5146 break;
5147  
5148 case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */
5149 if (Stat & STA_NOINIT) return RES_NOTRDY;
5150 1d02: 80 91 04 01 lds r24, 0x0104
5151 1d06: 80 fd sbrc r24, 0
5152 1d08: 47 c0 rjmp .+142 ; 0x1d98 <disk_ioctl+0x1c8>
5153 if ((send_cmd(CMD9, 0) == 0) /* READ_CSD */
5154 1d0a: 40 e0 ldi r20, 0x00 ; 0
5155 1d0c: 50 e0 ldi r21, 0x00 ; 0
5156 1d0e: 60 e0 ldi r22, 0x00 ; 0
5157 1d10: 70 e0 ldi r23, 0x00 ; 0
5158 1d12: 89 e4 ldi r24, 0x49 ; 73
5159 1d14: 09 c0 rjmp .+18 ; 0x1d28 <disk_ioctl+0x158>
5160 && rcvr_datablock(ptr, 16))
5161 res = RES_OK;
5162 break;
5163  
5164 case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */
5165 if (Stat & STA_NOINIT) return RES_NOTRDY;
5166 1d16: 80 91 04 01 lds r24, 0x0104
5167 1d1a: 80 fd sbrc r24, 0
5168 1d1c: 3d c0 rjmp .+122 ; 0x1d98 <disk_ioctl+0x1c8>
5169 if ((send_cmd(CMD10, 0) == 0) /* READ_CID */
5170 1d1e: 40 e0 ldi r20, 0x00 ; 0
5171 1d20: 50 e0 ldi r21, 0x00 ; 0
5172 1d22: 60 e0 ldi r22, 0x00 ; 0
5173 1d24: 70 e0 ldi r23, 0x00 ; 0
5174 1d26: 8a e4 ldi r24, 0x4A ; 74
5175 1d28: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5176 1d2c: 88 23 and r24, r24
5177 1d2e: 51 f5 brne .+84 ; 0x1d84 <disk_ioctl+0x1b4>
5178 1d30: 60 e1 ldi r22, 0x10 ; 16
5179 1d32: 70 e0 ldi r23, 0x00 ; 0
5180 1d34: c8 01 movw r24, r16
5181 1d36: 0e 94 ec 0c call 0x19d8 ; 0x19d8 <rcvr_datablock>
5182 1d3a: 90 e0 ldi r25, 0x00 ; 0
5183 1d3c: 81 11 cpse r24, r1
5184 1d3e: 91 e0 ldi r25, 0x01 ; 1
5185 1d40: 81 e0 ldi r24, 0x01 ; 1
5186 1d42: 98 27 eor r25, r24
5187 1d44: 29 2f mov r18, r25
5188 1d46: 33 27 eor r19, r19
5189 1d48: 1f c0 rjmp .+62 ; 0x1d88 <disk_ioctl+0x1b8>
5190 && rcvr_datablock(ptr, 16))
5191 res = RES_OK;
5192 break;
5193  
5194 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
5195 if (Stat & STA_NOINIT) return RES_NOTRDY;
5196 1d4a: 80 91 04 01 lds r24, 0x0104
5197 1d4e: 80 fd sbrc r24, 0
5198 1d50: 23 c0 rjmp .+70 ; 0x1d98 <disk_ioctl+0x1c8>
5199 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
5200 1d52: 40 e0 ldi r20, 0x00 ; 0
5201 1d54: 50 e0 ldi r21, 0x00 ; 0
5202 1d56: 60 e0 ldi r22, 0x00 ; 0
5203 1d58: 70 e0 ldi r23, 0x00 ; 0
5204 1d5a: 8a e7 ldi r24, 0x7A ; 122
5205 1d5c: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5206 1d60: 88 23 and r24, r24
5207 1d62: 81 f4 brne .+32 ; 0x1d84 <disk_ioctl+0x1b4>
5208 1d64: 90 e0 ldi r25, 0x00 ; 0
5209 /*-----------------------------------------------------------------------*/
5210  
5211 static
5212 BYTE rcvr_spi (void)
5213 {
5214 SPDR = 0xFF;
5215 1d66: 8f ef ldi r24, 0xFF ; 255
5216 1d68: 8e bd out 0x2e, r24 ; 46
5217 loop_until_bit_is_set(SPSR, SPIF);
5218 1d6a: 0d b4 in r0, 0x2d ; 45
5219 1d6c: 07 fe sbrs r0, 7
5220 1d6e: fd cf rjmp .-6 ; 0x1d6a <disk_ioctl+0x19a>
5221 return SPDR;
5222 1d70: 8e b5 in r24, 0x2e ; 46
5223  
5224 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
5225 if (Stat & STA_NOINIT) return RES_NOTRDY;
5226 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
5227 for (n = 0; n < 4; n++)
5228 *ptr++ = rcvr_spi();
5229 1d72: f8 01 movw r30, r16
5230 1d74: 80 83 st Z, r24
5231 break;
5232  
5233 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
5234 if (Stat & STA_NOINIT) return RES_NOTRDY;
5235 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
5236 for (n = 0; n < 4; n++)
5237 1d76: 9f 5f subi r25, 0xFF ; 255
5238 1d78: 94 30 cpi r25, 0x04 ; 4
5239 1d7a: 09 f4 brne .+2 ; 0x1d7e <disk_ioctl+0x1ae>
5240 1d7c: b9 cf rjmp .-142 ; 0x1cf0 <disk_ioctl+0x120>
5241 *ptr++ = rcvr_spi();
5242 1d7e: 0f 5f subi r16, 0xFF ; 255
5243 1d80: 1f 4f sbci r17, 0xFF ; 255
5244 1d82: f1 cf rjmp .-30 ; 0x1d66 <disk_ioctl+0x196>
5245 1d84: 21 e0 ldi r18, 0x01 ; 1
5246 1d86: 30 e0 ldi r19, 0x00 ; 0
5247  
5248 default:
5249 res = RES_PARERR;
5250 }
5251  
5252 DESELECT(); /* CS = H */
5253 1d88: 2a 9a sbi 0x05, 2 ; 5
5254 /*-----------------------------------------------------------------------*/
5255  
5256 static
5257 BYTE rcvr_spi (void)
5258 {
5259 SPDR = 0xFF;
5260 1d8a: 8f ef ldi r24, 0xFF ; 255
5261 1d8c: 8e bd out 0x2e, r24 ; 46
5262 loop_until_bit_is_set(SPSR, SPIF);
5263 1d8e: 0d b4 in r0, 0x2d ; 45
5264 1d90: 07 fe sbrs r0, 7
5265 1d92: fd cf rjmp .-6 ; 0x1d8e <disk_ioctl+0x1be>
5266 return SPDR;
5267 1d94: 8e b5 in r24, 0x2e ; 46
5268 1d96: 02 c0 rjmp .+4 ; 0x1d9c <disk_ioctl+0x1cc>
5269 }
5270  
5271 DESELECT(); /* CS = H */
5272 rcvr_spi(); /* Idle (Release DO) */
5273  
5274 return res;
5275 1d98: 23 e0 ldi r18, 0x03 ; 3
5276 1d9a: 30 e0 ldi r19, 0x00 ; 0
5277 }
5278 1d9c: c9 01 movw r24, r18
5279 1d9e: e4 e0 ldi r30, 0x04 ; 4
5280 1da0: 60 96 adiw r28, 0x10 ; 16
5281 1da2: 0c 94 54 11 jmp 0x22a8 ; 0x22a8 <__epilogue_restores__+0x1c>
5282  
5283 00001da6 <disk_write>:
5284 BYTE drv, /* Physical drive nmuber (0) */
5285 const BYTE *buff, /* Pointer to the data to be written */
5286 DWORD sector, /* Start sector number (LBA) */
5287 BYTE count /* Sector count (1..255) */
5288 )
5289 {
5290 1da6: cf 92 push r12
5291 1da8: df 92 push r13
5292 1daa: ef 92 push r14
5293 1dac: ff 92 push r15
5294 1dae: 0f 93 push r16
5295 1db0: cf 93 push r28
5296 1db2: df 93 push r29
5297 1db4: eb 01 movw r28, r22
5298 1db6: 69 01 movw r12, r18
5299 1db8: 7a 01 movw r14, r20
5300 if (drv || !count) return RES_PARERR;
5301 1dba: 88 23 and r24, r24
5302 1dbc: 09 f0 breq .+2 ; 0x1dc0 <disk_write+0x1a>
5303 1dbe: 67 c0 rjmp .+206 ; 0x1e8e <disk_write+0xe8>
5304 1dc0: 00 23 and r16, r16
5305 1dc2: 09 f4 brne .+2 ; 0x1dc6 <disk_write+0x20>
5306 1dc4: 64 c0 rjmp .+200 ; 0x1e8e <disk_write+0xe8>
5307 if (Stat & STA_NOINIT) return RES_NOTRDY;
5308 1dc6: 80 91 04 01 lds r24, 0x0104
5309 1dca: 80 ff sbrs r24, 0
5310 1dcc: 03 c0 rjmp .+6 ; 0x1dd4 <disk_write+0x2e>
5311 1dce: 83 e0 ldi r24, 0x03 ; 3
5312 1dd0: 90 e0 ldi r25, 0x00 ; 0
5313 1dd2: 5f c0 rjmp .+190 ; 0x1e92 <disk_write+0xec>
5314 if (Stat & STA_PROTECT) return RES_WRPRT;
5315 1dd4: 80 91 04 01 lds r24, 0x0104
5316 1dd8: 82 ff sbrs r24, 2
5317 1dda: 03 c0 rjmp .+6 ; 0x1de2 <disk_write+0x3c>
5318 1ddc: 82 e0 ldi r24, 0x02 ; 2
5319 1dde: 90 e0 ldi r25, 0x00 ; 0
5320 1de0: 58 c0 rjmp .+176 ; 0x1e92 <disk_write+0xec>
5321  
5322 if (!(CardType & 4)) sector *= 512; /* Convert to byte address if needed */
5323 1de2: 80 91 11 01 lds r24, 0x0111
5324 1de6: 99 27 eor r25, r25
5325 1de8: 82 fd sbrc r24, 2
5326 1dea: 07 c0 rjmp .+14 ; 0x1dfa <disk_write+0x54>
5327 1dec: e9 e0 ldi r30, 0x09 ; 9
5328 1dee: cc 0c add r12, r12
5329 1df0: dd 1c adc r13, r13
5330 1df2: ee 1c adc r14, r14
5331 1df4: ff 1c adc r15, r15
5332 1df6: ea 95 dec r30
5333 1df8: d1 f7 brne .-12 ; 0x1dee <disk_write+0x48>
5334  
5335 SELECT(); /* CS = L */
5336 1dfa: 2a 98 cbi 0x05, 2 ; 5
5337  
5338 if (count == 1) { /* Single block write */
5339 1dfc: 01 30 cpi r16, 0x01 ; 1
5340 1dfe: 79 f4 brne .+30 ; 0x1e1e <disk_write+0x78>
5341 if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */
5342 1e00: b7 01 movw r22, r14
5343 1e02: a6 01 movw r20, r12
5344 1e04: 88 e5 ldi r24, 0x58 ; 88
5345 1e06: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5346 1e0a: 88 23 and r24, r24
5347 1e0c: 91 f5 brne .+100 ; 0x1e72 <disk_write+0xcc>
5348 1e0e: 6e ef ldi r22, 0xFE ; 254
5349 1e10: ce 01 movw r24, r28
5350 1e12: 0e 94 24 0d call 0x1a48 ; 0x1a48 <xmit_datablock>
5351 1e16: 81 11 cpse r24, r1
5352 1e18: 81 e0 ldi r24, 0x01 ; 1
5353 1e1a: 08 27 eor r16, r24
5354 1e1c: 2a c0 rjmp .+84 ; 0x1e72 <disk_write+0xcc>
5355 && xmit_datablock(buff, 0xFE))
5356 count = 0;
5357 }
5358 else { /* Multiple block write */
5359 if (CardType & 2) {
5360 1e1e: 81 ff sbrs r24, 1
5361 1e20: 0e c0 rjmp .+28 ; 0x1e3e <disk_write+0x98>
5362 send_cmd(CMD55, 0); send_cmd(CMD23, count); /* ACMD23 */
5363 1e22: 40 e0 ldi r20, 0x00 ; 0
5364 1e24: 50 e0 ldi r21, 0x00 ; 0
5365 1e26: 60 e0 ldi r22, 0x00 ; 0
5366 1e28: 70 e0 ldi r23, 0x00 ; 0
5367 1e2a: 87 e7 ldi r24, 0x77 ; 119
5368 1e2c: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5369 1e30: 40 2f mov r20, r16
5370 1e32: 55 27 eor r21, r21
5371 1e34: 66 27 eor r22, r22
5372 1e36: 77 27 eor r23, r23
5373 1e38: 87 e5 ldi r24, 0x57 ; 87
5374 1e3a: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5375 }
5376 if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
5377 1e3e: b7 01 movw r22, r14
5378 1e40: a6 01 movw r20, r12
5379 1e42: 89 e5 ldi r24, 0x59 ; 89
5380 1e44: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5381 1e48: 88 23 and r24, r24
5382 1e4a: 99 f4 brne .+38 ; 0x1e72 <disk_write+0xcc>
5383 do {
5384 if (!xmit_datablock(buff, 0xFC)) break;
5385 1e4c: 6c ef ldi r22, 0xFC ; 252
5386 1e4e: ce 01 movw r24, r28
5387 1e50: 0e 94 24 0d call 0x1a48 ; 0x1a48 <xmit_datablock>
5388 1e54: 88 23 and r24, r24
5389 1e56: 29 f0 breq .+10 ; 0x1e62 <disk_write+0xbc>
5390 buff += 512;
5391 } while (--count);
5392 1e58: 01 50 subi r16, 0x01 ; 1
5393 1e5a: 19 f0 breq .+6 ; 0x1e62 <disk_write+0xbc>
5394 send_cmd(CMD55, 0); send_cmd(CMD23, count); /* ACMD23 */
5395 }
5396 if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
5397 do {
5398 if (!xmit_datablock(buff, 0xFC)) break;
5399 buff += 512;
5400 1e5c: c0 50 subi r28, 0x00 ; 0
5401 1e5e: de 4f sbci r29, 0xFE ; 254
5402 1e60: f5 cf rjmp .-22 ; 0x1e4c <disk_write+0xa6>
5403 } while (--count);
5404 if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */
5405 1e62: 6d ef ldi r22, 0xFD ; 253
5406 1e64: 80 e0 ldi r24, 0x00 ; 0
5407 1e66: 90 e0 ldi r25, 0x00 ; 0
5408 1e68: 0e 94 24 0d call 0x1a48 ; 0x1a48 <xmit_datablock>
5409 1e6c: 88 23 and r24, r24
5410 1e6e: 09 f4 brne .+2 ; 0x1e72 <disk_write+0xcc>
5411 1e70: 01 e0 ldi r16, 0x01 ; 1
5412 count = 1;
5413 }
5414 }
5415  
5416 DESELECT(); /* CS = H */
5417 1e72: 2a 9a sbi 0x05, 2 ; 5
5418 /*-----------------------------------------------------------------------*/
5419  
5420 static
5421 BYTE rcvr_spi (void)
5422 {
5423 SPDR = 0xFF;
5424 1e74: 8f ef ldi r24, 0xFF ; 255
5425 1e76: 8e bd out 0x2e, r24 ; 46
5426 loop_until_bit_is_set(SPSR, SPIF);
5427 1e78: 0d b4 in r0, 0x2d ; 45
5428 1e7a: 07 fe sbrs r0, 7
5429 1e7c: fd cf rjmp .-6 ; 0x1e78 <disk_write+0xd2>
5430 return SPDR;
5431 1e7e: 8e b5 in r24, 0x2e ; 46
5432 }
5433  
5434 DESELECT(); /* CS = H */
5435 rcvr_spi(); /* Idle (Release DO) */
5436  
5437 return count ? RES_ERROR : RES_OK;
5438 1e80: 80 e0 ldi r24, 0x00 ; 0
5439 1e82: 90 e0 ldi r25, 0x00 ; 0
5440 1e84: 00 23 and r16, r16
5441 1e86: 29 f0 breq .+10 ; 0x1e92 <disk_write+0xec>
5442 1e88: 81 e0 ldi r24, 0x01 ; 1
5443 1e8a: 90 e0 ldi r25, 0x00 ; 0
5444 1e8c: 02 c0 rjmp .+4 ; 0x1e92 <disk_write+0xec>
5445 1e8e: 84 e0 ldi r24, 0x04 ; 4
5446 1e90: 90 e0 ldi r25, 0x00 ; 0
5447 1e92: df 91 pop r29
5448 1e94: cf 91 pop r28
5449 1e96: 0f 91 pop r16
5450 1e98: ff 90 pop r15
5451 1e9a: ef 90 pop r14
5452 1e9c: df 90 pop r13
5453 1e9e: cf 90 pop r12
5454 1ea0: 08 95 ret
5455  
5456 00001ea2 <disk_read>:
5457 BYTE drv, /* Physical drive nmuber (0) */
5458 BYTE *buff, /* Pointer to the data buffer to store read data */
5459 DWORD sector, /* Start sector number (LBA) */
5460 BYTE count /* Sector count (1..255) */
5461 )
5462 {
5463 1ea2: 0f 93 push r16
5464 1ea4: cf 93 push r28
5465 1ea6: df 93 push r29
5466 1ea8: eb 01 movw r28, r22
5467 if (drv || !count) return RES_PARERR;
5468 1eaa: 88 23 and r24, r24
5469 1eac: 09 f0 breq .+2 ; 0x1eb0 <disk_read+0xe>
5470 1eae: 50 c0 rjmp .+160 ; 0x1f50 <disk_read+0xae>
5471 1eb0: 00 23 and r16, r16
5472 1eb2: 09 f4 brne .+2 ; 0x1eb6 <disk_read+0x14>
5473 1eb4: 4d c0 rjmp .+154 ; 0x1f50 <disk_read+0xae>
5474 if (Stat & STA_NOINIT) return RES_NOTRDY;
5475 1eb6: 80 91 04 01 lds r24, 0x0104
5476 1eba: 80 ff sbrs r24, 0
5477 1ebc: 03 c0 rjmp .+6 ; 0x1ec4 <disk_read+0x22>
5478 1ebe: 83 e0 ldi r24, 0x03 ; 3
5479 1ec0: 90 e0 ldi r25, 0x00 ; 0
5480 1ec2: 48 c0 rjmp .+144 ; 0x1f54 <disk_read+0xb2>
5481  
5482 if (!(CardType & 4)) sector *= 512; /* Convert to byte address if needed */
5483 1ec4: 80 91 11 01 lds r24, 0x0111
5484 1ec8: 82 fd sbrc r24, 2
5485 1eca: 07 c0 rjmp .+14 ; 0x1eda <disk_read+0x38>
5486 1ecc: f9 e0 ldi r31, 0x09 ; 9
5487 1ece: 22 0f add r18, r18
5488 1ed0: 33 1f adc r19, r19
5489 1ed2: 44 1f adc r20, r20
5490 1ed4: 55 1f adc r21, r21
5491 1ed6: fa 95 dec r31
5492 1ed8: d1 f7 brne .-12 ; 0x1ece <disk_read+0x2c>
5493  
5494 SELECT(); /* CS = L */
5495 1eda: 2a 98 cbi 0x05, 2 ; 5
5496  
5497 if (count == 1) { /* Single block read */
5498 1edc: 01 30 cpi r16, 0x01 ; 1
5499 1ede: 81 f4 brne .+32 ; 0x1f00 <disk_read+0x5e>
5500 if ((send_cmd(CMD17, sector) == 0) /* READ_SINGLE_BLOCK */
5501 1ee0: ba 01 movw r22, r20
5502 1ee2: a9 01 movw r20, r18
5503 1ee4: 81 e5 ldi r24, 0x51 ; 81
5504 1ee6: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5505 1eea: 88 23 and r24, r24
5506 1eec: 19 f5 brne .+70 ; 0x1f34 <disk_read+0x92>
5507 1eee: 60 e0 ldi r22, 0x00 ; 0
5508 1ef0: 72 e0 ldi r23, 0x02 ; 2
5509 1ef2: ce 01 movw r24, r28
5510 1ef4: 0e 94 ec 0c call 0x19d8 ; 0x19d8 <rcvr_datablock>
5511 1ef8: 81 11 cpse r24, r1
5512 1efa: 81 e0 ldi r24, 0x01 ; 1
5513 1efc: 08 27 eor r16, r24
5514 1efe: 1a c0 rjmp .+52 ; 0x1f34 <disk_read+0x92>
5515 && rcvr_datablock(buff, 512))
5516 count = 0;
5517 }
5518 else { /* Multiple block read */
5519 if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
5520 1f00: ba 01 movw r22, r20
5521 1f02: a9 01 movw r20, r18
5522 1f04: 82 e5 ldi r24, 0x52 ; 82
5523 1f06: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5524 1f0a: 88 23 and r24, r24
5525 1f0c: 99 f4 brne .+38 ; 0x1f34 <disk_read+0x92>
5526 do {
5527 if (!rcvr_datablock(buff, 512)) break;
5528 1f0e: 60 e0 ldi r22, 0x00 ; 0
5529 1f10: 72 e0 ldi r23, 0x02 ; 2
5530 1f12: ce 01 movw r24, r28
5531 1f14: 0e 94 ec 0c call 0x19d8 ; 0x19d8 <rcvr_datablock>
5532 1f18: 88 23 and r24, r24
5533 1f1a: 29 f0 breq .+10 ; 0x1f26 <disk_read+0x84>
5534 buff += 512;
5535 } while (--count);
5536 1f1c: 01 50 subi r16, 0x01 ; 1
5537 1f1e: 19 f0 breq .+6 ; 0x1f26 <disk_read+0x84>
5538 }
5539 else { /* Multiple block read */
5540 if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
5541 do {
5542 if (!rcvr_datablock(buff, 512)) break;
5543 buff += 512;
5544 1f20: c0 50 subi r28, 0x00 ; 0
5545 1f22: de 4f sbci r29, 0xFE ; 254
5546 1f24: f4 cf rjmp .-24 ; 0x1f0e <disk_read+0x6c>
5547 } while (--count);
5548 send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
5549 1f26: 40 e0 ldi r20, 0x00 ; 0
5550 1f28: 50 e0 ldi r21, 0x00 ; 0
5551 1f2a: 60 e0 ldi r22, 0x00 ; 0
5552 1f2c: 70 e0 ldi r23, 0x00 ; 0
5553 1f2e: 8c e4 ldi r24, 0x4C ; 76
5554 1f30: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5555 }
5556 }
5557  
5558 DESELECT(); /* CS = H */
5559 1f34: 2a 9a sbi 0x05, 2 ; 5
5560 /*-----------------------------------------------------------------------*/
5561  
5562 static
5563 BYTE rcvr_spi (void)
5564 {
5565 SPDR = 0xFF;
5566 1f36: 8f ef ldi r24, 0xFF ; 255
5567 1f38: 8e bd out 0x2e, r24 ; 46
5568 loop_until_bit_is_set(SPSR, SPIF);
5569 1f3a: 0d b4 in r0, 0x2d ; 45
5570 1f3c: 07 fe sbrs r0, 7
5571 1f3e: fd cf rjmp .-6 ; 0x1f3a <disk_read+0x98>
5572 return SPDR;
5573 1f40: 8e b5 in r24, 0x2e ; 46
5574 }
5575  
5576 DESELECT(); /* CS = H */
5577 rcvr_spi(); /* Idle (Release DO) */
5578  
5579 return count ? RES_ERROR : RES_OK;
5580 1f42: 80 e0 ldi r24, 0x00 ; 0
5581 1f44: 90 e0 ldi r25, 0x00 ; 0
5582 1f46: 00 23 and r16, r16
5583 1f48: 29 f0 breq .+10 ; 0x1f54 <disk_read+0xb2>
5584 1f4a: 81 e0 ldi r24, 0x01 ; 1
5585 1f4c: 90 e0 ldi r25, 0x00 ; 0
5586 1f4e: 02 c0 rjmp .+4 ; 0x1f54 <disk_read+0xb2>
5587 1f50: 84 e0 ldi r24, 0x04 ; 4
5588 1f52: 90 e0 ldi r25, 0x00 ; 0
5589 1f54: df 91 pop r29
5590 1f56: cf 91 pop r28
5591 1f58: 0f 91 pop r16
5592 1f5a: 08 95 ret
5593  
5594 00001f5c <disk_initialize>:
5595 /*-----------------------------------------------------------------------*/
5596  
5597 DSTATUS disk_initialize (
5598 BYTE drv /* Physical drive nmuber (0) */
5599 )
5600 {
5601 1f5c: a4 e0 ldi r26, 0x04 ; 4
5602 1f5e: b0 e0 ldi r27, 0x00 ; 0
5603 1f60: e4 eb ldi r30, 0xB4 ; 180
5604 1f62: ff e0 ldi r31, 0x0F ; 15
5605 1f64: 0c 94 36 11 jmp 0x226c ; 0x226c <__prologue_saves__+0x18>
5606 BYTE n, ty, ocr[4];
5607  
5608  
5609 if (drv) return STA_NOINIT; /* Supports only single drive */
5610 1f68: 88 23 and r24, r24
5611 1f6a: 19 f0 breq .+6 ; 0x1f72 <disk_initialize+0x16>
5612 1f6c: 81 e0 ldi r24, 0x01 ; 1
5613 1f6e: 90 e0 ldi r25, 0x00 ; 0
5614 1f70: d0 c0 rjmp .+416 ; 0x2112 <disk_initialize+0x1b6>
5615 if (Stat & STA_NODISK) return Stat; /* No card in the socket */
5616 1f72: 80 91 04 01 lds r24, 0x0104
5617 1f76: 81 fd sbrc r24, 1
5618 1f78: c9 c0 rjmp .+402 ; 0x210c <disk_initialize+0x1b0>
5619 1f7a: 9a e0 ldi r25, 0x0A ; 10
5620 /*-----------------------------------------------------------------------*/
5621  
5622 static
5623 BYTE rcvr_spi (void)
5624 {
5625 SPDR = 0xFF;
5626 1f7c: 8f ef ldi r24, 0xFF ; 255
5627 1f7e: 8e bd out 0x2e, r24 ; 46
5628 loop_until_bit_is_set(SPSR, SPIF);
5629 1f80: 0d b4 in r0, 0x2d ; 45
5630 1f82: 07 fe sbrs r0, 7
5631 1f84: fd cf rjmp .-6 ; 0x1f80 <disk_initialize+0x24>
5632 return SPDR;
5633 1f86: 8e b5 in r24, 0x2e ; 46
5634  
5635  
5636 if (drv) return STA_NOINIT; /* Supports only single drive */
5637 if (Stat & STA_NODISK) return Stat; /* No card in the socket */
5638  
5639 for (n = 10; n; n--) rcvr_spi(); /* 80 dummy clocks */
5640 1f88: 91 50 subi r25, 0x01 ; 1
5641 1f8a: c1 f7 brne .-16 ; 0x1f7c <disk_initialize+0x20>
5642  
5643 SELECT(); /* CS = L */
5644 1f8c: 2a 98 cbi 0x05, 2 ; 5
5645 ty = 0;
5646 if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
5647 1f8e: 40 e0 ldi r20, 0x00 ; 0
5648 1f90: 50 e0 ldi r21, 0x00 ; 0
5649 1f92: 60 e0 ldi r22, 0x00 ; 0
5650 1f94: 70 e0 ldi r23, 0x00 ; 0
5651 1f96: 80 e4 ldi r24, 0x40 ; 64
5652 1f98: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5653 1f9c: 81 30 cpi r24, 0x01 ; 1
5654 1f9e: 09 f0 breq .+2 ; 0x1fa2 <disk_initialize+0x46>
5655 1fa0: a0 c0 rjmp .+320 ; 0x20e2 <disk_initialize+0x186>
5656 Timer1 = 100; /* Initialization timeout of 1000 msec */
5657 1fa2: 84 e6 ldi r24, 0x64 ; 100
5658 1fa4: 80 93 0f 01 sts 0x010F, r24
5659 if (send_cmd(CMD8, 0x1AA) == 1) { /* SDC Ver2+ */
5660 1fa8: 4a ea ldi r20, 0xAA ; 170
5661 1faa: 51 e0 ldi r21, 0x01 ; 1
5662 1fac: 60 e0 ldi r22, 0x00 ; 0
5663 1fae: 70 e0 ldi r23, 0x00 ; 0
5664 1fb0: 88 e4 ldi r24, 0x48 ; 72
5665 1fb2: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5666 1fb6: 81 30 cpi r24, 0x01 ; 1
5667 1fb8: 09 f0 breq .+2 ; 0x1fbc <disk_initialize+0x60>
5668 1fba: 54 c0 rjmp .+168 ; 0x2064 <disk_initialize+0x108>
5669 1fbc: 7e 01 movw r14, r28
5670 1fbe: 08 94 sec
5671 1fc0: e1 1c adc r14, r1
5672 1fc2: f1 1c adc r15, r1
5673 1fc4: 87 01 movw r16, r14
5674 for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
5675 1fc6: 9e 01 movw r18, r28
5676 1fc8: 2b 5f subi r18, 0xFB ; 251
5677 1fca: 3f 4f sbci r19, 0xFF ; 255
5678 /*-----------------------------------------------------------------------*/
5679  
5680 static
5681 BYTE rcvr_spi (void)
5682 {
5683 SPDR = 0xFF;
5684 1fcc: 8f ef ldi r24, 0xFF ; 255
5685 1fce: 8e bd out 0x2e, r24 ; 46
5686 loop_until_bit_is_set(SPSR, SPIF);
5687 1fd0: 0d b4 in r0, 0x2d ; 45
5688 1fd2: 07 fe sbrs r0, 7
5689 1fd4: fd cf rjmp .-6 ; 0x1fd0 <disk_initialize+0x74>
5690 return SPDR;
5691 1fd6: 8e b5 in r24, 0x2e ; 46
5692 SELECT(); /* CS = L */
5693 ty = 0;
5694 if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
5695 Timer1 = 100; /* Initialization timeout of 1000 msec */
5696 if (send_cmd(CMD8, 0x1AA) == 1) { /* SDC Ver2+ */
5697 for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
5698 1fd8: f8 01 movw r30, r16
5699 1fda: 81 93 st Z+, r24
5700 1fdc: 8f 01 movw r16, r30
5701 1fde: e2 17 cp r30, r18
5702 1fe0: f3 07 cpc r31, r19
5703 1fe2: a1 f7 brne .-24 ; 0x1fcc <disk_initialize+0x70>
5704 if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */
5705 1fe4: 8b 81 ldd r24, Y+3 ; 0x03
5706 1fe6: 81 30 cpi r24, 0x01 ; 1
5707 1fe8: 09 f0 breq .+2 ; 0x1fec <disk_initialize+0x90>
5708 1fea: 7b c0 rjmp .+246 ; 0x20e2 <disk_initialize+0x186>
5709 1fec: 8c 81 ldd r24, Y+4 ; 0x04
5710 1fee: 8a 3a cpi r24, 0xAA ; 170
5711 1ff0: 09 f0 breq .+2 ; 0x1ff4 <disk_initialize+0x98>
5712 1ff2: 77 c0 rjmp .+238 ; 0x20e2 <disk_initialize+0x186>
5713 do {
5714 if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 1UL << 30) == 0) break; /* ACMD41 with HCS bit */
5715 1ff4: 40 e0 ldi r20, 0x00 ; 0
5716 1ff6: 50 e0 ldi r21, 0x00 ; 0
5717 1ff8: 60 e0 ldi r22, 0x00 ; 0
5718 1ffa: 70 e0 ldi r23, 0x00 ; 0
5719 1ffc: 87 e7 ldi r24, 0x77 ; 119
5720 1ffe: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5721 2002: 82 30 cpi r24, 0x02 ; 2
5722 2004: 48 f4 brcc .+18 ; 0x2018 <disk_initialize+0xbc>
5723 2006: 40 e0 ldi r20, 0x00 ; 0
5724 2008: 50 e0 ldi r21, 0x00 ; 0
5725 200a: 60 e0 ldi r22, 0x00 ; 0
5726 200c: 70 e4 ldi r23, 0x40 ; 64
5727 200e: 89 e6 ldi r24, 0x69 ; 105
5728 2010: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5729 2014: 88 23 and r24, r24
5730 2016: 21 f0 breq .+8 ; 0x2020 <disk_initialize+0xc4>
5731 } while (Timer1);
5732 2018: 80 91 0f 01 lds r24, 0x010F
5733 201c: 88 23 and r24, r24
5734 201e: 51 f7 brne .-44 ; 0x1ff4 <disk_initialize+0x98>
5735 if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit */
5736 2020: 80 91 0f 01 lds r24, 0x010F
5737 2024: 88 23 and r24, r24
5738 2026: 09 f4 brne .+2 ; 0x202a <disk_initialize+0xce>
5739 2028: 5c c0 rjmp .+184 ; 0x20e2 <disk_initialize+0x186>
5740 202a: 40 e0 ldi r20, 0x00 ; 0
5741 202c: 50 e0 ldi r21, 0x00 ; 0
5742 202e: 60 e0 ldi r22, 0x00 ; 0
5743 2030: 70 e0 ldi r23, 0x00 ; 0
5744 2032: 8a e7 ldi r24, 0x7A ; 122
5745 2034: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5746 2038: 88 23 and r24, r24
5747 203a: 09 f0 breq .+2 ; 0x203e <disk_initialize+0xe2>
5748 203c: 52 c0 rjmp .+164 ; 0x20e2 <disk_initialize+0x186>
5749 /*-----------------------------------------------------------------------*/
5750  
5751 static
5752 BYTE rcvr_spi (void)
5753 {
5754 SPDR = 0xFF;
5755 203e: 8f ef ldi r24, 0xFF ; 255
5756 2040: 8e bd out 0x2e, r24 ; 46
5757 loop_until_bit_is_set(SPSR, SPIF);
5758 2042: 0d b4 in r0, 0x2d ; 45
5759 2044: 07 fe sbrs r0, 7
5760 2046: fd cf rjmp .-6 ; 0x2042 <disk_initialize+0xe6>
5761 return SPDR;
5762 2048: 8e b5 in r24, 0x2e ; 46
5763 if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */
5764 do {
5765 if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 1UL << 30) == 0) break; /* ACMD41 with HCS bit */
5766 } while (Timer1);
5767 if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit */
5768 for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
5769 204a: f7 01 movw r30, r14
5770 204c: 81 93 st Z+, r24
5771 204e: 7f 01 movw r14, r30
5772 2050: e0 17 cp r30, r16
5773 2052: f1 07 cpc r31, r17
5774 2054: a1 f7 brne .-24 ; 0x203e <disk_initialize+0xe2>
5775 ty = (ocr[0] & 0x40) ? 6 : 2;
5776 2056: 89 81 ldd r24, Y+1 ; 0x01
5777 2058: 86 ff sbrs r24, 6
5778 205a: 02 c0 rjmp .+4 ; 0x2060 <disk_initialize+0x104>
5779 205c: 16 e0 ldi r17, 0x06 ; 6
5780 205e: 42 c0 rjmp .+132 ; 0x20e4 <disk_initialize+0x188>
5781 2060: 12 e0 ldi r17, 0x02 ; 2
5782 2062: 40 c0 rjmp .+128 ; 0x20e4 <disk_initialize+0x188>
5783 }
5784 }
5785 } else { /* SDC Ver1 or MMC */
5786 ty = (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 0) <= 1) ? 2 : 1; /* SDC : MMC */
5787 2064: 40 e0 ldi r20, 0x00 ; 0
5788 2066: 50 e0 ldi r21, 0x00 ; 0
5789 2068: 60 e0 ldi r22, 0x00 ; 0
5790 206a: 70 e0 ldi r23, 0x00 ; 0
5791 206c: 87 e7 ldi r24, 0x77 ; 119
5792 206e: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5793 2072: 82 30 cpi r24, 0x02 ; 2
5794 2074: 58 f4 brcc .+22 ; 0x208c <disk_initialize+0x130>
5795 2076: 40 e0 ldi r20, 0x00 ; 0
5796 2078: 50 e0 ldi r21, 0x00 ; 0
5797 207a: 60 e0 ldi r22, 0x00 ; 0
5798 207c: 70 e0 ldi r23, 0x00 ; 0
5799 207e: 89 e6 ldi r24, 0x69 ; 105
5800 2080: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5801 2084: 82 30 cpi r24, 0x02 ; 2
5802 2086: 10 f4 brcc .+4 ; 0x208c <disk_initialize+0x130>
5803 2088: 12 e0 ldi r17, 0x02 ; 2
5804 208a: 01 c0 rjmp .+2 ; 0x208e <disk_initialize+0x132>
5805 208c: 11 e0 ldi r17, 0x01 ; 1
5806 do {
5807 if (ty == 2) {
5808 208e: 12 30 cpi r17, 0x02 ; 2
5809 2090: 79 f4 brne .+30 ; 0x20b0 <disk_initialize+0x154>
5810 if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 0) == 0) break; /* ACMD41 */
5811 2092: 40 e0 ldi r20, 0x00 ; 0
5812 2094: 50 e0 ldi r21, 0x00 ; 0
5813 2096: 60 e0 ldi r22, 0x00 ; 0
5814 2098: 70 e0 ldi r23, 0x00 ; 0
5815 209a: 87 e7 ldi r24, 0x77 ; 119
5816 209c: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5817 20a0: 82 30 cpi r24, 0x02 ; 2
5818 20a2: 78 f4 brcc .+30 ; 0x20c2 <disk_initialize+0x166>
5819 20a4: 40 e0 ldi r20, 0x00 ; 0
5820 20a6: 50 e0 ldi r21, 0x00 ; 0
5821 20a8: 60 e0 ldi r22, 0x00 ; 0
5822 20aa: 70 e0 ldi r23, 0x00 ; 0
5823 20ac: 89 e6 ldi r24, 0x69 ; 105
5824 20ae: 05 c0 rjmp .+10 ; 0x20ba <disk_initialize+0x15e>
5825 } else {
5826 if (send_cmd(CMD1, 0) == 0) break; /* CMD1 */
5827 20b0: 40 e0 ldi r20, 0x00 ; 0
5828 20b2: 50 e0 ldi r21, 0x00 ; 0
5829 20b4: 60 e0 ldi r22, 0x00 ; 0
5830 20b6: 70 e0 ldi r23, 0x00 ; 0
5831 20b8: 81 e4 ldi r24, 0x41 ; 65
5832 20ba: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5833 20be: 88 23 and r24, r24
5834 20c0: 21 f0 breq .+8 ; 0x20ca <disk_initialize+0x16e>
5835 }
5836 } while (Timer1);
5837 20c2: 80 91 0f 01 lds r24, 0x010F
5838 20c6: 88 23 and r24, r24
5839 20c8: 11 f7 brne .-60 ; 0x208e <disk_initialize+0x132>
5840 if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Select R/W block length */
5841 20ca: 80 91 0f 01 lds r24, 0x010F
5842 20ce: 88 23 and r24, r24
5843 20d0: 41 f0 breq .+16 ; 0x20e2 <disk_initialize+0x186>
5844 20d2: 40 e0 ldi r20, 0x00 ; 0
5845 20d4: 52 e0 ldi r21, 0x02 ; 2
5846 20d6: 60 e0 ldi r22, 0x00 ; 0
5847 20d8: 70 e0 ldi r23, 0x00 ; 0
5848 20da: 80 e5 ldi r24, 0x50 ; 80
5849 20dc: 0e 94 65 0d call 0x1aca ; 0x1aca <send_cmd>
5850 20e0: 81 11 cpse r24, r1
5851 20e2: 10 e0 ldi r17, 0x00 ; 0
5852 ty = 0;
5853 }
5854 }
5855 CardType = ty;
5856 20e4: 10 93 11 01 sts 0x0111, r17
5857 DESELECT(); /* CS = H */
5858 20e8: 2a 9a sbi 0x05, 2 ; 5
5859 /*-----------------------------------------------------------------------*/
5860  
5861 static
5862 BYTE rcvr_spi (void)
5863 {
5864 SPDR = 0xFF;
5865 20ea: 8f ef ldi r24, 0xFF ; 255
5866 20ec: 8e bd out 0x2e, r24 ; 46
5867 loop_until_bit_is_set(SPSR, SPIF);
5868 20ee: 0d b4 in r0, 0x2d ; 45
5869 20f0: 07 fe sbrs r0, 7
5870 20f2: fd cf rjmp .-6 ; 0x20ee <disk_initialize+0x192>
5871 return SPDR;
5872 20f4: 8e b5 in r24, 0x2e ; 46
5873 }
5874 CardType = ty;
5875 DESELECT(); /* CS = H */
5876 rcvr_spi(); /* Idle (Release DO) */
5877  
5878 if (ty) { /* Initialization succeded */
5879 20f6: 11 23 and r17, r17
5880 20f8: 21 f0 breq .+8 ; 0x2102 <disk_initialize+0x1a6>
5881 Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */
5882 20fa: 80 91 04 01 lds r24, 0x0104
5883 20fe: 8e 7f andi r24, 0xFE ; 254
5884 2100: 03 c0 rjmp .+6 ; 0x2108 <disk_initialize+0x1ac>
5885 } else { /* Initialization failed */
5886 Stat |= STA_NOINIT; /* Set STA_NOINIT */
5887 2102: 80 91 04 01 lds r24, 0x0104
5888 2106: 81 60 ori r24, 0x01 ; 1
5889 2108: 80 93 04 01 sts 0x0104, r24
5890 }
5891  
5892 return Stat;
5893 210c: 80 91 04 01 lds r24, 0x0104
5894 2110: 99 27 eor r25, r25
5895 2112: e6 e0 ldi r30, 0x06 ; 6
5896 2114: 24 96 adiw r28, 0x04 ; 4
5897 2116: 0c 94 52 11 jmp 0x22a4 ; 0x22a4 <__epilogue_restores__+0x18>
5898  
5899 0000211a <strcpy_P>:
5900 211a: fb 01 movw r30, r22
5901 211c: dc 01 movw r26, r24
5902 211e: 05 90 lpm r0, Z+
5903 2120: 0d 92 st X+, r0
5904 2122: 00 20 and r0, r0
5905 2124: e1 f7 brne .-8 ; 0x211e <strcpy_P+0x4>
5906 2126: 08 95 ret
5907  
5908 00002128 <memcmp>:
5909 2128: fb 01 movw r30, r22
5910 212a: dc 01 movw r26, r24
5911 212c: 04 c0 rjmp .+8 ; 0x2136 <memcmp+0xe>
5912 212e: 8d 91 ld r24, X+
5913 2130: 01 90 ld r0, Z+
5914 2132: 80 19 sub r24, r0
5915 2134: 21 f4 brne .+8 ; 0x213e <memcmp+0x16>
5916 2136: 41 50 subi r20, 0x01 ; 1
5917 2138: 50 40 sbci r21, 0x00 ; 0
5918 213a: c8 f7 brcc .-14 ; 0x212e <memcmp+0x6>
5919 213c: 88 1b sub r24, r24
5920 213e: 99 0b sbc r25, r25
5921 2140: 08 95 ret
5922  
5923 00002142 <memcpy>:
5924 2142: fb 01 movw r30, r22
5925 2144: dc 01 movw r26, r24
5926 2146: 02 c0 rjmp .+4 ; 0x214c <memcpy+0xa>
5927 2148: 01 90 ld r0, Z+
5928 214a: 0d 92 st X+, r0
5929 214c: 41 50 subi r20, 0x01 ; 1
5930 214e: 50 40 sbci r21, 0x00 ; 0
5931 2150: d8 f7 brcc .-10 ; 0x2148 <memcpy+0x6>
5932 2152: 08 95 ret
5933  
5934 00002154 <memset>:
5935 2154: dc 01 movw r26, r24
5936 2156: 01 c0 rjmp .+2 ; 0x215a <memset+0x6>
5937 2158: 6d 93 st X+, r22
5938 215a: 41 50 subi r20, 0x01 ; 1
5939 215c: 50 40 sbci r21, 0x00 ; 0
5940 215e: e0 f7 brcc .-8 ; 0x2158 <memset+0x4>
5941 2160: 08 95 ret
5942  
5943 00002162 <strcpy>:
5944 2162: fb 01 movw r30, r22
5945 2164: dc 01 movw r26, r24
5946 2166: 01 90 ld r0, Z+
5947 2168: 0d 92 st X+, r0
5948 216a: 00 20 and r0, r0
5949 216c: e1 f7 brne .-8 ; 0x2166 <strcpy+0x4>
5950 216e: 08 95 ret
5951  
5952 00002170 <itoa>:
5953 2170: fb 01 movw r30, r22
5954 2172: 9f 01 movw r18, r30
5955 2174: e8 94 clt
5956 2176: 42 30 cpi r20, 0x02 ; 2
5957 2178: c4 f0 brlt .+48 ; 0x21aa <itoa+0x3a>
5958 217a: 45 32 cpi r20, 0x25 ; 37
5959 217c: b4 f4 brge .+44 ; 0x21aa <itoa+0x3a>
5960 217e: 4a 30 cpi r20, 0x0A ; 10
5961 2180: 29 f4 brne .+10 ; 0x218c <itoa+0x1c>
5962 2182: 97 fb bst r25, 7
5963 2184: 1e f4 brtc .+6 ; 0x218c <itoa+0x1c>
5964 2186: 90 95 com r25
5965 2188: 81 95 neg r24
5966 218a: 9f 4f sbci r25, 0xFF ; 255
5967 218c: 64 2f mov r22, r20
5968 218e: 77 27 eor r23, r23
5969 2190: 0e 94 61 11 call 0x22c2 ; 0x22c2 <__udivmodhi4>
5970 2194: 80 5d subi r24, 0xD0 ; 208
5971 2196: 8a 33 cpi r24, 0x3A ; 58
5972 2198: 0c f0 brlt .+2 ; 0x219c <itoa+0x2c>
5973 219a: 89 5d subi r24, 0xD9 ; 217
5974 219c: 81 93 st Z+, r24
5975 219e: cb 01 movw r24, r22
5976 21a0: 00 97 sbiw r24, 0x00 ; 0
5977 21a2: a1 f7 brne .-24 ; 0x218c <itoa+0x1c>
5978 21a4: 16 f4 brtc .+4 ; 0x21aa <itoa+0x3a>
5979 21a6: 5d e2 ldi r21, 0x2D ; 45
5980 21a8: 51 93 st Z+, r21
5981 21aa: 10 82 st Z, r1
5982 21ac: c9 01 movw r24, r18
5983 21ae: 0c 94 d9 10 jmp 0x21b2 ; 0x21b2 <strrev>
5984  
5985 000021b2 <strrev>:
5986 21b2: dc 01 movw r26, r24
5987 21b4: fc 01 movw r30, r24
5988 21b6: 67 2f mov r22, r23
5989 21b8: 71 91 ld r23, Z+
5990 21ba: 77 23 and r23, r23
5991 21bc: e1 f7 brne .-8 ; 0x21b6 <strrev+0x4>
5992 21be: 32 97 sbiw r30, 0x02 ; 2
5993 21c0: 04 c0 rjmp .+8 ; 0x21ca <strrev+0x18>
5994 21c2: 7c 91 ld r23, X
5995 21c4: 6d 93 st X+, r22
5996 21c6: 70 83 st Z, r23
5997 21c8: 62 91 ld r22, -Z
5998 21ca: ae 17 cp r26, r30
5999 21cc: bf 07 cpc r27, r31
6000 21ce: c8 f3 brcs .-14 ; 0x21c2 <strrev+0x10>
6001 21d0: 08 95 ret
6002  
6003 000021d2 <__mulsi3>:
6004 21d2: 62 9f mul r22, r18
6005 21d4: d0 01 movw r26, r0
6006 21d6: 73 9f mul r23, r19
6007 21d8: f0 01 movw r30, r0
6008 21da: 82 9f mul r24, r18
6009 21dc: e0 0d add r30, r0
6010 21de: f1 1d adc r31, r1
6011 21e0: 64 9f mul r22, r20
6012 21e2: e0 0d add r30, r0
6013 21e4: f1 1d adc r31, r1
6014 21e6: 92 9f mul r25, r18
6015 21e8: f0 0d add r31, r0
6016 21ea: 83 9f mul r24, r19
6017 21ec: f0 0d add r31, r0
6018 21ee: 74 9f mul r23, r20
6019 21f0: f0 0d add r31, r0
6020 21f2: 65 9f mul r22, r21
6021 21f4: f0 0d add r31, r0
6022 21f6: 99 27 eor r25, r25
6023 21f8: 72 9f mul r23, r18
6024 21fa: b0 0d add r27, r0
6025 21fc: e1 1d adc r30, r1
6026 21fe: f9 1f adc r31, r25
6027 2200: 63 9f mul r22, r19
6028 2202: b0 0d add r27, r0
6029 2204: e1 1d adc r30, r1
6030 2206: f9 1f adc r31, r25
6031 2208: bd 01 movw r22, r26
6032 220a: cf 01 movw r24, r30
6033 220c: 11 24 eor r1, r1
6034 220e: 08 95 ret
6035  
6036 00002210 <__udivmodsi4>:
6037 2210: a1 e2 ldi r26, 0x21 ; 33
6038 2212: 1a 2e mov r1, r26
6039 2214: aa 1b sub r26, r26
6040 2216: bb 1b sub r27, r27
6041 2218: fd 01 movw r30, r26
6042 221a: 0d c0 rjmp .+26 ; 0x2236 <__udivmodsi4_ep>
6043  
6044 0000221c <__udivmodsi4_loop>:
6045 221c: aa 1f adc r26, r26
6046 221e: bb 1f adc r27, r27
6047 2220: ee 1f adc r30, r30
6048 2222: ff 1f adc r31, r31
6049 2224: a2 17 cp r26, r18
6050 2226: b3 07 cpc r27, r19
6051 2228: e4 07 cpc r30, r20
6052 222a: f5 07 cpc r31, r21
6053 222c: 20 f0 brcs .+8 ; 0x2236 <__udivmodsi4_ep>
6054 222e: a2 1b sub r26, r18
6055 2230: b3 0b sbc r27, r19
6056 2232: e4 0b sbc r30, r20
6057 2234: f5 0b sbc r31, r21
6058  
6059 00002236 <__udivmodsi4_ep>:
6060 2236: 66 1f adc r22, r22
6061 2238: 77 1f adc r23, r23
6062 223a: 88 1f adc r24, r24
6063 223c: 99 1f adc r25, r25
6064 223e: 1a 94 dec r1
6065 2240: 69 f7 brne .-38 ; 0x221c <__udivmodsi4_loop>
6066 2242: 60 95 com r22
6067 2244: 70 95 com r23
6068 2246: 80 95 com r24
6069 2248: 90 95 com r25
6070 224a: 9b 01 movw r18, r22
6071 224c: ac 01 movw r20, r24
6072 224e: bd 01 movw r22, r26
6073 2250: cf 01 movw r24, r30
6074 2252: 08 95 ret
6075  
6076 00002254 <__prologue_saves__>:
6077 2254: 2f 92 push r2
6078 2256: 3f 92 push r3
6079 2258: 4f 92 push r4
6080 225a: 5f 92 push r5
6081 225c: 6f 92 push r6
6082 225e: 7f 92 push r7
6083 2260: 8f 92 push r8
6084 2262: 9f 92 push r9
6085 2264: af 92 push r10
6086 2266: bf 92 push r11
6087 2268: cf 92 push r12
6088 226a: df 92 push r13
6089 226c: ef 92 push r14
6090 226e: ff 92 push r15
6091 2270: 0f 93 push r16
6092 2272: 1f 93 push r17
6093 2274: cf 93 push r28
6094 2276: df 93 push r29
6095 2278: cd b7 in r28, 0x3d ; 61
6096 227a: de b7 in r29, 0x3e ; 62
6097 227c: ca 1b sub r28, r26
6098 227e: db 0b sbc r29, r27
6099 2280: 0f b6 in r0, 0x3f ; 63
6100 2282: f8 94 cli
6101 2284: de bf out 0x3e, r29 ; 62
6102 2286: 0f be out 0x3f, r0 ; 63
6103 2288: cd bf out 0x3d, r28 ; 61
6104 228a: 09 94 ijmp
6105  
6106 0000228c <__epilogue_restores__>:
6107 228c: 2a 88 ldd r2, Y+18 ; 0x12
6108 228e: 39 88 ldd r3, Y+17 ; 0x11
6109 2290: 48 88 ldd r4, Y+16 ; 0x10
6110 2292: 5f 84 ldd r5, Y+15 ; 0x0f
6111 2294: 6e 84 ldd r6, Y+14 ; 0x0e
6112 2296: 7d 84 ldd r7, Y+13 ; 0x0d
6113 2298: 8c 84 ldd r8, Y+12 ; 0x0c
6114 229a: 9b 84 ldd r9, Y+11 ; 0x0b
6115 229c: aa 84 ldd r10, Y+10 ; 0x0a
6116 229e: b9 84 ldd r11, Y+9 ; 0x09
6117 22a0: c8 84 ldd r12, Y+8 ; 0x08
6118 22a2: df 80 ldd r13, Y+7 ; 0x07
6119 22a4: ee 80 ldd r14, Y+6 ; 0x06
6120 22a6: fd 80 ldd r15, Y+5 ; 0x05
6121 22a8: 0c 81 ldd r16, Y+4 ; 0x04
6122 22aa: 1b 81 ldd r17, Y+3 ; 0x03
6123 22ac: aa 81 ldd r26, Y+2 ; 0x02
6124 22ae: b9 81 ldd r27, Y+1 ; 0x01
6125 22b0: ce 0f add r28, r30
6126 22b2: d1 1d adc r29, r1
6127 22b4: 0f b6 in r0, 0x3f ; 63
6128 22b6: f8 94 cli
6129 22b8: de bf out 0x3e, r29 ; 62
6130 22ba: 0f be out 0x3f, r0 ; 63
6131 22bc: cd bf out 0x3d, r28 ; 61
6132 22be: ed 01 movw r28, r26
6133 22c0: 08 95 ret
6134  
6135 000022c2 <__udivmodhi4>:
6136 22c2: aa 1b sub r26, r26
6137 22c4: bb 1b sub r27, r27
6138 22c6: 51 e1 ldi r21, 0x11 ; 17
6139 22c8: 07 c0 rjmp .+14 ; 0x22d8 <__udivmodhi4_ep>
6140  
6141 000022ca <__udivmodhi4_loop>:
6142 22ca: aa 1f adc r26, r26
6143 22cc: bb 1f adc r27, r27
6144 22ce: a6 17 cp r26, r22
6145 22d0: b7 07 cpc r27, r23
6146 22d2: 10 f0 brcs .+4 ; 0x22d8 <__udivmodhi4_ep>
6147 22d4: a6 1b sub r26, r22
6148 22d6: b7 0b sbc r27, r23
6149  
6150 000022d8 <__udivmodhi4_ep>:
6151 22d8: 88 1f adc r24, r24
6152 22da: 99 1f adc r25, r25
6153 22dc: 5a 95 dec r21
6154 22de: a9 f7 brne .-22 ; 0x22ca <__udivmodhi4_loop>
6155 22e0: 80 95 com r24
6156 22e2: 90 95 com r25
6157 22e4: bc 01 movw r22, r24
6158 22e6: cd 01 movw r24, r26
6159 22e8: 08 95 ret
6160  
6161 000022ea <_exit>:
6162 22ea: ff cf rjmp .-2 ; 0x22ea <_exit>