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
1296 kaklik 6  
1234 kaklik 7 CONTENTS, ALLOC, LOAD, DATA
1296 kaklik 8 1 .text 00002a28 00000000 00000000 00000074 2**1
1234 kaklik 9 CONTENTS, ALLOC, LOAD, READONLY, CODE
1296 kaklik 10 2 .bss 00000341 0080010c 00002a34 00002aa8 2**0
1234 kaklik 11 ALLOC
1296 kaklik 12 3 .stab 00002040 00000000 00000000 00002aa8 2**2
1234 kaklik 13 CONTENTS, READONLY, DEBUGGING
1296 kaklik 14 4 .stabstr 00000db4 00000000 00000000 00004ae8 2**0
1234 kaklik 15 CONTENTS, READONLY, DEBUGGING
1296 kaklik 16 5 .debug_aranges 00000060 00000000 00000000 0000589c 2**0
1234 kaklik 17 CONTENTS, READONLY, DEBUGGING
1296 kaklik 18 6 .debug_pubnames 0000019e 00000000 00000000 000058fc 2**0
1234 kaklik 19 CONTENTS, READONLY, DEBUGGING
1296 kaklik 20 7 .debug_info 00001f60 00000000 00000000 00005a9a 2**0
1234 kaklik 21 CONTENTS, READONLY, DEBUGGING
1296 kaklik 22 8 .debug_abbrev 000007b9 00000000 00000000 000079fa 2**0
1234 kaklik 23 CONTENTS, READONLY, DEBUGGING
1296 kaklik 24 9 .debug_line 00001b85 00000000 00000000 000081b3 2**0
1234 kaklik 25 CONTENTS, READONLY, DEBUGGING
1296 kaklik 26 10 .debug_frame 00000200 00000000 00000000 00009d38 2**2
1234 kaklik 27 CONTENTS, READONLY, DEBUGGING
1296 kaklik 28 11 .debug_str 000005cc 00000000 00000000 00009f38 2**0
1234 kaklik 29 CONTENTS, READONLY, DEBUGGING
1296 kaklik 30 12 .debug_loc 00002af1 00000000 00000000 0000a504 2**0
1234 kaklik 31 CONTENTS, READONLY, DEBUGGING
1296 kaklik 32 13 .debug_ranges 000001d0 00000000 00000000 0000cff5 2**0
1234 kaklik 33 CONTENTS, READONLY, DEBUGGING
34 Disassembly of section .text:
35  
36 00000000 <__vectors>:
1296 kaklik 37 0: 0c 94 41 00 jmp 0x82 ; 0x82 <__ctors_end>
38 4: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
39 8: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
40 c: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
41 10: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
42 14: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
43 18: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
44 1c: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
45 20: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
46 24: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
47 28: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
48 2c: 0c 94 18 03 jmp 0x630 ; 0x630 <__vector_11>
49 30: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
50 34: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
51 38: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
52 3c: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
53 40: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
54 44: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
55 48: 0c 94 b5 00 jmp 0x16a ; 0x16a <__vector_18>
56 4c: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
57 50: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
58 54: 0c 94 60 00 jmp 0xc0 ; 0xc0 <__vector_21>
59 58: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
60 5c: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
61 60: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
62 64: 0c 94 5e 00 jmp 0xbc ; 0xbc <__bad_interrupt>
1234 kaklik 63  
1296 kaklik 64 00000068 <__c.1757>:
65 68: 24 47 50 52 4d 43 00 $GPRMC.
1234 kaklik 66  
1296 kaklik 67 0000006f <__c.1755>:
68 6f: 24 47 50 47 47 41 00 $GPGGA.
1234 kaklik 69  
1296 kaklik 70 00000076 <__c.1753>:
71 76: 2e 6c 6f 67 00 .log.
1234 kaklik 72  
1296 kaklik 73 0000007b <__c.1747>:
74 7b: 24 47 50 52 4d 43 00 $GPRMC.
1234 kaklik 75  
1296 kaklik 76 00000082 <__ctors_end>:
77 82: 11 24 eor r1, r1
78 84: 1f be out 0x3f, r1 ; 63
79 86: cf ef ldi r28, 0xFF ; 255
80 88: d4 e0 ldi r29, 0x04 ; 4
81 8a: de bf out 0x3e, r29 ; 62
82 8c: cd bf out 0x3d, r28 ; 61
1234 kaklik 83  
1296 kaklik 84 0000008e <__do_copy_data>:
85 8e: 11 e0 ldi r17, 0x01 ; 1
86 90: a0 e0 ldi r26, 0x00 ; 0
87 92: b1 e0 ldi r27, 0x01 ; 1
88 94: e8 e2 ldi r30, 0x28 ; 40
89 96: fa e2 ldi r31, 0x2A ; 42
90 98: 02 c0 rjmp .+4 ; 0x9e <.do_copy_data_start>
1234 kaklik 91  
1296 kaklik 92 0000009a <.do_copy_data_loop>:
93 9a: 05 90 lpm r0, Z+
94 9c: 0d 92 st X+, r0
1234 kaklik 95  
1296 kaklik 96 0000009e <.do_copy_data_start>:
97 9e: ac 30 cpi r26, 0x0C ; 12
98 a0: b1 07 cpc r27, r17
99 a2: d9 f7 brne .-10 ; 0x9a <.do_copy_data_loop>
1234 kaklik 100  
1296 kaklik 101 000000a4 <__do_clear_bss>:
102 a4: 14 e0 ldi r17, 0x04 ; 4
103 a6: ac e0 ldi r26, 0x0C ; 12
1234 kaklik 104 a8: b1 e0 ldi r27, 0x01 ; 1
1296 kaklik 105 aa: 01 c0 rjmp .+2 ; 0xae <.do_clear_bss_start>
1234 kaklik 106  
1296 kaklik 107 000000ac <.do_clear_bss_loop>:
108 ac: 1d 92 st X+, r1
1234 kaklik 109  
1296 kaklik 110 000000ae <.do_clear_bss_start>:
111 ae: ad 34 cpi r26, 0x4D ; 77
112 b0: b1 07 cpc r27, r17
113 b2: e1 f7 brne .-8 ; 0xac <.do_clear_bss_loop>
114 b4: 0e 94 35 01 call 0x26a ; 0x26a <main>
115 b8: 0c 94 12 15 jmp 0x2a24 ; 0x2a24 <_exit>
1234 kaklik 116  
1296 kaklik 117 000000bc <__bad_interrupt>:
118 bc: 0c 94 00 00 jmp 0 ; 0x0 <__heap_end>
1234 kaklik 119  
1296 kaklik 120 000000c0 <__vector_21>:
1234 kaklik 121 /*---------------------------------------------------------*/
122 /* ADC interrupt */
123 /*---------------------------------------------------------*/
124  
125 ISR(ADC_vect)
126 {
1296 kaklik 127 c0: 1f 92 push r1
128 c2: 0f 92 push r0
129 c4: 0f b6 in r0, 0x3f ; 63
130 c6: 0f 92 push r0
131 c8: 11 24 eor r1, r1
132 ca: 2f 93 push r18
133 cc: 3f 93 push r19
134 ce: 8f 93 push r24
1234 kaklik 135 WORD n;
136 static BYTE l, h;
137  
138 n = ADC;
1296 kaklik 139 d0: 20 91 78 00 lds r18, 0x0078
140 d4: 30 91 79 00 lds r19, 0x0079
1234 kaklik 141  
142 if(ADMUX == POWER_check)
1296 kaklik 143 d8: 80 91 7c 00 lds r24, 0x007C
1234 kaklik 144 {
145 if (n < VTH_LOW) {
1296 kaklik 146 dc: 20 3d cpi r18, 0xD0 ; 208
147 de: 31 05 cpc r19, r1
148 e0: 70 f4 brcc .+28 ; 0xfe <__vector_21+0x3e>
1234 kaklik 149 if (l >= 15) {
1296 kaklik 150 e2: 80 91 0f 01 lds r24, 0x010F
151 e6: 8f 30 cpi r24, 0x0F ; 15
152 e8: 30 f0 brcs .+12 ; 0xf6 <__vector_21+0x36>
1234 kaklik 153 Stat |= 0x01;
1296 kaklik 154 ea: 80 91 6f 01 lds r24, 0x016F
155 ee: 81 60 ori r24, 0x01 ; 1
156 f0: 80 93 6f 01 sts 0x016F, r24
157 f4: 06 c0 rjmp .+12 ; 0x102 <__vector_21+0x42>
1234 kaklik 158 }
159 else {l++;}
1296 kaklik 160 f6: 8f 5f subi r24, 0xFF ; 255
161 f8: 80 93 0f 01 sts 0x010F, r24
162 fc: 02 c0 rjmp .+4 ; 0x102 <__vector_21+0x42>
1234 kaklik 163 }
164 else {l = 0;}
1296 kaklik 165 fe: 10 92 0f 01 sts 0x010F, r1
1234 kaklik 166  
167 if (n > VTH_HIGH) {
1296 kaklik 168 102: 81 e0 ldi r24, 0x01 ; 1
169 104: 2c 32 cpi r18, 0x2C ; 44
170 106: 38 07 cpc r19, r24
171 108: 70 f0 brcs .+28 ; 0x126 <__vector_21+0x66>
1234 kaklik 172 if (h >= 15) {
1296 kaklik 173 10a: 80 91 0e 01 lds r24, 0x010E
174 10e: 8f 30 cpi r24, 0x0F ; 15
175 110: 30 f0 brcs .+12 ; 0x11e <__vector_21+0x5e>
1234 kaklik 176 Stat &= 0xFE;
1296 kaklik 177 112: 80 91 6f 01 lds r24, 0x016F
178 116: 8e 7f andi r24, 0xFE ; 254
179 118: 80 93 6f 01 sts 0x016F, r24
180 11c: 06 c0 rjmp .+12 ; 0x12a <__vector_21+0x6a>
1234 kaklik 181 }
182 else {h++;}
1296 kaklik 183 11e: 8f 5f subi r24, 0xFF ; 255
184 120: 80 93 0e 01 sts 0x010E, r24
185 124: 02 c0 rjmp .+4 ; 0x12a <__vector_21+0x6a>
1234 kaklik 186 }
187 else {h = 0;}
1296 kaklik 188 126: 10 92 0e 01 sts 0x010E, r1
1234 kaklik 189  
190 battery = n;
1296 kaklik 191 12a: 30 93 75 01 sts 0x0175, r19
192 12e: 20 93 74 01 sts 0x0174, r18
1234 kaklik 193 ADMUX = ANALOG_IN1;
1296 kaklik 194 132: 82 e4 ldi r24, 0x42 ; 66
195 134: 80 93 7c 00 sts 0x007C, r24
1234 kaklik 196 }
197  
198 if(ADMUX == ANALOG_IN1)
1296 kaklik 199 138: 80 91 7c 00 lds r24, 0x007C
1234 kaklik 200 {
201 intensity = n;
1296 kaklik 202 13c: 30 93 10 02 sts 0x0210, r19
203 140: 20 93 0f 02 sts 0x020F, r18
1234 kaklik 204 ADMUX = POWER_check;
1296 kaklik 205 144: 81 e4 ldi r24, 0x41 ; 65
206 146: 80 93 7c 00 sts 0x007C, r24
1234 kaklik 207 }
208  
209 //!!!!
210 //Stat &= 0xFE;
211  
212 ADCSRA = _BV(ADEN)|_BV(ADSC)|_BV(ADIF)|_BV(ADIE)|0b111;
1296 kaklik 213 14a: 8f ed ldi r24, 0xDF ; 223
214 14c: 80 93 7a 00 sts 0x007A, r24
215 }
216 150: 8f 91 pop r24
217 152: 3f 91 pop r19
218 154: 2f 91 pop r18
219 156: 0f 90 pop r0
220 158: 0f be out 0x3f, r0 ; 63
221 15a: 0f 90 pop r0
222 15c: 1f 90 pop r1
223 15e: 18 95 reti
1234 kaklik 224  
1296 kaklik 225 00000160 <get_fattime>:
1234 kaklik 226 /* FatFs module. Any valid time must be returned even if */
227 /* the system does not support a real time clock. */
228  
229  
230 DWORD get_fattime ()
231 {
1296 kaklik 232 160: 60 e0 ldi r22, 0x00 ; 0
233 162: 70 e0 ldi r23, 0x00 ; 0
234 164: 81 ea ldi r24, 0xA1 ; 161
235 166: 96 e3 ldi r25, 0x36 ; 54
236 168: 08 95 ret
1234 kaklik 237  
1296 kaklik 238 0000016a <__vector_18>:
239 return d;
1234 kaklik 240 }
241  
242 /* USART0 RXC interrupt */
243 ISR(USART_RX_vect)
244 {
1296 kaklik 245 16a: 1f 92 push r1
246 16c: 0f 92 push r0
247 16e: 0f b6 in r0, 0x3f ; 63
248 170: 0f 92 push r0
249 172: 11 24 eor r1, r1
250 174: 8f 93 push r24
251 176: 9f 93 push r25
252 178: ef 93 push r30
253 17a: ff 93 push r31
1234 kaklik 254 uint8_t d, n, i;
255  
256  
257 d = UDR0;
1296 kaklik 258 17c: 90 91 c6 00 lds r25, 0x00C6
1234 kaklik 259 n = rxfifo.count;
1296 kaklik 260 180: 80 91 78 01 lds r24, 0x0178
1234 kaklik 261 if(n < sizeof(rxfifo.buff)) {
1296 kaklik 262 184: 86 39 cpi r24, 0x96 ; 150
263 186: 88 f4 brcc .+34 ; 0x1aa <__vector_18+0x40>
1234 kaklik 264 rxfifo.count = ++n;
1296 kaklik 265 188: 8f 5f subi r24, 0xFF ; 255
266 18a: 80 93 78 01 sts 0x0178, r24
1234 kaklik 267 i = rxfifo.idx_w;
1296 kaklik 268 18e: 80 91 76 01 lds r24, 0x0176
1234 kaklik 269 rxfifo.buff[i++] = d;
1296 kaklik 270 192: e8 2f mov r30, r24
271 194: f0 e0 ldi r31, 0x00 ; 0
272 196: ea 58 subi r30, 0x8A ; 138
273 198: fe 4f sbci r31, 0xFE ; 254
274 19a: 93 83 std Z+3, r25 ; 0x03
275 19c: 8f 5f subi r24, 0xFF ; 255
1234 kaklik 276 if(i >= sizeof(rxfifo.buff))
1296 kaklik 277 19e: 86 39 cpi r24, 0x96 ; 150
278 1a0: 08 f0 brcs .+2 ; 0x1a4 <__vector_18+0x3a>
279 1a2: 80 e0 ldi r24, 0x00 ; 0
1234 kaklik 280 i = 0;
281 rxfifo.idx_w = i;
1296 kaklik 282 1a4: 80 93 76 01 sts 0x0176, r24
283 1a8: 05 c0 rjmp .+10 ; 0x1b4 <__vector_18+0x4a>
1234 kaklik 284 } else {
285 Stat |= 2;
1296 kaklik 286 1aa: 80 91 6f 01 lds r24, 0x016F
287 1ae: 82 60 ori r24, 0x02 ; 2
288 1b0: 80 93 6f 01 sts 0x016F, r24
289 }
290 }
291 1b4: ff 91 pop r31
292 1b6: ef 91 pop r30
293 1b8: 9f 91 pop r25
294 1ba: 8f 91 pop r24
295 1bc: 0f 90 pop r0
296 1be: 0f be out 0x3f, r0 ; 63
297 1c0: 0f 90 pop r0
298 1c2: 1f 90 pop r1
299 1c4: 18 95 reti
1234 kaklik 300  
1296 kaklik 301 000001c6 <get_line>:
1234 kaklik 302 /* Get a line received from GPS module */
303 /*----------------------------------------------------*/
304  
305 static
306 BYTE get_line (void) // 0: Power fail occured, >0: Number of bytes received.
307 {
1296 kaklik 308 1c6: 90 e0 ldi r25, 0x00 ; 0
309 cli();
310 UCSR0B = 0;
311 rxfifo.idx_r = 0;
312 rxfifo.idx_w = 0;
313 rxfifo.count = 0;
314 UBRR0L = SYSCLK/16/GPS_BAUDRATE;
1305 kaklik 315 1c8: 52 e8 ldi r21, 0x82 ; 130
1296 kaklik 316 UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0);
317 1ca: 48 e9 ldi r20, 0x98 ; 152
318 1cc: 01 c0 rjmp .+2 ; 0x1d0 <get_line+0xa>
319 /* Get a line received from GPS module */
320 /*----------------------------------------------------*/
321  
322 static
323 BYTE get_line (void) // 0: Power fail occured, >0: Number of bytes received.
324 {
325 1ce: 90 e0 ldi r25, 0x00 ; 0
1234 kaklik 326 BYTE c, i = 0;
327  
328  
329 for (;;) {
330 if (Stat & 1) return 0; // When power fail is detected, return with zero.
1296 kaklik 331 1d0: 80 91 6f 01 lds r24, 0x016F
332 1d4: 80 fd sbrc r24, 0
333 1d6: 46 c0 rjmp .+140 ; 0x264 <get_line+0x9e>
1234 kaklik 334 uint8_t uart_get ()
335 {
336 uint8_t d, i;
337  
338  
339 i = rxfifo.idx_r;
1296 kaklik 340 1d8: 30 91 77 01 lds r19, 0x0177
1234 kaklik 341 if (rxfifo.count == 0) return 0;
1296 kaklik 342 1dc: 80 91 78 01 lds r24, 0x0178
343 1e0: 88 23 and r24, r24
344 1e2: 11 f4 brne .+4 ; 0x1e8 <get_line+0x22>
345 1e4: 20 e0 ldi r18, 0x00 ; 0
346 1e6: 13 c0 rjmp .+38 ; 0x20e <get_line+0x48>
1234 kaklik 347 d = rxfifo.buff[i++];
1296 kaklik 348 1e8: e3 2f mov r30, r19
349 1ea: f0 e0 ldi r31, 0x00 ; 0
350 1ec: ea 58 subi r30, 0x8A ; 138
351 1ee: fe 4f sbci r31, 0xFE ; 254
352 1f0: 23 81 ldd r18, Z+3 ; 0x03
353 1f2: e3 2f mov r30, r19
354 1f4: ef 5f subi r30, 0xFF ; 255
1234 kaklik 355 cli();
1296 kaklik 356 1f6: f8 94 cli
1234 kaklik 357 rxfifo.count--;
1296 kaklik 358 1f8: 80 91 78 01 lds r24, 0x0178
359 1fc: 81 50 subi r24, 0x01 ; 1
360 1fe: 80 93 78 01 sts 0x0178, r24
1234 kaklik 361 sei();
1296 kaklik 362 202: 78 94 sei
1234 kaklik 363 if(i >= sizeof(rxfifo.buff))
1296 kaklik 364 204: e6 39 cpi r30, 0x96 ; 150
365 206: 08 f0 brcs .+2 ; 0x20a <get_line+0x44>
366 208: e0 e0 ldi r30, 0x00 ; 0
1234 kaklik 367 i = 0;
368 rxfifo.idx_r = i;
1296 kaklik 369 20a: e0 93 77 01 sts 0x0177, r30
1234 kaklik 370  
371  
372 for (;;) {
373 if (Stat & 1) return 0; // When power fail is detected, return with zero.
374 c = uart_get();
1296 kaklik 375 if (Stat & 2) { // When buffer overflow has occured, restart to receive line.
376 20e: 80 91 6f 01 lds r24, 0x016F
377 212: 81 ff sbrs r24, 1
378 214: 14 c0 rjmp .+40 ; 0x23e <get_line+0x78>
1234 kaklik 379  
380  
1296 kaklik 381 static
382 void uart_init (void)
383 {
384 cli();
385 216: f8 94 cli
386 UCSR0B = 0;
387 218: 10 92 c1 00 sts 0x00C1, r1
388 rxfifo.idx_r = 0;
389 21c: 10 92 77 01 sts 0x0177, r1
390 rxfifo.idx_w = 0;
391 220: 10 92 76 01 sts 0x0176, r1
392 rxfifo.count = 0;
393 224: 10 92 78 01 sts 0x0178, r1
394 UBRR0L = SYSCLK/16/GPS_BAUDRATE;
395 228: 50 93 c4 00 sts 0x00C4, r21
396 UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0);
397 22c: 40 93 c1 00 sts 0x00C1, r20
398 Stat &= 0xFD; // Clear overflow flag
399 230: 80 91 6f 01 lds r24, 0x016F
400 234: 8d 7f andi r24, 0xFD ; 253
401 236: 80 93 6f 01 sts 0x016F, r24
402 sei();
403 23a: 78 94 sei
404 23c: c8 cf rjmp .-112 ; 0x1ce <get_line+0x8>
1234 kaklik 405 c = uart_get();
1296 kaklik 406 if (Stat & 2) { // When buffer overflow has occured, restart to receive line.
1234 kaklik 407 uart_init();
408 i = 0; c = 0;
409 }
410 if (!c || (i == 0 && c != '$')) continue;
1296 kaklik 411 23e: 22 23 and r18, r18
412 240: 39 f2 breq .-114 ; 0x1d0 <get_line+0xa>
413 242: 99 23 and r25, r25
414 244: 19 f4 brne .+6 ; 0x24c <get_line+0x86>
415 246: 24 32 cpi r18, 0x24 ; 36
416 248: 09 f0 breq .+2 ; 0x24c <get_line+0x86>
417 24a: c2 cf rjmp .-124 ; 0x1d0 <get_line+0xa>
1234 kaklik 418 Buff[i++] = c;
1296 kaklik 419 24c: e9 2f mov r30, r25
420 24e: f0 e0 ldi r31, 0x00 ; 0
421 250: e3 5e subi r30, 0xE3 ; 227
422 252: fe 4f sbci r31, 0xFE ; 254
423 254: 20 83 st Z, r18
424 256: 9f 5f subi r25, 0xFF ; 255
1234 kaklik 425 if (c == '\n') break;
1296 kaklik 426 258: 2a 30 cpi r18, 0x0A ; 10
427 25a: 29 f0 breq .+10 ; 0x266 <get_line+0xa0>
1234 kaklik 428 if (i >= sizeof(Buff)) i = 0;
1296 kaklik 429 25c: 92 35 cpi r25, 0x52 ; 82
430 25e: 08 f0 brcs .+2 ; 0x262 <get_line+0x9c>
431 260: b6 cf rjmp .-148 ; 0x1ce <get_line+0x8>
432 262: b6 cf rjmp .-148 ; 0x1d0 <get_line+0xa>
433 264: 90 e0 ldi r25, 0x00 ; 0
1234 kaklik 434 }
435 return i;
436 }
1296 kaklik 437 266: 89 2f mov r24, r25
438 268: 08 95 ret
1234 kaklik 439  
1296 kaklik 440 0000026a <main>:
1234 kaklik 441 /*-----------------------------------------------------------------------*/
442 /* Main */
443  
444  
445 int main ()
446 {
1296 kaklik 447 26a: a2 e0 ldi r26, 0x02 ; 2
448 26c: b0 e0 ldi r27, 0x00 ; 0
449 26e: eb e3 ldi r30, 0x3B ; 59
450 270: f1 e0 ldi r31, 0x01 ; 1
451 272: 0c 94 c7 14 jmp 0x298e ; 0x298e <__prologue_saves__>
1234 kaklik 452  
453  
454 static
455 void ioinit (void)
456 {
457 PORTB = 0b00001101; // Port B
1296 kaklik 458 276: 8d e0 ldi r24, 0x0D ; 13
459 278: 85 b9 out 0x05, r24 ; 5
1234 kaklik 460 DDRB = 0b00101110;
1296 kaklik 461 27a: 8e e2 ldi r24, 0x2E ; 46
462 27c: 84 b9 out 0x04, r24 ; 4
1234 kaklik 463 PORTC = 0b00111111; // Port C
1296 kaklik 464 27e: 8f e3 ldi r24, 0x3F ; 63
465 280: 88 b9 out 0x08, r24 ; 8
1234 kaklik 466 DDRC = 0b00000000;
1296 kaklik 467 282: 17 b8 out 0x07, r1 ; 7
1234 kaklik 468 PORTD = 0b10101110; // Port D
1296 kaklik 469 284: 8e ea ldi r24, 0xAE ; 174
470 286: 8b b9 out 0x0b, r24 ; 11
1234 kaklik 471 DDRD = 0b01010010;
1296 kaklik 472 288: 82 e5 ldi r24, 0x52 ; 82
473 28a: 8a b9 out 0x0a, r24 ; 10
1234 kaklik 474  
475 SPCR = 0b01010000; /* Initialize SPI port (Mode 0) */
1296 kaklik 476 28c: 80 e5 ldi r24, 0x50 ; 80
477 28e: 8c bd out 0x2c, r24 ; 44
1234 kaklik 478 SPSR = 0b00000001;
1296 kaklik 479 290: 81 e0 ldi r24, 0x01 ; 1
480 292: 8d bd out 0x2d, r24 ; 45
1234 kaklik 481  
482 OCR1A = SYSCLK/8/100-1; // Timer1: 100Hz interval (OC1A)
1296 kaklik 483 294: 83 ed ldi r24, 0xD3 ; 211
484 296: 90 e3 ldi r25, 0x30 ; 48
485 298: 90 93 89 00 sts 0x0089, r25
486 29c: 80 93 88 00 sts 0x0088, r24
1234 kaklik 487 TCCR1B = 0b00001010;
1296 kaklik 488 2a0: 8a e0 ldi r24, 0x0A ; 10
489 2a2: 80 93 81 00 sts 0x0081, r24
1234 kaklik 490 TIMSK1 = _BV(OCIE1A); // Enable TC1.oca interrupt
1296 kaklik 491 2a6: 82 e0 ldi r24, 0x02 ; 2
492 2a8: 80 93 6f 00 sts 0x006F, r24
1234 kaklik 493  
494 OCR0A = SYSCLK/64/4000/2-1; // Timer0: 4kHz sound (OC0A)
1296 kaklik 495 2ac: 82 e1 ldi r24, 0x12 ; 18
496 2ae: 87 bd out 0x27, r24 ; 39
1234 kaklik 497 TCCR0A = 0b01000010;
1296 kaklik 498 2b0: 82 e4 ldi r24, 0x42 ; 66
499 2b2: 84 bd out 0x24, r24 ; 36
1234 kaklik 500  
501 ADMUX = POWER_check; // Select ADC input
1296 kaklik 502 2b4: 81 e4 ldi r24, 0x41 ; 65
503 2b6: 80 93 7c 00 sts 0x007C, r24
1234 kaklik 504 ADCSRA = _BV(ADEN)|_BV(ADSC)|_BV(ADIF)|_BV(ADIE)|0b111;
1296 kaklik 505 2ba: 8f ed ldi r24, 0xDF ; 223
506 2bc: 80 93 7a 00 sts 0x007A, r24
1234 kaklik 507  
508 sei();
1296 kaklik 509 2c0: 78 94 sei
1234 kaklik 510 BYTE b, err, *p = NULL;
511 WORD s;
512  
513  
514 ioinit();
515 f_mount(0, &fatfs); /* Enable file I/O layer */
1296 kaklik 516 2c2: 6d e2 ldi r22, 0x2D ; 45
517 2c4: 72 e0 ldi r23, 0x02 ; 2
518 2c6: 80 e0 ldi r24, 0x00 ; 0
519 2c8: 0e 94 7f 09 call 0x12fe ; 0x12fe <f_mount>
520 2cc: ee 24 eor r14, r14
521 2ce: ff 24 eor r15, r15
522  
523 static
524 void beep (BYTE len, BYTE cnt)
525 {
526 while (cnt--) {
527 BEEP_ON();
528 2d0: 53 e0 ldi r21, 0x03 ; 3
529 2d2: a5 2e mov r10, r21
530 DELAY(len);
531 2d4: 45 e0 ldi r20, 0x05 ; 5
532 2d6: b4 2e mov r11, r20
533 beep(5, 1); // Single beep. Start to get current time.
534 uart_init();
535 do { // Wait for valid RMC sentence.
536 b = get_line();
537 if (!b) break;
538 if (gp_comp(Buff, PSTR("$GPRMC"))) continue;
539 2d8: 3d e1 ldi r19, 0x1D ; 29
540 2da: c3 2e mov r12, r19
541 2dc: 31 e0 ldi r19, 0x01 ; 1
542 2de: d3 2e mov r13, r19
1234 kaklik 543 // || !gp_comp(Buff, PSTR("$GPGSV"))
544 // || !gp_comp(Buff, PSTR("$GPZDA"))
545 // || !gp_comp(Buff, PSTR("$GPVTG"))
546 )
547 {
548 if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
1296 kaklik 549 2e0: 4e 01 movw r8, r28
550 2e2: 08 94 sec
551 2e4: 81 1c adc r8, r1
552 2e6: 91 1c adc r9, r1
553 itoa(battery,&Value1,10); // convert number to character
554 2e8: 28 e1 ldi r18, 0x18 ; 24
555 2ea: 22 2e mov r2, r18
556 2ec: 21 e0 ldi r18, 0x01 ; 1
557 2ee: 32 2e mov r3, r18
558 itoa(intensity,&Value2,10);
559 2f0: 90 e7 ldi r25, 0x70 ; 112
560 2f2: 69 2e mov r6, r25
561 2f4: 91 e0 ldi r25, 0x01 ; 1
562 2f6: 79 2e mov r7, r25
563 sprintf(Buff,"%d,%d\n",Value1,Value2);
564 2f8: 80 e0 ldi r24, 0x00 ; 0
565 2fa: 48 2e mov r4, r24
566 2fc: 81 e0 ldi r24, 0x01 ; 1
567 2fe: 58 2e mov r5, r24
1234 kaklik 568  
569  
570 static
571 void uart_stop (void)
572 {
573 UCSR0B = 0;
1296 kaklik 574 300: 10 92 c1 00 sts 0x00C1, r1
1234 kaklik 575 ioinit();
576 f_mount(0, &fatfs); /* Enable file I/O layer */
577  
578 for (;;) {
579 uart_stop();
580 GPS_OFF();
1296 kaklik 581 304: 29 98 cbi 0x05, 1 ; 5
1234 kaklik 582 Timer = 100;
1296 kaklik 583 306: 84 e6 ldi r24, 0x64 ; 100
584 308: 80 93 1c 01 sts 0x011C, r24
1234 kaklik 585 do {
586 if (Stat & 1) Timer = 100;
1296 kaklik 587 30c: 94 e6 ldi r25, 0x64 ; 100
588 30e: 80 91 6f 01 lds r24, 0x016F
589 312: 80 ff sbrs r24, 0
590 314: 02 c0 rjmp .+4 ; 0x31a <main+0xb0>
591 316: 90 93 1c 01 sts 0x011C, r25
1234 kaklik 592 } while (Timer);
1296 kaklik 593 31a: 80 91 1c 01 lds r24, 0x011C
594 31e: 88 23 and r24, r24
595 320: b1 f7 brne .-20 ; 0x30e <main+0xa4>
1234 kaklik 596  
597 GPS_ON();
1296 kaklik 598 322: 29 9a sbi 0x05, 1 ; 5
1234 kaklik 599 Timer = 255;
1296 kaklik 600 324: 8f ef ldi r24, 0xFF ; 255
601 326: 80 93 1c 01 sts 0x011C, r24
1234 kaklik 602 do {
603 if ((Stat & 1) || (disk_status(0) & STA_NODISK)) Timer = 255;
1296 kaklik 604 32a: 1f ef ldi r17, 0xFF ; 255
605 32c: 80 91 6f 01 lds r24, 0x016F
606 330: 80 fd sbrc r24, 0
607 332: 05 c0 rjmp .+10 ; 0x33e <main+0xd4>
608 334: 80 e0 ldi r24, 0x00 ; 0
609 336: 0e 94 95 0f call 0x1f2a ; 0x1f2a <disk_status>
610 33a: 81 ff sbrs r24, 1
611 33c: 02 c0 rjmp .+4 ; 0x342 <main+0xd8>
612 33e: 10 93 1c 01 sts 0x011C, r17
1234 kaklik 613 } while (Timer);
1296 kaklik 614 342: 80 91 1c 01 lds r24, 0x011C
615 346: 88 23 and r24, r24
616 348: 89 f7 brne .-30 ; 0x32c <main+0xc2>
617 34a: 91 e0 ldi r25, 0x01 ; 1
618 34c: 0e c0 rjmp .+28 ; 0x36a <main+0x100>
1234 kaklik 619  
620 static
1296 kaklik 621 void beep (BYTE len, BYTE cnt)
1234 kaklik 622 {
1296 kaklik 623 while (cnt--) {
624 BEEP_ON();
625 34e: a5 bc out 0x25, r10 ; 37
626 DELAY(len);
627 350: b0 92 1c 01 sts 0x011C, r11
628 354: 80 91 1c 01 lds r24, 0x011C
629 358: 88 23 and r24, r24
630 35a: e1 f7 brne .-8 ; 0x354 <main+0xea>
631 BEEP_OFF();
632 35c: 15 bc out 0x25, r1 ; 37
633 DELAY(len);
634 35e: b0 92 1c 01 sts 0x011C, r11
635 362: 80 91 1c 01 lds r24, 0x011C
636 366: 88 23 and r24, r24
637 368: e1 f7 brne .-8 ; 0x362 <main+0xf8>
638 /* Controls */
1234 kaklik 639  
640 static
1296 kaklik 641 void beep (BYTE len, BYTE cnt)
1234 kaklik 642 {
1296 kaklik 643 while (cnt--) {
644 36a: 91 50 subi r25, 0x01 ; 1
645 36c: 80 f7 brcc .-32 ; 0x34e <main+0xe4>
646  
647  
648 static
649 void uart_init (void)
1234 kaklik 650 {
1296 kaklik 651 cli();
652 36e: f8 94 cli
653 UCSR0B = 0;
654 370: 10 92 c1 00 sts 0x00C1, r1
655 rxfifo.idx_r = 0;
656 374: 10 92 77 01 sts 0x0177, r1
657 rxfifo.idx_w = 0;
658 378: 10 92 76 01 sts 0x0176, r1
659 rxfifo.count = 0;
660 37c: 10 92 78 01 sts 0x0178, r1
661 UBRR0L = SYSCLK/16/GPS_BAUDRATE;
1305 kaklik 662 380: 82 e8 ldi r24, 0x82 ; 130
1296 kaklik 663 382: 80 93 c4 00 sts 0x00C4, r24
664 UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0);
665 386: 88 e9 ldi r24, 0x98 ; 152
666 388: 80 93 c1 00 sts 0x00C1, r24
667 Stat &= 0xFD; // Clear overflow flag
668 38c: 80 91 6f 01 lds r24, 0x016F
669 390: 8d 7f andi r24, 0xFD ; 253
670 392: 80 93 6f 01 sts 0x016F, r24
671 sei();
672 396: 78 94 sei
673 398: 02 c0 rjmp .+4 ; 0x39e <main+0x134>
674 39a: ee 24 eor r14, r14
675 39c: ff 24 eor r15, r15
676 } while (Timer);
1234 kaklik 677  
678 beep(5, 1); // Single beep. Start to get current time.
679 uart_init();
680 do { // Wait for valid RMC sentence.
681 b = get_line();
1296 kaklik 682 39e: 0e 94 e3 00 call 0x1c6 ; 0x1c6 <get_line>
1234 kaklik 683 if (!b) break;
1296 kaklik 684 3a2: 88 23 and r24, r24
685 3a4: 09 f4 brne .+2 ; 0x3a8 <main+0x13e>
686 3a6: ac cf rjmp .-168 ; 0x300 <main+0x96>
1234 kaklik 687 if (gp_comp(Buff, PSTR("$GPRMC"))) continue;
1296 kaklik 688 3a8: 2b e7 ldi r18, 0x7B ; 123
689 3aa: 30 e0 ldi r19, 0x00 ; 0
690 3ac: ad e1 ldi r26, 0x1D ; 29
691 3ae: b1 e0 ldi r27, 0x01 ; 1
692 3b0: f9 01 movw r30, r18
693 BYTE gp_comp (BYTE *str1, const prog_uint8_t *str2)
694 {
695 BYTE c;
696  
697 do {
698 c = pgm_read_byte(str2++);
699 3b2: 2f 5f subi r18, 0xFF ; 255
700 3b4: 3f 4f sbci r19, 0xFF ; 255
701 3b6: 94 91 lpm r25, Z
702 } while (c && c == *str1++);
703 3b8: 99 23 and r25, r25
704 3ba: 29 f0 breq .+10 ; 0x3c6 <main+0x15c>
705 3bc: 8c 91 ld r24, X
706 3be: 98 17 cp r25, r24
707 3c0: 71 f4 brne .+28 ; 0x3de <main+0x174>
708 3c2: 11 96 adiw r26, 0x01 ; 1
709 3c4: f5 cf rjmp .-22 ; 0x3b0 <main+0x146>
710 3c6: ed e1 ldi r30, 0x1D ; 29
711 3c8: f1 e0 ldi r31, 0x01 ; 1
712 3ca: 82 e0 ldi r24, 0x02 ; 2
713 BYTE c;
714  
715  
716 while (col) {
717 do {
718 c = *buf++;
719 3cc: 90 81 ld r25, Z
720 if (c <= ' ') return NULL;
721 3ce: 91 32 cpi r25, 0x21 ; 33
722 3d0: 20 f3 brcs .-56 ; 0x39a <main+0x130>
723 BYTE c;
724  
725  
726 while (col) {
727 do {
728 c = *buf++;
729 3d2: 31 96 adiw r30, 0x01 ; 1
730 if (c <= ' ') return NULL;
731 } while (c != ',');
732 3d4: 9c 32 cpi r25, 0x2C ; 44
733 3d6: d1 f7 brne .-12 ; 0x3cc <main+0x162>
734 col--;
735 3d8: 81 50 subi r24, 0x01 ; 1
736 BYTE col /* Column number (0 is the 1st item) */
737 ) {
738 BYTE c;
739  
740  
741 while (col) {
742 3da: c1 f7 brne .-16 ; 0x3cc <main+0x162>
743 c = *buf++;
744 if (c <= ' ') return NULL;
745 } while (c != ',');
746 col--;
747 }
748 return (BYTE*)buf;
749 3dc: 7f 01 movw r14, r30
750 do { // Wait for valid RMC sentence.
751 b = get_line();
752 if (!b) break;
753 if (gp_comp(Buff, PSTR("$GPRMC"))) continue;
1234 kaklik 754 p = gp_col(Buff,2);
755 } while (!p || *p != 'A');
1296 kaklik 756 3de: e1 14 cp r14, r1
757 3e0: f1 04 cpc r15, r1
758 3e2: e9 f2 breq .-70 ; 0x39e <main+0x134>
759 3e4: f7 01 movw r30, r14
760 3e6: 80 81 ld r24, Z
761 3e8: 81 34 cpi r24, 0x41 ; 65
762 3ea: c9 f6 brne .-78 ; 0x39e <main+0x134>
763 3ec: ed e1 ldi r30, 0x1D ; 29
764 3ee: f1 e0 ldi r31, 0x01 ; 1
765 3f0: 89 e0 ldi r24, 0x09 ; 9
766 BYTE c;
767  
768  
769 while (col) {
770 do {
771 c = *buf++;
772 3f2: 90 81 ld r25, Z
773 if (c <= ' ') return NULL;
774 3f4: 91 32 cpi r25, 0x21 ; 33
775 3f6: 08 f4 brcc .+2 ; 0x3fa <main+0x190>
776 3f8: f0 c0 rjmp .+480 ; 0x5da <__stack+0xdb>
777 BYTE c;
778  
779  
780 while (col) {
781 do {
782 c = *buf++;
783 3fa: 31 96 adiw r30, 0x01 ; 1
784 if (c <= ' ') return NULL;
785 } while (c != ',');
786 3fc: 9c 32 cpi r25, 0x2C ; 44
787 3fe: c9 f7 brne .-14 ; 0x3f2 <main+0x188>
788 col--;
789 400: 81 50 subi r24, 0x01 ; 1
790 BYTE col /* Column number (0 is the 1st item) */
791 ) {
792 BYTE c;
793  
794  
795 while (col) {
796 402: b9 f7 brne .-18 ; 0x3f2 <main+0x188>
797 c = *buf++;
798 if (c <= ' ') return NULL;
799 } while (c != ',');
800 col--;
801 }
802 return (BYTE*)buf;
803 404: 7f 01 movw r14, r30
804 p = gp_col(Buff,2);
805 } while (!p || *p != 'A');
1234 kaklik 806 if (!b) continue;
807 p = gp_col(Buff,9); // Open log file with the name of current date (YYMMDD.log in UTC).
808  
809 if (!p) {err = 3; break;}
1296 kaklik 810 406: 30 97 sbiw r30, 0x00 ; 0
811 408: 09 f4 brne .+2 ; 0x40c <main+0x1a2>
812 40a: e7 c0 rjmp .+462 ; 0x5da <__stack+0xdb>
1234 kaklik 813  
814 memcpy(&Buff[0], p+4, 2);
1296 kaklik 815 40c: 84 81 ldd r24, Z+4 ; 0x04
816 40e: 95 81 ldd r25, Z+5 ; 0x05
817 410: 90 93 1e 01 sts 0x011E, r25
818 414: 80 93 1d 01 sts 0x011D, r24
1234 kaklik 819 memcpy(&Buff[2], p+2, 2);
1296 kaklik 820 418: 82 81 ldd r24, Z+2 ; 0x02
821 41a: 93 81 ldd r25, Z+3 ; 0x03
822 41c: 90 93 20 01 sts 0x0120, r25
823 420: 80 93 1f 01 sts 0x011F, r24
1234 kaklik 824 memcpy(&Buff[4], p+0, 2);
1296 kaklik 825 424: 80 81 ld r24, Z
826 426: 91 81 ldd r25, Z+1 ; 0x01
827 428: 90 93 22 01 sts 0x0122, r25
828 42c: 80 93 21 01 sts 0x0121, r24
1234 kaklik 829 strcpy_P(&Buff[6], PSTR(".log"));
1296 kaklik 830 430: 66 e7 ldi r22, 0x76 ; 118
831 432: 70 e0 ldi r23, 0x00 ; 0
832 434: 83 e2 ldi r24, 0x23 ; 35
833 436: 91 e0 ldi r25, 0x01 ; 1
834 438: 0e 94 8f 11 call 0x231e ; 0x231e <strcpy_P>
1234 kaklik 835 if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }
1296 kaklik 836 43c: 42 e1 ldi r20, 0x12 ; 18
837 43e: 6d e1 ldi r22, 0x1D ; 29
838 440: 71 e0 ldi r23, 0x01 ; 1
839 442: 81 e1 ldi r24, 0x11 ; 17
840 444: 92 e0 ldi r25, 0x02 ; 2
841 446: 0e 94 d7 09 call 0x13ae ; 0x13ae <f_open>
842 44a: 89 2b or r24, r25
843 44c: 09 f0 breq .+2 ; 0x450 <main+0x1e6>
844 44e: c7 c0 rjmp .+398 ; 0x5de <__stack+0xdf>
845 450: 40 91 1b 02 lds r20, 0x021B
846 454: 50 91 1c 02 lds r21, 0x021C
847 458: 60 91 1d 02 lds r22, 0x021D
848 45c: 70 91 1e 02 lds r23, 0x021E
849 460: 81 e1 ldi r24, 0x11 ; 17
850 462: 92 e0 ldi r25, 0x02 ; 2
851 464: 0e 94 3c 05 call 0xa78 ; 0xa78 <f_lseek>
852 468: 89 2b or r24, r25
853 46a: 09 f0 breq .+2 ; 0x46e <main+0x204>
854 46c: b8 c0 rjmp .+368 ; 0x5de <__stack+0xdf>
855 46e: 92 e0 ldi r25, 0x02 ; 2
856 470: 0e c0 rjmp .+28 ; 0x48e <main+0x224>
1234 kaklik 857  
1296 kaklik 858 static
859 void beep (BYTE len, BYTE cnt)
860 {
861 while (cnt--) {
862 BEEP_ON();
863 472: a5 bc out 0x25, r10 ; 37
864 DELAY(len);
865 474: b0 92 1c 01 sts 0x011C, r11
866 478: 80 91 1c 01 lds r24, 0x011C
867 47c: 88 23 and r24, r24
868 47e: e1 f7 brne .-8 ; 0x478 <main+0x20e>
869 BEEP_OFF();
870 480: 15 bc out 0x25, r1 ; 37
871 DELAY(len);
872 482: b0 92 1c 01 sts 0x011C, r11
873 486: 80 91 1c 01 lds r24, 0x011C
874 48a: 88 23 and r24, r24
875 48c: e1 f7 brne .-8 ; 0x486 <main+0x21c>
876 /* Controls */
877  
878 static
879 void beep (BYTE len, BYTE cnt)
880 {
881 while (cnt--) {
882 48e: 91 50 subi r25, 0x01 ; 1
883 490: 80 f7 brcc .-32 ; 0x472 <main+0x208>
884 492: 85 c0 rjmp .+266 ; 0x59e <__stack+0x9f>
885 if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }
886  
1234 kaklik 887 beep(5, 2); // Two beeps. Start logging.
888 err = 0;
889 while ((b = get_line()) > 0) {
890 if ( !gp_comp(Buff, PSTR("$GPGGA")) // Which sentence is logged?
1296 kaklik 891 494: 2f e6 ldi r18, 0x6F ; 111
892 496: 30 e0 ldi r19, 0x00 ; 0
893 498: ad e1 ldi r26, 0x1D ; 29
894 49a: b1 e0 ldi r27, 0x01 ; 1
895 49c: f9 01 movw r30, r18
896 BYTE gp_comp (BYTE *str1, const prog_uint8_t *str2)
897 {
898 BYTE c;
899  
900 do {
901 c = pgm_read_byte(str2++);
902 49e: 2f 5f subi r18, 0xFF ; 255
903 4a0: 3f 4f sbci r19, 0xFF ; 255
904 4a2: 94 91 lpm r25, Z
905 } while (c && c == *str1++);
906 4a4: 99 23 and r25, r25
907 4a6: 89 f0 breq .+34 ; 0x4ca <main+0x260>
908 4a8: 8c 91 ld r24, X
909 4aa: 98 17 cp r25, r24
910 4ac: 09 f0 breq .+2 ; 0x4b0 <main+0x246>
911 4ae: ae c0 rjmp .+348 ; 0x60c <__stack+0x10d>
912 4b0: 11 96 adiw r26, 0x01 ; 1
913 4b2: f4 cf rjmp .-24 ; 0x49c <main+0x232>
914 BYTE gp_comp (BYTE *str1, const prog_uint8_t *str2)
915 {
916 BYTE c;
917  
918 do {
919 c = pgm_read_byte(str2++);
920 4b4: 11 96 adiw r26, 0x01 ; 1
921 4b6: f9 01 movw r30, r18
922 4b8: 2f 5f subi r18, 0xFF ; 255
923 4ba: 3f 4f sbci r19, 0xFF ; 255
924 4bc: 94 91 lpm r25, Z
925 } while (c && c == *str1++);
926 4be: 99 23 and r25, r25
927 4c0: 21 f0 breq .+8 ; 0x4ca <main+0x260>
928 4c2: 8c 91 ld r24, X
929 4c4: 98 17 cp r25, r24
930 4c6: b1 f3 breq .-20 ; 0x4b4 <main+0x24a>
931 4c8: 57 c0 rjmp .+174 ; 0x578 <__stack+0x79>
1234 kaklik 932 // || !gp_comp(Buff, PSTR("$GPGSV"))
933 // || !gp_comp(Buff, PSTR("$GPZDA"))
934 // || !gp_comp(Buff, PSTR("$GPVTG"))
935 )
936 {
937 if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
1296 kaklik 938 4ca: 04 2f mov r16, r20
939 4cc: 10 e0 ldi r17, 0x00 ; 0
940 4ce: 94 01 movw r18, r8
941 4d0: a8 01 movw r20, r16
942 4d2: 6d e1 ldi r22, 0x1D ; 29
943 4d4: 71 e0 ldi r23, 0x01 ; 1
944 4d6: 81 e1 ldi r24, 0x11 ; 17
945 4d8: 92 e0 ldi r25, 0x02 ; 2
946 4da: 0e 94 0e 07 call 0xe1c ; 0xe1c <f_write>
947 4de: 89 2b or r24, r25
948 4e0: 09 f0 breq .+2 ; 0x4e4 <main+0x27a>
949 4e2: 64 c0 rjmp .+200 ; 0x5ac <__stack+0xad>
950 4e4: 89 81 ldd r24, Y+1 ; 0x01
951 4e6: 9a 81 ldd r25, Y+2 ; 0x02
952 4e8: 08 17 cp r16, r24
953 4ea: 19 07 cpc r17, r25
954 4ec: 09 f0 breq .+2 ; 0x4f0 <main+0x286>
955 4ee: 5e c0 rjmp .+188 ; 0x5ac <__stack+0xad>
956 itoa(battery,&Value1,10); // convert number to character
957 4f0: 4a e0 ldi r20, 0x0A ; 10
958 4f2: 50 e0 ldi r21, 0x00 ; 0
959 4f4: 68 e1 ldi r22, 0x18 ; 24
960 4f6: 71 e0 ldi r23, 0x01 ; 1
961 4f8: 80 91 74 01 lds r24, 0x0174
962 4fc: 90 91 75 01 lds r25, 0x0175
963 500: 0e 94 b3 11 call 0x2366 ; 0x2366 <itoa>
1234 kaklik 964 itoa(intensity,&Value2,10);
1296 kaklik 965 504: 4a e0 ldi r20, 0x0A ; 10
966 506: 50 e0 ldi r21, 0x00 ; 0
967 508: 60 e7 ldi r22, 0x70 ; 112
968 50a: 71 e0 ldi r23, 0x01 ; 1
969 50c: 80 91 0f 02 lds r24, 0x020F
970 510: 90 91 10 02 lds r25, 0x0210
971 514: 0e 94 b3 11 call 0x2366 ; 0x2366 <itoa>
972 sprintf(Buff,"%d,%d\n",Value1,Value2);
973 518: 7f 92 push r7
974 51a: 6f 92 push r6
975 51c: 3f 92 push r3
976 51e: 2f 92 push r2
977 520: 5f 92 push r5
978 522: 4f 92 push r4
979 524: df 92 push r13
980 526: cf 92 push r12
981 528: 0e 94 d4 11 call 0x23a8 ; 0x23a8 <sprintf>
982 if (f_write(&file1, Buff,strlen(Buff), &s) || (strlen(Buff) != s)) { err = 8; break; };
983 52c: f6 01 movw r30, r12
984 52e: 01 90 ld r0, Z+
985 530: 00 20 and r0, r0
986 532: e9 f7 brne .-6 ; 0x52e <__stack+0x2f>
987 534: 31 97 sbiw r30, 0x01 ; 1
988 536: ec 19 sub r30, r12
989 538: fd 09 sbc r31, r13
990 53a: 94 01 movw r18, r8
991 53c: af 01 movw r20, r30
992 53e: 6d e1 ldi r22, 0x1D ; 29
993 540: 71 e0 ldi r23, 0x01 ; 1
994 542: 81 e1 ldi r24, 0x11 ; 17
995 544: 92 e0 ldi r25, 0x02 ; 2
996 546: 0e 94 0e 07 call 0xe1c ; 0xe1c <f_write>
997 54a: 2d b7 in r18, 0x3d ; 61
998 54c: 3e b7 in r19, 0x3e ; 62
999 54e: 28 5f subi r18, 0xF8 ; 248
1000 550: 3f 4f sbci r19, 0xFF ; 255
1001 552: 0f b6 in r0, 0x3f ; 63
1002 554: f8 94 cli
1003 556: 3e bf out 0x3e, r19 ; 62
1004 558: 0f be out 0x3f, r0 ; 63
1005 55a: 2d bf out 0x3d, r18 ; 61
1006 55c: 89 2b or r24, r25
1007 55e: 41 f5 brne .+80 ; 0x5b0 <__stack+0xb1>
1008 560: d6 01 movw r26, r12
1009 562: 0d 90 ld r0, X+
1010 564: 00 20 and r0, r0
1011 566: e9 f7 brne .-6 ; 0x562 <__stack+0x63>
1012 568: 11 97 sbiw r26, 0x01 ; 1
1013 56a: ac 19 sub r26, r12
1014 56c: bd 09 sbc r27, r13
1015 56e: 89 81 ldd r24, Y+1 ; 0x01
1016 570: 9a 81 ldd r25, Y+2 ; 0x02
1017 572: a8 17 cp r26, r24
1018 574: b9 07 cpc r27, r25
1019 576: e1 f4 brne .+56 ; 0x5b0 <__stack+0xb1>
1234 kaklik 1020 }
1021 if ((Stat & 4) == 0) continue;
1296 kaklik 1022 578: 80 91 6f 01 lds r24, 0x016F
1023 57c: 82 ff sbrs r24, 2
1024 57e: 0f c0 rjmp .+30 ; 0x59e <__stack+0x9f>
1234 kaklik 1025 if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec.
1296 kaklik 1026 580: 81 e1 ldi r24, 0x11 ; 17
1027 582: 92 e0 ldi r25, 0x02 ; 2
1028 584: 0e 94 a9 06 call 0xd52 ; 0xd52 <f_sync>
1029 588: 89 2b or r24, r25
1030 58a: 11 f0 breq .+4 ; 0x590 <__stack+0x91>
1031 58c: 96 e0 ldi r25, 0x06 ; 6
1032 58e: 28 c0 rjmp .+80 ; 0x5e0 <__stack+0xe1>
1234 kaklik 1033 cli(); Stat &= 0xFB; sei(); // Clear sync request
1296 kaklik 1034 590: f8 94 cli
1035 592: 80 91 6f 01 lds r24, 0x016F
1036 596: 8b 7f andi r24, 0xFB ; 251
1037 598: 80 93 6f 01 sts 0x016F, r24
1038 59c: 78 94 sei
1234 kaklik 1039 strcpy_P(&Buff[6], PSTR(".log"));
1040 if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }
1041  
1042 beep(5, 2); // Two beeps. Start logging.
1043 err = 0;
1044 while ((b = get_line()) > 0) {
1296 kaklik 1045 59e: 0e 94 e3 00 call 0x1c6 ; 0x1c6 <get_line>
1046 5a2: 48 2f mov r20, r24
1047 5a4: 88 23 and r24, r24
1048 5a6: 09 f0 breq .+2 ; 0x5aa <__stack+0xab>
1049 5a8: 75 cf rjmp .-278 ; 0x494 <main+0x22a>
1050 5aa: 35 c0 rjmp .+106 ; 0x616 <__stack+0x117>
1051 5ac: 95 e0 ldi r25, 0x05 ; 5
1052 5ae: 18 c0 rjmp .+48 ; 0x5e0 <__stack+0xe1>
1053 5b0: 98 e0 ldi r25, 0x08 ; 8
1054 5b2: 16 c0 rjmp .+44 ; 0x5e0 <__stack+0xe1>
1234 kaklik 1055  
1296 kaklik 1056 static
1057 void beep (BYTE len, BYTE cnt)
1058 {
1059 while (cnt--) {
1060 BEEP_ON();
1061 5b4: a5 bc out 0x25, r10 ; 37
1062 DELAY(len);
1063 5b6: 32 e3 ldi r19, 0x32 ; 50
1064 5b8: 30 93 1c 01 sts 0x011C, r19
1065 5bc: 80 91 1c 01 lds r24, 0x011C
1066 5c0: 88 23 and r24, r24
1067 5c2: e1 f7 brne .-8 ; 0x5bc <__stack+0xbd>
1068 BEEP_OFF();
1069 5c4: 15 bc out 0x25, r1 ; 37
1070 DELAY(len);
1071 5c6: 82 e3 ldi r24, 0x32 ; 50
1072 5c8: 80 93 1c 01 sts 0x011C, r24
1073 5cc: 80 91 1c 01 lds r24, 0x011C
1074 5d0: 88 23 and r24, r24
1075 5d2: e1 f7 brne .-8 ; 0x5cc <__stack+0xcd>
1076 /* Controls */
1234 kaklik 1077  
1296 kaklik 1078 static
1079 void beep (BYTE len, BYTE cnt)
1080 {
1081 while (cnt--) {
1082 5d4: 91 50 subi r25, 0x01 ; 1
1083 5d6: 70 f7 brcc .-36 ; 0x5b4 <__stack+0xb5>
1084 5d8: 93 ce rjmp .-730 ; 0x300 <main+0x96>
1085 5da: 93 e0 ldi r25, 0x03 ; 3
1086 5dc: 01 c0 rjmp .+2 ; 0x5e0 <__stack+0xe1>
1087 5de: 94 e0 ldi r25, 0x04 ; 4
1234 kaklik 1088  
1296 kaklik 1089  
1234 kaklik 1090 static
1091 void uart_stop (void)
1092 {
1093 UCSR0B = 0;
1296 kaklik 1094 5e0: 10 92 c1 00 sts 0x00C1, r1
1234 kaklik 1095 beep(50, 1);
1096 }
1097  
1098 // Unrecoverble error. Enter shutdown state.
1099 uart_stop();
1100 GPS_OFF();
1296 kaklik 1101 5e4: 29 98 cbi 0x05, 1 ; 5
1234 kaklik 1102  
1296 kaklik 1103 static
1104 void beep (BYTE len, BYTE cnt)
1105 {
1106 while (cnt--) {
1107 BEEP_ON();
1108 5e6: 33 e0 ldi r19, 0x03 ; 3
1109 DELAY(len);
1110 5e8: 29 e1 ldi r18, 0x19 ; 25
1234 kaklik 1111  
1112 static
1296 kaklik 1113 void beep (BYTE len, BYTE cnt)
1114 {
1115 while (cnt--) {
1116 BEEP_ON();
1117 5ea: 35 bd out 0x25, r19 ; 37
1118 DELAY(len);
1119 5ec: 20 93 1c 01 sts 0x011C, r18
1120 5f0: 80 91 1c 01 lds r24, 0x011C
1121 5f4: 88 23 and r24, r24
1122 5f6: e1 f7 brne .-8 ; 0x5f0 <__stack+0xf1>
1123 BEEP_OFF();
1124 5f8: 15 bc out 0x25, r1 ; 37
1125 DELAY(len);
1126 5fa: 20 93 1c 01 sts 0x011C, r18
1127 5fe: 80 91 1c 01 lds r24, 0x011C
1128 602: 88 23 and r24, r24
1129 604: e1 f7 brne .-8 ; 0x5fe <__stack+0xff>
1130 606: 91 50 subi r25, 0x01 ; 1
1131 /* Controls */
1132  
1133 static
1134 void beep (BYTE len, BYTE cnt)
1135 {
1136 while (cnt--) {
1137 608: 81 f7 brne .-32 ; 0x5ea <__stack+0xeb>
1138 60a: ff cf rjmp .-2 ; 0x60a <__stack+0x10b>
1139  
1140 beep(5, 2); // Two beeps. Start logging.
1141 err = 0;
1142 while ((b = get_line()) > 0) {
1143 if ( !gp_comp(Buff, PSTR("$GPGGA")) // Which sentence is logged?
1144 || !gp_comp(Buff, PSTR("$GPRMC"))
1145 60c: 28 e6 ldi r18, 0x68 ; 104
1146 60e: 30 e0 ldi r19, 0x00 ; 0
1147 610: ad e1 ldi r26, 0x1D ; 29
1148 612: b1 e0 ldi r27, 0x01 ; 1
1149 614: 50 cf rjmp .-352 ; 0x4b6 <main+0x24c>
1150  
1151  
1152 static
1234 kaklik 1153 void uart_stop (void)
1154 {
1155 UCSR0B = 0;
1296 kaklik 1156 616: 10 92 c1 00 sts 0x00C1, r1
1234 kaklik 1157 }
1158 if (err) break;
1159  
1160 // Turn-off GPS power and close the log file by power supply is discharged.
1161 uart_stop();
1162 GPS_OFF();
1296 kaklik 1163 61a: 29 98 cbi 0x05, 1 ; 5
1234 kaklik 1164 if (f_close(&file1)) { err = 7; break; };
1296 kaklik 1165 61c: 81 e1 ldi r24, 0x11 ; 17
1166 61e: 92 e0 ldi r25, 0x02 ; 2
1167 620: 0e 94 00 07 call 0xe00 ; 0xe00 <f_close>
1168 624: 89 2b or r24, r25
1169 626: 11 f0 breq .+4 ; 0x62c <__stack+0x12d>
1170 628: 97 e0 ldi r25, 0x07 ; 7
1171 62a: da cf rjmp .-76 ; 0x5e0 <__stack+0xe1>
1172 62c: 91 e0 ldi r25, 0x01 ; 1
1173 62e: d2 cf rjmp .-92 ; 0x5d4 <__stack+0xd5>
1234 kaklik 1174  
1296 kaklik 1175 00000630 <__vector_11>:
1176 /* 100Hz timer interrupt generated by OC1A */
1177 /*---------------------------------------------------------*/
1234 kaklik 1178  
1296 kaklik 1179  
1180 ISR(TIMER1_COMPA_vect)
1234 kaklik 1181 {
1296 kaklik 1182 630: 1f 92 push r1
1183 632: 0f 92 push r0
1184 634: 0f b6 in r0, 0x3f ; 63
1185 636: 0f 92 push r0
1186 638: 11 24 eor r1, r1
1187 63a: 2f 93 push r18
1188 63c: 8f 93 push r24
1189 63e: 9f 93 push r25
1190 BYTE n;
1191 static WORD ivt_sync;
1234 kaklik 1192  
1193  
1296 kaklik 1194 n = Timer;
1195 640: 80 91 1c 01 lds r24, 0x011C
1196 if (n) Timer = n - 1;
1197 644: 88 23 and r24, r24
1198 646: 19 f0 breq .+6 ; 0x64e <__vector_11+0x1e>
1199 648: 81 50 subi r24, 0x01 ; 1
1200 64a: 80 93 1c 01 sts 0x011C, r24
1201  
1202 if (++ivt_sync >= 180 * 100) {
1203 64e: 80 91 0c 01 lds r24, 0x010C
1204 652: 90 91 0d 01 lds r25, 0x010D
1205 656: 01 96 adiw r24, 0x01 ; 1
1206 658: 90 93 0d 01 sts 0x010D, r25
1207 65c: 80 93 0c 01 sts 0x010C, r24
1208 660: 80 55 subi r24, 0x50 ; 80
1209 662: 96 44 sbci r25, 0x46 ; 70
1210 664: 48 f0 brcs .+18 ; 0x678 <__vector_11+0x48>
1211 ivt_sync = 0;
1212 666: 10 92 0d 01 sts 0x010D, r1
1213 66a: 10 92 0c 01 sts 0x010C, r1
1214 Stat |= 4;
1215 66e: 80 91 6f 01 lds r24, 0x016F
1216 672: 84 60 ori r24, 0x04 ; 4
1217 674: 80 93 6f 01 sts 0x016F, r24
1218 }
1219  
1220 disk_timerproc(); /* Drive timer procedure of low level disk I/O module */
1221 678: 0e 94 6f 11 call 0x22de ; 0x22de <disk_timerproc>
1222  
1234 kaklik 1223 }
1296 kaklik 1224 67c: 9f 91 pop r25
1225 67e: 8f 91 pop r24
1226 680: 2f 91 pop r18
1227 682: 0f 90 pop r0
1228 684: 0f be out 0x3f, r0 ; 63
1229 686: 0f 90 pop r0
1230 688: 1f 90 pop r1
1231 68a: 18 95 reti
1234 kaklik 1232  
1296 kaklik 1233 0000068c <validate>:
1234 kaklik 1234 static
1235 FRESULT validate ( /* FR_OK(0): The id is valid, !=0: Not valid */
1236 const FATFS *fs, /* Pointer to the file system object */
1237 WORD id /* id member of the target object to be checked */
1238 )
1239 {
1296 kaklik 1240 68c: fc 01 movw r30, r24
1234 kaklik 1241 if (!fs || fs->id != id)
1296 kaklik 1242 68e: 00 97 sbiw r24, 0x00 ; 0
1243 690: 69 f0 breq .+26 ; 0x6ac <validate+0x20>
1244 692: 80 81 ld r24, Z
1245 694: 91 81 ldd r25, Z+1 ; 0x01
1246 696: 86 17 cp r24, r22
1247 698: 97 07 cpc r25, r23
1248 69a: 41 f4 brne .+16 ; 0x6ac <validate+0x20>
1234 kaklik 1249 return FR_INVALID_OBJECT;
1250 if (disk_status(0) & STA_NOINIT)
1296 kaklik 1251 69c: 80 e0 ldi r24, 0x00 ; 0
1252 69e: 0e 94 95 0f call 0x1f2a ; 0x1f2a <disk_status>
1253 6a2: 28 2f mov r18, r24
1254 6a4: 30 e0 ldi r19, 0x00 ; 0
1255 6a6: 21 70 andi r18, 0x01 ; 1
1256 6a8: 30 70 andi r19, 0x00 ; 0
1257 6aa: 02 c0 rjmp .+4 ; 0x6b0 <validate+0x24>
1258 6ac: 2c e0 ldi r18, 0x0C ; 12
1259 6ae: 30 e0 ldi r19, 0x00 ; 0
1234 kaklik 1260 return FR_NOT_READY;
1261  
1262 return FR_OK;
1263 }
1296 kaklik 1264 6b0: c9 01 movw r24, r18
1265 6b2: 08 95 ret
1234 kaklik 1266  
1296 kaklik 1267 000006b4 <move_window>:
1234 kaklik 1268  
1269 static
1270 BOOL move_window ( /* TRUE: successful, FALSE: failed */
1271 DWORD sector /* Sector number to make apperance in the FatFs->win */
1272 ) /* Move to zero only writes back dirty window */
1273 {
1296 kaklik 1274 6b4: a0 e0 ldi r26, 0x00 ; 0
1275 6b6: b0 e0 ldi r27, 0x00 ; 0
1276 6b8: e0 e6 ldi r30, 0x60 ; 96
1277 6ba: f3 e0 ldi r31, 0x03 ; 3
1278 6bc: 0c 94 cb 14 jmp 0x2996 ; 0x2996 <__prologue_saves__+0x8>
1279 6c0: 4b 01 movw r8, r22
1280 6c2: 5c 01 movw r10, r24
1234 kaklik 1281 DWORD wsect;
1282 FATFS *fs = FatFs;
1296 kaklik 1283 6c4: c0 91 10 01 lds r28, 0x0110
1284 6c8: d0 91 11 01 lds r29, 0x0111
1234 kaklik 1285  
1286  
1287 wsect = fs->winsect;
1296 kaklik 1288 6cc: cc 80 ldd r12, Y+4 ; 0x04
1289 6ce: dd 80 ldd r13, Y+5 ; 0x05
1290 6d0: ee 80 ldd r14, Y+6 ; 0x06
1291 6d2: ff 80 ldd r15, Y+7 ; 0x07
1234 kaklik 1292 if (wsect != sector) { /* Changed current window */
1296 kaklik 1293 6d4: c6 16 cp r12, r22
1294 6d6: d7 06 cpc r13, r23
1295 6d8: e8 06 cpc r14, r24
1296 6da: f9 06 cpc r15, r25
1297 6dc: 09 f4 brne .+2 ; 0x6e0 <move_window+0x2c>
1298 6de: 4e c0 rjmp .+156 ; 0x77c <move_window+0xc8>
1234 kaklik 1299 #if !_FS_READONLY
1300 BYTE n;
1301 if (fs->winflag) { /* Write back dirty window if needed */
1296 kaklik 1302 6e0: 8f 8d ldd r24, Y+31 ; 0x1f
1303 6e2: 88 23 and r24, r24
1304 6e4: a1 f1 breq .+104 ; 0x74e <move_window+0x9a>
1234 kaklik 1305 if (disk_write(0, fs->win, wsect, 1) != RES_OK)
1296 kaklik 1306 6e6: 80 e2 ldi r24, 0x20 ; 32
1307 6e8: 68 2e mov r6, r24
1308 6ea: 71 2c mov r7, r1
1309 6ec: 6c 0e add r6, r28
1310 6ee: 7d 1e adc r7, r29
1311 6f0: 01 e0 ldi r16, 0x01 ; 1
1312 6f2: a7 01 movw r20, r14
1313 6f4: 96 01 movw r18, r12
1314 6f6: b3 01 movw r22, r6
1315 6f8: 80 e0 ldi r24, 0x00 ; 0
1316 6fa: 0e 94 fb 0f call 0x1ff6 ; 0x1ff6 <disk_write>
1317 6fe: 89 2b or r24, r25
1318 700: d9 f5 brne .+118 ; 0x778 <move_window+0xc4>
1234 kaklik 1319 return FALSE;
1320 fs->winflag = 0;
1296 kaklik 1321 702: 1f 8e std Y+31, r1 ; 0x1f
1234 kaklik 1322 if (wsect < (fs->fatbase + fs->sects_fat)) { /* In FAT area */
1296 kaklik 1323 704: 8c 89 ldd r24, Y+20 ; 0x14
1324 706: 9d 89 ldd r25, Y+21 ; 0x15
1325 708: a0 e0 ldi r26, 0x00 ; 0
1326 70a: b0 e0 ldi r27, 0x00 ; 0
1327 70c: 28 85 ldd r18, Y+8 ; 0x08
1328 70e: 39 85 ldd r19, Y+9 ; 0x09
1329 710: 4a 85 ldd r20, Y+10 ; 0x0a
1330 712: 5b 85 ldd r21, Y+11 ; 0x0b
1331 714: 82 0f add r24, r18
1332 716: 93 1f adc r25, r19
1333 718: a4 1f adc r26, r20
1334 71a: b5 1f adc r27, r21
1335 71c: c8 16 cp r12, r24
1336 71e: d9 06 cpc r13, r25
1337 720: ea 06 cpc r14, r26
1338 722: fb 06 cpc r15, r27
1339 724: a0 f4 brcc .+40 ; 0x74e <move_window+0x9a>
1234 kaklik 1340 for (n = fs->n_fats; n >= 2; n--) { /* Refrect the change to all FAT copies */
1296 kaklik 1341 726: 1e 8d ldd r17, Y+30 ; 0x1e
1342 728: 10 c0 rjmp .+32 ; 0x74a <move_window+0x96>
1234 kaklik 1343 wsect += fs->sects_fat;
1296 kaklik 1344 72a: 8c 89 ldd r24, Y+20 ; 0x14
1345 72c: 9d 89 ldd r25, Y+21 ; 0x15
1346 72e: a0 e0 ldi r26, 0x00 ; 0
1347 730: b0 e0 ldi r27, 0x00 ; 0
1348 732: c8 0e add r12, r24
1349 734: d9 1e adc r13, r25
1350 736: ea 1e adc r14, r26
1351 738: fb 1e adc r15, r27
1234 kaklik 1352 disk_write(0, fs->win, wsect, 1);
1296 kaklik 1353 73a: 01 e0 ldi r16, 0x01 ; 1
1354 73c: a7 01 movw r20, r14
1355 73e: 96 01 movw r18, r12
1356 740: b3 01 movw r22, r6
1357 742: 80 e0 ldi r24, 0x00 ; 0
1358 744: 0e 94 fb 0f call 0x1ff6 ; 0x1ff6 <disk_write>
1234 kaklik 1359 if (fs->winflag) { /* Write back dirty window if needed */
1360 if (disk_write(0, fs->win, wsect, 1) != RES_OK)
1361 return FALSE;
1362 fs->winflag = 0;
1363 if (wsect < (fs->fatbase + fs->sects_fat)) { /* In FAT area */
1364 for (n = fs->n_fats; n >= 2; n--) { /* Refrect the change to all FAT copies */
1296 kaklik 1365 748: 11 50 subi r17, 0x01 ; 1
1366 74a: 12 30 cpi r17, 0x02 ; 2
1367 74c: 70 f7 brcc .-36 ; 0x72a <move_window+0x76>
1234 kaklik 1368 disk_write(0, fs->win, wsect, 1);
1369 }
1370 }
1371 }
1372 #endif
1373 if (sector) {
1296 kaklik 1374 74e: 81 14 cp r8, r1
1375 750: 91 04 cpc r9, r1
1376 752: a1 04 cpc r10, r1
1377 754: b1 04 cpc r11, r1
1378 756: 91 f0 breq .+36 ; 0x77c <move_window+0xc8>
1234 kaklik 1379 if (disk_read(0, fs->win, sector, 1) != RES_OK)
1296 kaklik 1380 758: be 01 movw r22, r28
1381 75a: 60 5e subi r22, 0xE0 ; 224
1382 75c: 7f 4f sbci r23, 0xFF ; 255
1383 75e: 01 e0 ldi r16, 0x01 ; 1
1384 760: a5 01 movw r20, r10
1385 762: 94 01 movw r18, r8
1386 764: 80 e0 ldi r24, 0x00 ; 0
1387 766: 0e 94 9c 0f call 0x1f38 ; 0x1f38 <disk_read>
1388 76a: 89 2b or r24, r25
1389 76c: 29 f4 brne .+10 ; 0x778 <move_window+0xc4>
1234 kaklik 1390 return FALSE;
1391 fs->winsect = sector;
1296 kaklik 1392 76e: 8c 82 std Y+4, r8 ; 0x04
1393 770: 9d 82 std Y+5, r9 ; 0x05
1394 772: ae 82 std Y+6, r10 ; 0x06
1395 774: bf 82 std Y+7, r11 ; 0x07
1396 776: 02 c0 rjmp .+4 ; 0x77c <move_window+0xc8>
1397 778: 80 e0 ldi r24, 0x00 ; 0
1398 77a: 01 c0 rjmp .+2 ; 0x77e <move_window+0xca>
1399 77c: 81 e0 ldi r24, 0x01 ; 1
1400 }
1401 }
1402 return TRUE;
1403 }
1404 77e: cd b7 in r28, 0x3d ; 61
1405 780: de b7 in r29, 0x3e ; 62
1406 782: ee e0 ldi r30, 0x0E ; 14
1407 784: 0c 94 e7 14 jmp 0x29ce ; 0x29ce <__epilogue_restores__+0x8>
1234 kaklik 1408  
1296 kaklik 1409 00000788 <put_cluster>:
1234 kaklik 1410 static
1411 BOOL put_cluster ( /* TRUE: successful, FALSE: failed */
1412 CLUST clust, /* Cluster# to change */
1413 CLUST val /* New value to mark the cluster */
1414 )
1415 {
1296 kaklik 1416 788: a0 e0 ldi r26, 0x00 ; 0
1417 78a: b0 e0 ldi r27, 0x00 ; 0
1418 78c: ea ec ldi r30, 0xCA ; 202
1419 78e: f3 e0 ldi r31, 0x03 ; 3
1420 790: 0c 94 cb 14 jmp 0x2996 ; 0x2996 <__prologue_saves__+0x8>
1421 794: ec 01 movw r28, r24
1422 796: 4b 01 movw r8, r22
1234 kaklik 1423 WORD bc;
1424 BYTE *p;
1425 DWORD fatsect;
1426 FATFS *fs = FatFs;
1296 kaklik 1427 798: e0 90 10 01 lds r14, 0x0110
1428 79c: f0 90 11 01 lds r15, 0x0111
1234 kaklik 1429  
1430  
1431 fatsect = fs->fatbase;
1296 kaklik 1432 7a0: f7 01 movw r30, r14
1433 7a2: a0 84 ldd r10, Z+8 ; 0x08
1434 7a4: b1 84 ldd r11, Z+9 ; 0x09
1435 7a6: c2 84 ldd r12, Z+10 ; 0x0a
1436 7a8: d3 84 ldd r13, Z+11 ; 0x0b
1234 kaklik 1437 switch (fs->fs_type) {
1296 kaklik 1438 7aa: 84 8d ldd r24, Z+28 ; 0x1c
1439 7ac: 81 30 cpi r24, 0x01 ; 1
1440 7ae: 21 f0 breq .+8 ; 0x7b8 <put_cluster+0x30>
1441 7b0: 82 30 cpi r24, 0x02 ; 2
1442 7b2: 09 f0 breq .+2 ; 0x7b6 <put_cluster+0x2e>
1443 7b4: 72 c0 rjmp .+228 ; 0x89a <put_cluster+0x112>
1444 7b6: 5a c0 rjmp .+180 ; 0x86c <put_cluster+0xe4>
1234 kaklik 1445 case FS_FAT12 :
1446 bc = (WORD)clust * 3 / 2;
1296 kaklik 1447 7b8: 8e 01 movw r16, r28
1448 7ba: 00 0f add r16, r16
1449 7bc: 11 1f adc r17, r17
1450 7be: 0c 0f add r16, r28
1451 7c0: 1d 1f adc r17, r29
1452 7c2: 16 95 lsr r17
1453 7c4: 07 95 ror r16
1234 kaklik 1454 if (!move_window(fatsect + bc / 512)) return FALSE;
1296 kaklik 1455 7c6: b8 01 movw r22, r16
1456 7c8: 67 2f mov r22, r23
1457 7ca: 77 27 eor r23, r23
1458 7cc: 66 95 lsr r22
1459 7ce: 80 e0 ldi r24, 0x00 ; 0
1460 7d0: 90 e0 ldi r25, 0x00 ; 0
1461 7d2: 6a 0d add r22, r10
1462 7d4: 7b 1d adc r23, r11
1463 7d6: 8c 1d adc r24, r12
1464 7d8: 9d 1d adc r25, r13
1465 7da: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
1466 7de: 88 23 and r24, r24
1467 7e0: 09 f4 brne .+2 ; 0x7e4 <put_cluster+0x5c>
1468 7e2: 5b c0 rjmp .+182 ; 0x89a <put_cluster+0x112>
1234 kaklik 1469 p = &fs->win[bc % 512];
1296 kaklik 1470 7e4: d8 01 movw r26, r16
1471 7e6: b1 70 andi r27, 0x01 ; 1
1234 kaklik 1472 *p = (clust & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val;
1296 kaklik 1473 7e8: 51 e0 ldi r21, 0x01 ; 1
1474 7ea: 65 2e mov r6, r21
1475 7ec: 71 2c mov r7, r1
1476 7ee: 6c 22 and r6, r28
1477 7f0: 7d 22 and r7, r29
1478 7f2: c0 ff sbrs r28, 0
1479 7f4: 0a c0 rjmp .+20 ; 0x80a <put_cluster+0x82>
1480 7f6: f7 01 movw r30, r14
1481 7f8: ea 0f add r30, r26
1482 7fa: fb 1f adc r31, r27
1483 7fc: 80 a1 ldd r24, Z+32 ; 0x20
1234 kaklik 1484 7fe: 8f 70 andi r24, 0x0F ; 15
1296 kaklik 1485 800: 98 2d mov r25, r8
1234 kaklik 1486 802: 92 95 swap r25
1487 804: 90 7f andi r25, 0xF0 ; 240
1488 806: 98 2b or r25, r24
1296 kaklik 1489 808: 01 c0 rjmp .+2 ; 0x80c <put_cluster+0x84>
1490 80a: 98 2d mov r25, r8
1491 80c: ae 0d add r26, r14
1492 80e: bf 1d adc r27, r15
1493 810: fd 01 movw r30, r26
1494 812: 90 a3 std Z+32, r25 ; 0x20
1234 kaklik 1495 bc++;
1296 kaklik 1496 814: e8 01 movw r28, r16
1497 816: 21 96 adiw r28, 0x01 ; 1
1234 kaklik 1498 fs->winflag = 1;
1296 kaklik 1499 818: 81 e0 ldi r24, 0x01 ; 1
1500 81a: f7 01 movw r30, r14
1501 81c: 87 8f std Z+31, r24 ; 0x1f
1234 kaklik 1502 if (!move_window(fatsect + bc / 512)) return FALSE;
1296 kaklik 1503 81e: be 01 movw r22, r28
1504 820: 67 2f mov r22, r23
1505 822: 77 27 eor r23, r23
1506 824: 66 95 lsr r22
1507 826: 80 e0 ldi r24, 0x00 ; 0
1508 828: 90 e0 ldi r25, 0x00 ; 0
1509 82a: 6a 0d add r22, r10
1510 82c: 7b 1d adc r23, r11
1511 82e: 8c 1d adc r24, r12
1512 830: 9d 1d adc r25, r13
1513 832: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
1514 836: 88 23 and r24, r24
1515 838: 81 f1 breq .+96 ; 0x89a <put_cluster+0x112>
1234 kaklik 1516 p = &fs->win[bc % 512];
1296 kaklik 1517 83a: de 01 movw r26, r28
1518 83c: b1 70 andi r27, 0x01 ; 1
1234 kaklik 1519 *p = (clust & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F));
1296 kaklik 1520 83e: 61 14 cp r6, r1
1521 840: 71 04 cpc r7, r1
1522 842: 39 f0 breq .+14 ; 0x852 <put_cluster+0xca>
1523 844: 34 e0 ldi r19, 0x04 ; 4
1524 846: 96 94 lsr r9
1525 848: 87 94 ror r8
1526 84a: 3a 95 dec r19
1527 84c: e1 f7 brne .-8 ; 0x846 <put_cluster+0xbe>
1528 84e: 98 2d mov r25, r8
1529 850: 08 c0 rjmp .+16 ; 0x862 <put_cluster+0xda>
1530 852: f7 01 movw r30, r14
1531 854: ea 0f add r30, r26
1532 856: fb 1f adc r31, r27
1533 858: 90 a1 ldd r25, Z+32 ; 0x20
1534 85a: 90 7f andi r25, 0xF0 ; 240
1535 85c: 89 2d mov r24, r9
1536 85e: 8f 70 andi r24, 0x0F ; 15
1537 860: 98 2b or r25, r24
1538 862: ae 0d add r26, r14
1539 864: bf 1d adc r27, r15
1540 866: fd 01 movw r30, r26
1541 868: 90 a3 std Z+32, r25 ; 0x20
1542 86a: 13 c0 rjmp .+38 ; 0x892 <put_cluster+0x10a>
1234 kaklik 1543 break;
1544  
1545 case FS_FAT16 :
1546 if (!move_window(fatsect + clust / 256)) return FALSE;
1296 kaklik 1547 86c: 6d 2f mov r22, r29
1548 86e: 77 27 eor r23, r23
1549 870: 80 e0 ldi r24, 0x00 ; 0
1550 872: 90 e0 ldi r25, 0x00 ; 0
1551 874: 6a 0d add r22, r10
1552 876: 7b 1d adc r23, r11
1553 878: 8c 1d adc r24, r12
1554 87a: 9d 1d adc r25, r13
1555 87c: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
1556 880: 88 23 and r24, r24
1557 882: 59 f0 breq .+22 ; 0x89a <put_cluster+0x112>
1234 kaklik 1558 ST_WORD(&fs->win[((WORD)clust * 2) % 512], (WORD)val);
1296 kaklik 1559 884: cc 0f add r28, r28
1560 886: dd 1f adc r29, r29
1561 888: d1 70 andi r29, 0x01 ; 1
1562 88a: ce 0d add r28, r14
1563 88c: df 1d adc r29, r15
1564 88e: 99 a2 std Y+33, r9 ; 0x21
1565 890: 88 a2 std Y+32, r8 ; 0x20
1234 kaklik 1566 break;
1567 #endif
1568 default :
1569 return FALSE;
1570 }
1571 fs->winflag = 1;
1296 kaklik 1572 892: 81 e0 ldi r24, 0x01 ; 1
1573 894: f7 01 movw r30, r14
1574 896: 87 8f std Z+31, r24 ; 0x1f
1575 898: 01 c0 rjmp .+2 ; 0x89c <put_cluster+0x114>
1234 kaklik 1576 return TRUE;
1296 kaklik 1577 89a: 80 e0 ldi r24, 0x00 ; 0
1578 }
1579 89c: cd b7 in r28, 0x3d ; 61
1580 89e: de b7 in r29, 0x3e ; 62
1581 8a0: ee e0 ldi r30, 0x0E ; 14
1582 8a2: 0c 94 e7 14 jmp 0x29ce ; 0x29ce <__epilogue_restores__+0x8>
1234 kaklik 1583  
1296 kaklik 1584 000008a6 <get_cluster>:
1234 kaklik 1585  
1586 static
1587 CLUST get_cluster ( /* 0,>=2: successful, 1: failed */
1588 CLUST clust /* Cluster# to get the link information */
1589 )
1590 {
1296 kaklik 1591 8a6: a0 e0 ldi r26, 0x00 ; 0
1592 8a8: b0 e0 ldi r27, 0x00 ; 0
1593 8aa: e9 e5 ldi r30, 0x59 ; 89
1594 8ac: f4 e0 ldi r31, 0x04 ; 4
1595 8ae: 0c 94 ce 14 jmp 0x299c ; 0x299c <__prologue_saves__+0xe>
1596 8b2: 8c 01 movw r16, r24
1234 kaklik 1597 WORD wc, bc;
1598 DWORD fatsect;
1599 FATFS *fs = FatFs;
1296 kaklik 1600 8b4: e0 90 10 01 lds r14, 0x0110
1601 8b8: f0 90 11 01 lds r15, 0x0111
1234 kaklik 1602  
1603  
1604 if (clust >= 2 && clust < fs->max_clust) { /* Valid cluster# */
1296 kaklik 1605 8bc: 82 30 cpi r24, 0x02 ; 2
1606 8be: 91 05 cpc r25, r1
1607 8c0: 08 f4 brcc .+2 ; 0x8c4 <get_cluster+0x1e>
1608 8c2: 67 c0 rjmp .+206 ; 0x992 <get_cluster+0xec>
1609 8c4: e7 01 movw r28, r14
1610 8c6: 8e 89 ldd r24, Y+22 ; 0x16
1611 8c8: 9f 89 ldd r25, Y+23 ; 0x17
1612 8ca: 08 17 cp r16, r24
1613 8cc: 19 07 cpc r17, r25
1614 8ce: 08 f0 brcs .+2 ; 0x8d2 <get_cluster+0x2c>
1615 8d0: 60 c0 rjmp .+192 ; 0x992 <get_cluster+0xec>
1234 kaklik 1616 fatsect = fs->fatbase;
1296 kaklik 1617 8d2: a8 84 ldd r10, Y+8 ; 0x08
1618 8d4: b9 84 ldd r11, Y+9 ; 0x09
1619 8d6: ca 84 ldd r12, Y+10 ; 0x0a
1620 8d8: db 84 ldd r13, Y+11 ; 0x0b
1234 kaklik 1621 switch (fs->fs_type) {
1296 kaklik 1622 8da: 8c 8d ldd r24, Y+28 ; 0x1c
1623 8dc: 81 30 cpi r24, 0x01 ; 1
1624 8de: 21 f0 breq .+8 ; 0x8e8 <get_cluster+0x42>
1625 8e0: 82 30 cpi r24, 0x02 ; 2
1626 8e2: 09 f0 breq .+2 ; 0x8e6 <get_cluster+0x40>
1627 8e4: 56 c0 rjmp .+172 ; 0x992 <get_cluster+0xec>
1628 8e6: 40 c0 rjmp .+128 ; 0x968 <get_cluster+0xc2>
1234 kaklik 1629 case FS_FAT12 :
1630 bc = (WORD)clust * 3 / 2;
1296 kaklik 1631 8e8: e8 01 movw r28, r16
1632 8ea: cc 0f add r28, r28
1633 8ec: dd 1f adc r29, r29
1634 8ee: c0 0f add r28, r16
1635 8f0: d1 1f adc r29, r17
1636 8f2: d6 95 lsr r29
1637 8f4: c7 95 ror r28
1234 kaklik 1638 if (!move_window(fatsect + bc / 512)) break;
1296 kaklik 1639 8f6: be 01 movw r22, r28
1640 8f8: 67 2f mov r22, r23
1641 8fa: 77 27 eor r23, r23
1642 8fc: 66 95 lsr r22
1643 8fe: 80 e0 ldi r24, 0x00 ; 0
1644 900: 90 e0 ldi r25, 0x00 ; 0
1645 902: 6a 0d add r22, r10
1646 904: 7b 1d adc r23, r11
1647 906: 8c 1d adc r24, r12
1648 908: 9d 1d adc r25, r13
1649 90a: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
1650 90e: 88 23 and r24, r24
1651 910: 09 f4 brne .+2 ; 0x914 <get_cluster+0x6e>
1652 912: 3f c0 rjmp .+126 ; 0x992 <get_cluster+0xec>
1234 kaklik 1653 wc = fs->win[bc % 512]; bc++;
1296 kaklik 1654 914: fe 01 movw r30, r28
1655 916: f1 70 andi r31, 0x01 ; 1
1656 918: ee 0d add r30, r14
1657 91a: ff 1d adc r31, r15
1658 91c: 90 a0 ldd r9, Z+32 ; 0x20
1659 91e: 21 96 adiw r28, 0x01 ; 1
1234 kaklik 1660 if (!move_window(fatsect + bc / 512)) break;
1296 kaklik 1661 920: be 01 movw r22, r28
1662 922: 67 2f mov r22, r23
1663 924: 77 27 eor r23, r23
1664 926: 66 95 lsr r22
1665 928: 80 e0 ldi r24, 0x00 ; 0
1666 92a: 90 e0 ldi r25, 0x00 ; 0
1667 92c: 6a 0d add r22, r10
1668 92e: 7b 1d adc r23, r11
1669 930: 8c 1d adc r24, r12
1670 932: 9d 1d adc r25, r13
1671 934: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
1672 938: 88 23 and r24, r24
1673 93a: 59 f1 breq .+86 ; 0x992 <get_cluster+0xec>
1234 kaklik 1674 fatsect = fs->fatbase;
1675 switch (fs->fs_type) {
1676 case FS_FAT12 :
1677 bc = (WORD)clust * 3 / 2;
1678 if (!move_window(fatsect + bc / 512)) break;
1679 wc = fs->win[bc % 512]; bc++;
1296 kaklik 1680 93c: 29 2d mov r18, r9
1681 93e: 30 e0 ldi r19, 0x00 ; 0
1234 kaklik 1682 if (!move_window(fatsect + bc / 512)) break;
1683 wc |= (WORD)fs->win[bc % 512] << 8;
1296 kaklik 1684 940: d1 70 andi r29, 0x01 ; 1
1685 942: ec 0e add r14, r28
1686 944: fd 1e adc r15, r29
1687 946: f7 01 movw r30, r14
1688 948: 90 a1 ldd r25, Z+32 ; 0x20
1689 94a: 80 e0 ldi r24, 0x00 ; 0
1690 94c: 28 2b or r18, r24
1691 94e: 39 2b or r19, r25
1234 kaklik 1692 return (clust & 1) ? (wc >> 4) : (wc & 0xFFF);
1296 kaklik 1693 950: 00 ff sbrs r16, 0
1694 952: 07 c0 rjmp .+14 ; 0x962 <get_cluster+0xbc>
1695 954: f9 01 movw r30, r18
1696 956: 94 e0 ldi r25, 0x04 ; 4
1697 958: f6 95 lsr r31
1698 95a: e7 95 ror r30
1699 95c: 9a 95 dec r25
1700 95e: e1 f7 brne .-8 ; 0x958 <get_cluster+0xb2>
1701 960: 1a c0 rjmp .+52 ; 0x996 <get_cluster+0xf0>
1702 962: f9 01 movw r30, r18
1703 964: ff 70 andi r31, 0x0F ; 15
1704 966: 17 c0 rjmp .+46 ; 0x996 <get_cluster+0xf0>
1234 kaklik 1705  
1706 case FS_FAT16 :
1707 if (!move_window(fatsect + clust / 256)) break;
1296 kaklik 1708 968: 61 2f mov r22, r17
1709 96a: 77 27 eor r23, r23
1710 96c: 80 e0 ldi r24, 0x00 ; 0
1711 96e: 90 e0 ldi r25, 0x00 ; 0
1712 970: 6a 0d add r22, r10
1713 972: 7b 1d adc r23, r11
1714 974: 8c 1d adc r24, r12
1715 976: 9d 1d adc r25, r13
1716 978: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
1717 97c: 88 23 and r24, r24
1718 97e: 49 f0 breq .+18 ; 0x992 <get_cluster+0xec>
1234 kaklik 1719 return LD_WORD(&fs->win[((WORD)clust * 2) % 512]);
1296 kaklik 1720 980: 00 0f add r16, r16
1721 982: 11 1f adc r17, r17
1722 984: 11 70 andi r17, 0x01 ; 1
1723 986: e0 0e add r14, r16
1724 988: f1 1e adc r15, r17
1725 98a: e7 01 movw r28, r14
1726 98c: e8 a1 ldd r30, Y+32 ; 0x20
1727 98e: f9 a1 ldd r31, Y+33 ; 0x21
1728 990: 02 c0 rjmp .+4 ; 0x996 <get_cluster+0xf0>
1729 992: e1 e0 ldi r30, 0x01 ; 1
1730 994: f0 e0 ldi r31, 0x00 ; 0
1731 #endif
1234 kaklik 1732 }
1733 }
1734  
1296 kaklik 1735 return 1; /* There is no cluster information, or an error occured */
1736 }
1737 996: cf 01 movw r24, r30
1738 998: cd b7 in r28, 0x3d ; 61
1739 99a: de b7 in r29, 0x3e ; 62
1740 99c: eb e0 ldi r30, 0x0B ; 11
1741 99e: 0c 94 ea 14 jmp 0x29d4 ; 0x29d4 <__epilogue_restores__+0xe>
1742  
1743 000009a2 <create_chain>:
1234 kaklik 1744 #if !_FS_READONLY
1745 static
1746 CLUST create_chain ( /* 0: no free cluster, 1: error, >=2: new cluster number */
1747 CLUST clust /* Cluster# to stretch, 0 means create new */
1748 )
1749 {
1296 kaklik 1750 9a2: a0 e0 ldi r26, 0x00 ; 0
1751 9a4: b0 e0 ldi r27, 0x00 ; 0
1752 9a6: e7 ed ldi r30, 0xD7 ; 215
1753 9a8: f4 e0 ldi r31, 0x04 ; 4
1754 9aa: 0c 94 cf 14 jmp 0x299e ; 0x299e <__prologue_saves__+0x10>
1755 9ae: 7c 01 movw r14, r24
1234 kaklik 1756 CLUST cstat, ncl, scl, mcl;
1757 FATFS *fs = FatFs;
1296 kaklik 1758 9b0: c0 90 10 01 lds r12, 0x0110
1759 9b4: d0 90 11 01 lds r13, 0x0111
1234 kaklik 1760  
1761  
1762 mcl = fs->max_clust;
1296 kaklik 1763 9b8: f6 01 movw r30, r12
1764 9ba: a6 88 ldd r10, Z+22 ; 0x16
1765 9bc: b7 88 ldd r11, Z+23 ; 0x17
1234 kaklik 1766 if (clust == 0) { /* Create new chain */
1296 kaklik 1767 9be: 00 97 sbiw r24, 0x00 ; 0
1768 9c0: 49 f4 brne .+18 ; 0x9d4 <create_chain+0x32>
1234 kaklik 1769 scl = fs->last_clust; /* Get last allocated cluster */
1296 kaklik 1770 9c2: 00 8d ldd r16, Z+24 ; 0x18
1771 9c4: 11 8d ldd r17, Z+25 ; 0x19
1234 kaklik 1772 if (scl < 2 || scl >= mcl) scl = 1;
1296 kaklik 1773 9c6: 02 30 cpi r16, 0x02 ; 2
1774 9c8: 11 05 cpc r17, r1
1775 9ca: 88 f0 brcs .+34 ; 0x9ee <create_chain+0x4c>
1776 9cc: 0a 15 cp r16, r10
1777 9ce: 1b 05 cpc r17, r11
1778 9d0: 70 f4 brcc .+28 ; 0x9ee <create_chain+0x4c>
1779 9d2: 0f c0 rjmp .+30 ; 0x9f2 <create_chain+0x50>
1234 kaklik 1780 }
1781 else { /* Stretch existing chain */
1782 cstat = get_cluster(clust); /* Check the cluster status */
1296 kaklik 1783 9d4: 0e 94 53 04 call 0x8a6 ; 0x8a6 <get_cluster>
1784 9d8: 9c 01 movw r18, r24
1234 kaklik 1785 if (cstat < 2) return 1; /* It is an invalid cluster */
1296 kaklik 1786 9da: 82 30 cpi r24, 0x02 ; 2
1787 9dc: 91 05 cpc r25, r1
1788 9de: 08 f4 brcc .+2 ; 0x9e2 <create_chain+0x40>
1789 9e0: 40 c0 rjmp .+128 ; 0xa62 <create_chain+0xc0>
1234 kaklik 1790 if (cstat < mcl) return cstat; /* It is already followed by next cluster */
1296 kaklik 1791 9e2: 8a 15 cp r24, r10
1792 9e4: 9b 05 cpc r25, r11
1793 9e6: 08 f4 brcc .+2 ; 0x9ea <create_chain+0x48>
1794 9e8: 41 c0 rjmp .+130 ; 0xa6c <create_chain+0xca>
1795 9ea: 87 01 movw r16, r14
1796 9ec: 02 c0 rjmp .+4 ; 0x9f2 <create_chain+0x50>
1797 9ee: 01 e0 ldi r16, 0x01 ; 1
1798 9f0: 10 e0 ldi r17, 0x00 ; 0
1799 9f2: e8 01 movw r28, r16
1234 kaklik 1800 scl = clust;
1801 }
1802  
1803 ncl = scl; /* Start cluster */
1804 for (;;) {
1805 ncl++; /* Next cluster */
1296 kaklik 1806 9f4: 21 96 adiw r28, 0x01 ; 1
1234 kaklik 1807 if (ncl >= mcl) { /* Wrap around */
1296 kaklik 1808 9f6: ca 15 cp r28, r10
1809 9f8: db 05 cpc r29, r11
1810 9fa: 28 f0 brcs .+10 ; 0xa06 <create_chain+0x64>
1234 kaklik 1811 ncl = 2;
1812 if (ncl > scl) return 0; /* No free custer */
1296 kaklik 1813 9fc: 02 30 cpi r16, 0x02 ; 2
1814 9fe: 11 05 cpc r17, r1
1815 a00: 98 f1 brcs .+102 ; 0xa68 <create_chain+0xc6>
1816 a02: c2 e0 ldi r28, 0x02 ; 2
1817 a04: d0 e0 ldi r29, 0x00 ; 0
1234 kaklik 1818 }
1819 cstat = get_cluster(ncl); /* Get the cluster status */
1296 kaklik 1820 a06: ce 01 movw r24, r28
1821 a08: 0e 94 53 04 call 0x8a6 ; 0x8a6 <get_cluster>
1822 a0c: 9c 01 movw r18, r24
1234 kaklik 1823 if (cstat == 0) break; /* Found a free cluster */
1296 kaklik 1824 a0e: 00 97 sbiw r24, 0x00 ; 0
1825 a10: 39 f0 breq .+14 ; 0xa20 <create_chain+0x7e>
1234 kaklik 1826 if (cstat == 1) return 1; /* Any error occured */
1296 kaklik 1827 a12: 81 30 cpi r24, 0x01 ; 1
1828 a14: 91 05 cpc r25, r1
1829 a16: 51 f1 breq .+84 ; 0xa6c <create_chain+0xca>
1234 kaklik 1830 if (ncl == scl) return 0; /* No free custer */
1296 kaklik 1831 a18: c0 17 cp r28, r16
1832 a1a: d1 07 cpc r29, r17
1833 a1c: 59 f7 brne .-42 ; 0x9f4 <create_chain+0x52>
1834 a1e: 24 c0 rjmp .+72 ; 0xa68 <create_chain+0xc6>
1835 a20: 1c 2f mov r17, r28
1836 a22: 0d 2f mov r16, r29
1234 kaklik 1837 }
1838  
1839 if (!put_cluster(ncl, (CLUST)0x0FFFFFFF)) return 1; /* Mark the new cluster "in use" */
1296 kaklik 1840 a24: 6f ef ldi r22, 0xFF ; 255
1841 a26: 7f ef ldi r23, 0xFF ; 255
1842 a28: ce 01 movw r24, r28
1843 a2a: 0e 94 c4 03 call 0x788 ; 0x788 <put_cluster>
1844 a2e: 88 23 and r24, r24
1845 a30: c1 f0 breq .+48 ; 0xa62 <create_chain+0xc0>
1234 kaklik 1846 if (clust && !put_cluster(clust, ncl)) return 1; /* Link it to previous one if needed */
1296 kaklik 1847 a32: e1 14 cp r14, r1
1848 a34: f1 04 cpc r15, r1
1849 a36: 31 f0 breq .+12 ; 0xa44 <create_chain+0xa2>
1850 a38: be 01 movw r22, r28
1851 a3a: c7 01 movw r24, r14
1852 a3c: 0e 94 c4 03 call 0x788 ; 0x788 <put_cluster>
1853 a40: 88 23 and r24, r24
1854 a42: 79 f0 breq .+30 ; 0xa62 <create_chain+0xc0>
1234 kaklik 1855  
1856 fs->last_clust = ncl; /* Update fsinfo */
1296 kaklik 1857 a44: f6 01 movw r30, r12
1858 a46: 10 8f std Z+24, r17 ; 0x18
1859 a48: 01 8f std Z+25, r16 ; 0x19
1234 kaklik 1860 if (fs->free_clust != (CLUST)0xFFFFFFFF) {
1296 kaklik 1861 a4a: 82 8d ldd r24, Z+26 ; 0x1a
1862 a4c: 93 8d ldd r25, Z+27 ; 0x1b
1863 a4e: ff ef ldi r31, 0xFF ; 255
1864 a50: 8f 3f cpi r24, 0xFF ; 255
1865 a52: 9f 07 cpc r25, r31
1866 a54: 21 f0 breq .+8 ; 0xa5e <create_chain+0xbc>
1234 kaklik 1867 fs->free_clust--;
1296 kaklik 1868 a56: 01 97 sbiw r24, 0x01 ; 1
1869 a58: f6 01 movw r30, r12
1870 a5a: 93 8f std Z+27, r25 ; 0x1b
1871 a5c: 82 8f std Z+26, r24 ; 0x1a
1872 a5e: 9e 01 movw r18, r28
1873 a60: 05 c0 rjmp .+10 ; 0xa6c <create_chain+0xca>
1874 a62: 21 e0 ldi r18, 0x01 ; 1
1875 a64: 30 e0 ldi r19, 0x00 ; 0
1876 a66: 02 c0 rjmp .+4 ; 0xa6c <create_chain+0xca>
1877 a68: 20 e0 ldi r18, 0x00 ; 0
1878 a6a: 30 e0 ldi r19, 0x00 ; 0
1234 kaklik 1879 fs->fsi_flag = 1;
1880 #endif
1881 }
1882  
1883 return ncl; /* Return new cluster number */
1884 }
1296 kaklik 1885 a6c: c9 01 movw r24, r18
1886 a6e: cd b7 in r28, 0x3d ; 61
1887 a70: de b7 in r29, 0x3e ; 62
1888 a72: ea e0 ldi r30, 0x0A ; 10
1889 a74: 0c 94 eb 14 jmp 0x29d6 ; 0x29d6 <__epilogue_restores__+0x10>
1234 kaklik 1890  
1296 kaklik 1891 00000a78 <f_lseek>:
1234 kaklik 1892  
1893 FRESULT f_lseek (
1894 FIL *fp, /* Pointer to the file object */
1895 DWORD ofs /* File pointer from top of file */
1896 )
1897 {
1296 kaklik 1898 a78: a0 e0 ldi r26, 0x00 ; 0
1899 a7a: b0 e0 ldi r27, 0x00 ; 0
1900 a7c: e2 e4 ldi r30, 0x42 ; 66
1901 a7e: f5 e0 ldi r31, 0x05 ; 5
1902 a80: 0c 94 cb 14 jmp 0x2996 ; 0x2996 <__prologue_saves__+0x8>
1903 a84: ec 01 movw r28, r24
1904 a86: 7a 01 movw r14, r20
1905 a88: 8b 01 movw r16, r22
1234 kaklik 1906 CLUST clust;
1907 DWORD csize;
1908 BYTE csect;
1909 FRESULT res;
1910 FATFS *fs = fp->fs;
1296 kaklik 1911 a8a: 6c 80 ldd r6, Y+4 ; 0x04
1912 a8c: 7d 80 ldd r7, Y+5 ; 0x05
1234 kaklik 1913  
1914  
1915 res = validate(fs, fp->id); /* Check validity of the object */
1296 kaklik 1916 a8e: 68 81 ld r22, Y
1917 a90: 79 81 ldd r23, Y+1 ; 0x01
1918 a92: c3 01 movw r24, r6
1919 a94: 0e 94 46 03 call 0x68c ; 0x68c <validate>
1920 a98: 4c 01 movw r8, r24
1234 kaklik 1921 if (res) return res;
1296 kaklik 1922 a9a: 00 97 sbiw r24, 0x00 ; 0
1923 a9c: 09 f0 breq .+2 ; 0xaa0 <f_lseek+0x28>
1924 a9e: d6 c0 rjmp .+428 ; 0xc4c <f_lseek+0x1d4>
1234 kaklik 1925  
1926 if (fp->flag & FA__ERROR) return FR_RW_ERROR;
1296 kaklik 1927 aa0: 8a 81 ldd r24, Y+2 ; 0x02
1928 aa2: 87 fd sbrc r24, 7
1929 aa4: d0 c0 rjmp .+416 ; 0xc46 <f_lseek+0x1ce>
1234 kaklik 1930 #if !_FS_READONLY
1931 if (ofs > fp->fsize && !(fp->flag & FA_WRITE))
1296 kaklik 1932 aa6: aa 84 ldd r10, Y+10 ; 0x0a
1933 aa8: bb 84 ldd r11, Y+11 ; 0x0b
1934 aaa: cc 84 ldd r12, Y+12 ; 0x0c
1935 aac: dd 84 ldd r13, Y+13 ; 0x0d
1936 aae: ae 14 cp r10, r14
1937 ab0: bf 04 cpc r11, r15
1938 ab2: c0 06 cpc r12, r16
1939 ab4: d1 06 cpc r13, r17
1940 ab6: 10 f4 brcc .+4 ; 0xabc <f_lseek+0x44>
1941 ab8: 81 ff sbrs r24, 1
1942 aba: 02 c0 rjmp .+4 ; 0xac0 <f_lseek+0x48>
1943 abc: 57 01 movw r10, r14
1944 abe: 68 01 movw r12, r16
1234 kaklik 1945 #else
1946 if (ofs > fp->fsize)
1947 #endif
1948 ofs = fp->fsize;
1949 fp->fptr = 0; fp->sect_clust = 1; /* Set file R/W pointer to top of the file */
1296 kaklik 1950 ac0: 1e 82 std Y+6, r1 ; 0x06
1951 ac2: 1f 82 std Y+7, r1 ; 0x07
1952 ac4: 18 86 std Y+8, r1 ; 0x08
1953 ac6: 19 86 std Y+9, r1 ; 0x09
1954 ac8: 81 e0 ldi r24, 0x01 ; 1
1955 aca: 8b 83 std Y+3, r24 ; 0x03
1234 kaklik 1956  
1957 /* Move file R/W pointer if needed */
1958 if (ofs) {
1296 kaklik 1959 acc: a1 14 cp r10, r1
1960 ace: b1 04 cpc r11, r1
1961 ad0: c1 04 cpc r12, r1
1962 ad2: d1 04 cpc r13, r1
1963 ad4: 09 f4 brne .+2 ; 0xad8 <f_lseek+0x60>
1964 ad6: 9d c0 rjmp .+314 ; 0xc12 <f_lseek+0x19a>
1234 kaklik 1965 clust = fp->org_clust; /* Get start cluster */
1296 kaklik 1966 ad8: 6e 85 ldd r22, Y+14 ; 0x0e
1967 ada: 7f 85 ldd r23, Y+15 ; 0x0f
1234 kaklik 1968 #if !_FS_READONLY
1969 if (!clust) { /* If the file does not have a cluster chain, create new cluster chain */
1296 kaklik 1970 adc: 61 15 cp r22, r1
1971 ade: 71 05 cpc r23, r1
1972 ae0: 71 f4 brne .+28 ; 0xafe <f_lseek+0x86>
1234 kaklik 1973 clust = create_chain(0);
1296 kaklik 1974 ae2: 80 e0 ldi r24, 0x00 ; 0
1975 ae4: 90 e0 ldi r25, 0x00 ; 0
1976 ae6: 0e 94 d1 04 call 0x9a2 ; 0x9a2 <create_chain>
1977 aea: bc 01 movw r22, r24
1234 kaklik 1978 if (clust == 1) goto fk_error;
1296 kaklik 1979 aec: 81 30 cpi r24, 0x01 ; 1
1980 aee: 91 05 cpc r25, r1
1981 af0: 09 f4 brne .+2 ; 0xaf4 <f_lseek+0x7c>
1982 af2: a6 c0 rjmp .+332 ; 0xc40 <f_lseek+0x1c8>
1234 kaklik 1983 fp->org_clust = clust;
1296 kaklik 1984 af4: 9f 87 std Y+15, r25 ; 0x0f
1985 af6: 8e 87 std Y+14, r24 ; 0x0e
1234 kaklik 1986 }
1987 #endif
1988 if (clust) { /* If the file has a cluster chain, it can be followed */
1296 kaklik 1989 af8: 00 97 sbiw r24, 0x00 ; 0
1990 afa: 09 f4 brne .+2 ; 0xafe <f_lseek+0x86>
1991 afc: 8a c0 rjmp .+276 ; 0xc12 <f_lseek+0x19a>
1234 kaklik 1992 csize = (DWORD)fs->sects_clust * 512; /* Cluster size in unit of byte */
1296 kaklik 1993 afe: f3 01 movw r30, r6
1994 b00: 85 8d ldd r24, Z+29 ; 0x1d
1995 b02: e8 2e mov r14, r24
1996 b04: ff 24 eor r15, r15
1997 b06: 00 e0 ldi r16, 0x00 ; 0
1998 b08: 10 e0 ldi r17, 0x00 ; 0
1999 b0a: f9 e0 ldi r31, 0x09 ; 9
2000 b0c: ee 0c add r14, r14
2001 b0e: ff 1c adc r15, r15
2002 b10: 00 1f adc r16, r16
2003 b12: 11 1f adc r17, r17
2004 b14: fa 95 dec r31
2005 b16: d1 f7 brne .-12 ; 0xb0c <f_lseek+0x94>
1234 kaklik 2006 for (;;) { /* Loop to skip leading clusters */
2007 fp->curr_clust = clust; /* Update current cluster */
1296 kaklik 2008 b18: 79 8b std Y+17, r23 ; 0x11
2009 b1a: 68 8b std Y+16, r22 ; 0x10
1234 kaklik 2010 if (ofs <= csize) break;
1296 kaklik 2011 b1c: ea 14 cp r14, r10
2012 b1e: fb 04 cpc r15, r11
2013 b20: 0c 05 cpc r16, r12
2014 b22: 1d 05 cpc r17, r13
2015 b24: 58 f5 brcc .+86 ; 0xb7c <f_lseek+0x104>
1234 kaklik 2016 #if !_FS_READONLY
2017 if (fp->flag & FA_WRITE) /* Check if in write mode or not */
1296 kaklik 2018 b26: 8a 81 ldd r24, Y+2 ; 0x02
2019 b28: 81 ff sbrs r24, 1
2020 b2a: 04 c0 rjmp .+8 ; 0xb34 <f_lseek+0xbc>
1234 kaklik 2021 clust = create_chain(clust); /* Force streached if in write mode */
1296 kaklik 2022 b2c: cb 01 movw r24, r22
2023 b2e: 0e 94 d1 04 call 0x9a2 ; 0x9a2 <create_chain>
2024 b32: 03 c0 rjmp .+6 ; 0xb3a <f_lseek+0xc2>
1234 kaklik 2025 else
2026 #endif
2027 clust = get_cluster(clust); /* Only follow cluster chain if not in write mode */
1296 kaklik 2028 b34: cb 01 movw r24, r22
2029 b36: 0e 94 53 04 call 0x8a6 ; 0x8a6 <get_cluster>
2030 b3a: bc 01 movw r22, r24
1234 kaklik 2031 if (clust == 0) { /* Stop if could not follow the cluster chain */
1296 kaklik 2032 b3c: 00 97 sbiw r24, 0x00 ; 0
2033 b3e: e1 f0 breq .+56 ; 0xb78 <f_lseek+0x100>
1234 kaklik 2034 ofs = csize; break;
2035 }
2036 if (clust == 1 || clust >= fs->max_clust) goto fk_error;
1296 kaklik 2037 b40: 81 30 cpi r24, 0x01 ; 1
2038 b42: 91 05 cpc r25, r1
2039 b44: 09 f4 brne .+2 ; 0xb48 <f_lseek+0xd0>
2040 b46: 7c c0 rjmp .+248 ; 0xc40 <f_lseek+0x1c8>
2041 b48: f3 01 movw r30, r6
2042 b4a: 86 89 ldd r24, Z+22 ; 0x16
2043 b4c: 97 89 ldd r25, Z+23 ; 0x17
2044 b4e: 68 17 cp r22, r24
2045 b50: 79 07 cpc r23, r25
2046 b52: 08 f0 brcs .+2 ; 0xb56 <f_lseek+0xde>
2047 b54: 75 c0 rjmp .+234 ; 0xc40 <f_lseek+0x1c8>
1234 kaklik 2048 fp->fptr += csize; /* Update R/W pointer */
1296 kaklik 2049 b56: 8e 81 ldd r24, Y+6 ; 0x06
2050 b58: 9f 81 ldd r25, Y+7 ; 0x07
2051 b5a: a8 85 ldd r26, Y+8 ; 0x08
2052 b5c: b9 85 ldd r27, Y+9 ; 0x09
2053 b5e: 8e 0d add r24, r14
2054 b60: 9f 1d adc r25, r15
2055 b62: a0 1f adc r26, r16
2056 b64: b1 1f adc r27, r17
2057 b66: 8e 83 std Y+6, r24 ; 0x06
2058 b68: 9f 83 std Y+7, r25 ; 0x07
2059 b6a: a8 87 std Y+8, r26 ; 0x08
2060 b6c: b9 87 std Y+9, r27 ; 0x09
1234 kaklik 2061 ofs -= csize;
1296 kaklik 2062 b6e: ae 18 sub r10, r14
2063 b70: bf 08 sbc r11, r15
2064 b72: c0 0a sbc r12, r16
2065 b74: d1 0a sbc r13, r17
2066 b76: d0 cf rjmp .-96 ; 0xb18 <f_lseek+0xa0>
1234 kaklik 2067 }
1296 kaklik 2068 b78: 57 01 movw r10, r14
2069 b7a: 68 01 movw r12, r16
1234 kaklik 2070 csect = (BYTE)((ofs - 1) / 512); /* Sector offset in the cluster */
1296 kaklik 2071 b7c: d6 01 movw r26, r12
2072 b7e: c5 01 movw r24, r10
2073 b80: 01 97 sbiw r24, 0x01 ; 1
2074 b82: a1 09 sbc r26, r1
2075 b84: b1 09 sbc r27, r1
2076 b86: e9 e0 ldi r30, 0x09 ; 9
2077 b88: b6 95 lsr r27
2078 b8a: a7 95 ror r26
2079 b8c: 97 95 ror r25
2080 b8e: 87 95 ror r24
2081 b90: ea 95 dec r30
2082 b92: d1 f7 brne .-12 ; 0xb88 <f_lseek+0x110>
2083 b94: f8 2e mov r15, r24
2084 static
2085 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
2086 CLUST clust /* Cluster# to be converted */
2087 )
2088 {
2089 FATFS *fs = FatFs;
2090 b96: 00 91 10 01 lds r16, 0x0110
2091 b9a: 10 91 11 01 lds r17, 0x0111
2092  
2093  
2094 clust -= 2;
2095 b9e: 62 50 subi r22, 0x02 ; 2
2096 ba0: 70 40 sbci r23, 0x00 ; 0
2097 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
2098 ba2: f8 01 movw r30, r16
2099 ba4: 86 89 ldd r24, Z+22 ; 0x16
2100 ba6: 97 89 ldd r25, Z+23 ; 0x17
2101 ba8: 02 97 sbiw r24, 0x02 ; 2
2102 baa: 68 17 cp r22, r24
2103 bac: 79 07 cpc r23, r25
2104 bae: 28 f0 brcs .+10 ; 0xbba <f_lseek+0x142>
2105 bb0: 20 e0 ldi r18, 0x00 ; 0
2106 bb2: 30 e0 ldi r19, 0x00 ; 0
2107 bb4: 40 e0 ldi r20, 0x00 ; 0
2108 bb6: 50 e0 ldi r21, 0x00 ; 0
2109 bb8: 14 c0 rjmp .+40 ; 0xbe2 <f_lseek+0x16a>
2110 return (DWORD)clust * fs->sects_clust + fs->database;
2111 bba: 80 e0 ldi r24, 0x00 ; 0
2112 bbc: 90 e0 ldi r25, 0x00 ; 0
2113 bbe: f8 01 movw r30, r16
2114 bc0: 25 8d ldd r18, Z+29 ; 0x1d
2115 bc2: 30 e0 ldi r19, 0x00 ; 0
2116 bc4: 40 e0 ldi r20, 0x00 ; 0
2117 bc6: 50 e0 ldi r21, 0x00 ; 0
2118 bc8: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
2119 bcc: 9b 01 movw r18, r22
2120 bce: ac 01 movw r20, r24
2121 bd0: f8 01 movw r30, r16
2122 bd2: 80 89 ldd r24, Z+16 ; 0x10
2123 bd4: 91 89 ldd r25, Z+17 ; 0x11
2124 bd6: a2 89 ldd r26, Z+18 ; 0x12
2125 bd8: b3 89 ldd r27, Z+19 ; 0x13
2126 bda: 28 0f add r18, r24
2127 bdc: 39 1f adc r19, r25
2128 bde: 4a 1f adc r20, r26
2129 be0: 5b 1f adc r21, r27
2130 if (clust == 1 || clust >= fs->max_clust) goto fk_error;
2131 fp->fptr += csize; /* Update R/W pointer */
2132 ofs -= csize;
2133 }
2134 csect = (BYTE)((ofs - 1) / 512); /* Sector offset in the cluster */
1234 kaklik 2135 fp->curr_sect = clust2sect(clust) + csect; /* Current sector */
1296 kaklik 2136 be2: 2f 0d add r18, r15
2137 be4: 31 1d adc r19, r1
2138 be6: 41 1d adc r20, r1
2139 be8: 51 1d adc r21, r1
2140 bea: 2a 8b std Y+18, r18 ; 0x12
2141 bec: 3b 8b std Y+19, r19 ; 0x13
2142 bee: 4c 8b std Y+20, r20 ; 0x14
2143 bf0: 5d 8b std Y+21, r21 ; 0x15
1234 kaklik 2144 fp->sect_clust = fs->sects_clust - csect; /* Left sector counter in the cluster */
1296 kaklik 2145 bf2: f3 01 movw r30, r6
2146 bf4: 85 8d ldd r24, Z+29 ; 0x1d
2147 bf6: 8f 19 sub r24, r15
2148 bf8: 8b 83 std Y+3, r24 ; 0x03
1234 kaklik 2149 fp->fptr += ofs; /* Update file R/W pointer */
1296 kaklik 2150 bfa: 8e 81 ldd r24, Y+6 ; 0x06
2151 bfc: 9f 81 ldd r25, Y+7 ; 0x07
2152 bfe: a8 85 ldd r26, Y+8 ; 0x08
2153 c00: b9 85 ldd r27, Y+9 ; 0x09
2154 c02: 8a 0d add r24, r10
2155 c04: 9b 1d adc r25, r11
2156 c06: ac 1d adc r26, r12
2157 c08: bd 1d adc r27, r13
2158 c0a: 8e 83 std Y+6, r24 ; 0x06
2159 c0c: 9f 83 std Y+7, r25 ; 0x07
2160 c0e: a8 87 std Y+8, r26 ; 0x08
2161 c10: b9 87 std Y+9, r27 ; 0x09
1234 kaklik 2162 }
2163 }
2164 #if !_FS_READONLY
2165 if ((fp->flag & FA_WRITE) && fp->fptr > fp->fsize) { /* Set updated flag if in write mode */
1296 kaklik 2166 c12: 6a 81 ldd r22, Y+2 ; 0x02
2167 c14: 61 ff sbrs r22, 1
2168 c16: 1a c0 rjmp .+52 ; 0xc4c <f_lseek+0x1d4>
2169 c18: 2e 81 ldd r18, Y+6 ; 0x06
2170 c1a: 3f 81 ldd r19, Y+7 ; 0x07
2171 c1c: 48 85 ldd r20, Y+8 ; 0x08
2172 c1e: 59 85 ldd r21, Y+9 ; 0x09
2173 c20: 8a 85 ldd r24, Y+10 ; 0x0a
2174 c22: 9b 85 ldd r25, Y+11 ; 0x0b
2175 c24: ac 85 ldd r26, Y+12 ; 0x0c
2176 c26: bd 85 ldd r27, Y+13 ; 0x0d
2177 c28: 82 17 cp r24, r18
2178 c2a: 93 07 cpc r25, r19
2179 c2c: a4 07 cpc r26, r20
2180 c2e: b5 07 cpc r27, r21
2181 c30: 68 f4 brcc .+26 ; 0xc4c <f_lseek+0x1d4>
1234 kaklik 2182 fp->fsize = fp->fptr;
1296 kaklik 2183 c32: 2a 87 std Y+10, r18 ; 0x0a
2184 c34: 3b 87 std Y+11, r19 ; 0x0b
2185 c36: 4c 87 std Y+12, r20 ; 0x0c
2186 c38: 5d 87 std Y+13, r21 ; 0x0d
1234 kaklik 2187 fp->flag |= FA__WRITTEN;
1296 kaklik 2188 c3a: 60 62 ori r22, 0x20 ; 32
2189 c3c: 6a 83 std Y+2, r22 ; 0x02
2190 c3e: 06 c0 rjmp .+12 ; 0xc4c <f_lseek+0x1d4>
1234 kaklik 2191 #endif
2192  
2193 return FR_OK;
2194  
2195 fk_error: /* Abort this function due to an unrecoverable error */
2196 fp->flag |= FA__ERROR;
1296 kaklik 2197 c40: 8a 81 ldd r24, Y+2 ; 0x02
2198 c42: 80 68 ori r24, 0x80 ; 128
2199 c44: 8a 83 std Y+2, r24 ; 0x02
2200 c46: 68 e0 ldi r22, 0x08 ; 8
2201 c48: 86 2e mov r8, r22
2202 c4a: 91 2c mov r9, r1
1234 kaklik 2203 return FR_RW_ERROR;
2204 }
1296 kaklik 2205 c4c: c4 01 movw r24, r8
2206 c4e: cd b7 in r28, 0x3d ; 61
2207 c50: de b7 in r29, 0x3e ; 62
2208 c52: ee e0 ldi r30, 0x0E ; 14
2209 c54: 0c 94 e7 14 jmp 0x29ce ; 0x29ce <__epilogue_restores__+0x8>
1234 kaklik 2210  
1296 kaklik 2211 00000c58 <next_dir_entry>:
2212  
2213 static
2214 BOOL next_dir_entry ( /* TRUE: successful, FALSE: could not move next */
2215 DIR *dirobj /* Pointer to directory object */
2216 )
2217 {
2218 c58: ef 92 push r14
2219 c5a: ff 92 push r15
2220 c5c: 0f 93 push r16
2221 c5e: 1f 93 push r17
2222 c60: cf 93 push r28
2223 c62: df 93 push r29
2224 c64: 8c 01 movw r16, r24
2225 CLUST clust;
2226 WORD idx;
2227 FATFS *fs = FatFs;
2228 c66: c0 91 10 01 lds r28, 0x0110
2229 c6a: d0 91 11 01 lds r29, 0x0111
2230  
2231  
2232 idx = dirobj->index + 1;
2233 c6e: fc 01 movw r30, r24
2234 c70: e2 80 ldd r14, Z+2 ; 0x02
2235 c72: f3 80 ldd r15, Z+3 ; 0x03
2236 c74: 08 94 sec
2237 c76: e1 1c adc r14, r1
2238 c78: f1 1c adc r15, r1
2239 if ((idx & 15) == 0) { /* Table sector changed? */
2240 c7a: c7 01 movw r24, r14
2241 c7c: 8f 70 andi r24, 0x0F ; 15
2242 c7e: 90 70 andi r25, 0x00 ; 0
2243 c80: 89 2b or r24, r25
2244 c82: 09 f0 breq .+2 ; 0xc86 <next_dir_entry+0x2e>
2245 c84: 5b c0 rjmp .+182 ; 0xd3c <next_dir_entry+0xe4>
2246 dirobj->sect++; /* Next sector */
2247 c86: 82 85 ldd r24, Z+10 ; 0x0a
2248 c88: 93 85 ldd r25, Z+11 ; 0x0b
2249 c8a: a4 85 ldd r26, Z+12 ; 0x0c
2250 c8c: b5 85 ldd r27, Z+13 ; 0x0d
2251 c8e: 01 96 adiw r24, 0x01 ; 1
2252 c90: a1 1d adc r26, r1
2253 c92: b1 1d adc r27, r1
2254 c94: 82 87 std Z+10, r24 ; 0x0a
2255 c96: 93 87 std Z+11, r25 ; 0x0b
2256 c98: a4 87 std Z+12, r26 ; 0x0c
2257 c9a: b5 87 std Z+13, r27 ; 0x0d
2258 if (!dirobj->clust) { /* In static table */
2259 c9c: 40 85 ldd r20, Z+8 ; 0x08
2260 c9e: 51 85 ldd r21, Z+9 ; 0x09
2261 ca0: 41 15 cp r20, r1
2262 ca2: 51 05 cpc r21, r1
2263 ca4: 39 f4 brne .+14 ; 0xcb4 <next_dir_entry+0x5c>
2264 if (idx >= fs->n_rootdir) return FALSE; /* Reached to end of table */
2265 ca6: 8a 81 ldd r24, Y+2 ; 0x02
2266 ca8: 9b 81 ldd r25, Y+3 ; 0x03
2267 caa: e8 16 cp r14, r24
2268 cac: f9 06 cpc r15, r25
2269 cae: 08 f4 brcc .+2 ; 0xcb2 <next_dir_entry+0x5a>
2270 cb0: 45 c0 rjmp .+138 ; 0xd3c <next_dir_entry+0xe4>
2271 cb2: 49 c0 rjmp .+146 ; 0xd46 <next_dir_entry+0xee>
2272 } else { /* In dynamic table */
2273 if (((idx / 16) & (fs->sects_clust - 1)) == 0) { /* Cluster changed? */
2274 cb4: 8d 8d ldd r24, Y+29 ; 0x1d
2275 cb6: 90 e0 ldi r25, 0x00 ; 0
2276 cb8: 01 97 sbiw r24, 0x01 ; 1
2277 cba: 97 01 movw r18, r14
2278 cbc: a4 e0 ldi r26, 0x04 ; 4
2279 cbe: 36 95 lsr r19
2280 cc0: 27 95 ror r18
2281 cc2: aa 95 dec r26
2282 cc4: e1 f7 brne .-8 ; 0xcbe <next_dir_entry+0x66>
2283 cc6: 82 23 and r24, r18
2284 cc8: 93 23 and r25, r19
2285 cca: 89 2b or r24, r25
2286 ccc: b9 f5 brne .+110 ; 0xd3c <next_dir_entry+0xe4>
2287 clust = get_cluster(dirobj->clust); /* Get next cluster */
2288 cce: ca 01 movw r24, r20
2289 cd0: 0e 94 53 04 call 0x8a6 ; 0x8a6 <get_cluster>
2290 cd4: bc 01 movw r22, r24
2291 if (clust < 2 || clust >= fs->max_clust) /* Reached to end of table */
2292 cd6: 82 30 cpi r24, 0x02 ; 2
2293 cd8: 91 05 cpc r25, r1
2294 cda: a8 f1 brcs .+106 ; 0xd46 <next_dir_entry+0xee>
2295 cdc: 8e 89 ldd r24, Y+22 ; 0x16
2296 cde: 9f 89 ldd r25, Y+23 ; 0x17
2297 ce0: 68 17 cp r22, r24
2298 ce2: 79 07 cpc r23, r25
2299 ce4: 80 f5 brcc .+96 ; 0xd46 <next_dir_entry+0xee>
2300 return FALSE;
2301 dirobj->clust = clust; /* Initialize for new cluster */
2302 ce6: f8 01 movw r30, r16
2303 ce8: 71 87 std Z+9, r23 ; 0x09
2304 cea: 60 87 std Z+8, r22 ; 0x08
2305 static
2306 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
2307 CLUST clust /* Cluster# to be converted */
2308 )
2309 {
2310 FATFS *fs = FatFs;
2311 cec: c0 91 10 01 lds r28, 0x0110
2312 cf0: d0 91 11 01 lds r29, 0x0111
2313  
2314  
2315 clust -= 2;
2316 cf4: 62 50 subi r22, 0x02 ; 2
2317 cf6: 70 40 sbci r23, 0x00 ; 0
2318 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
2319 cf8: 8e 89 ldd r24, Y+22 ; 0x16
2320 cfa: 9f 89 ldd r25, Y+23 ; 0x17
2321 cfc: 02 97 sbiw r24, 0x02 ; 2
2322 cfe: 68 17 cp r22, r24
2323 d00: 79 07 cpc r23, r25
2324 d02: 28 f0 brcs .+10 ; 0xd0e <next_dir_entry+0xb6>
2325 d04: 20 e0 ldi r18, 0x00 ; 0
2326 d06: 30 e0 ldi r19, 0x00 ; 0
2327 d08: 40 e0 ldi r20, 0x00 ; 0
2328 d0a: 50 e0 ldi r21, 0x00 ; 0
2329 d0c: 12 c0 rjmp .+36 ; 0xd32 <next_dir_entry+0xda>
2330 return (DWORD)clust * fs->sects_clust + fs->database;
2331 d0e: 80 e0 ldi r24, 0x00 ; 0
2332 d10: 90 e0 ldi r25, 0x00 ; 0
2333 d12: 2d 8d ldd r18, Y+29 ; 0x1d
2334 d14: 30 e0 ldi r19, 0x00 ; 0
2335 d16: 40 e0 ldi r20, 0x00 ; 0
2336 d18: 50 e0 ldi r21, 0x00 ; 0
2337 d1a: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
2338 d1e: 9b 01 movw r18, r22
2339 d20: ac 01 movw r20, r24
2340 d22: 88 89 ldd r24, Y+16 ; 0x10
2341 d24: 99 89 ldd r25, Y+17 ; 0x11
2342 d26: aa 89 ldd r26, Y+18 ; 0x12
2343 d28: bb 89 ldd r27, Y+19 ; 0x13
2344 d2a: 28 0f add r18, r24
2345 d2c: 39 1f adc r19, r25
2346 d2e: 4a 1f adc r20, r26
2347 d30: 5b 1f adc r21, r27
2348 if (((idx / 16) & (fs->sects_clust - 1)) == 0) { /* Cluster changed? */
2349 clust = get_cluster(dirobj->clust); /* Get next cluster */
2350 if (clust < 2 || clust >= fs->max_clust) /* Reached to end of table */
2351 return FALSE;
2352 dirobj->clust = clust; /* Initialize for new cluster */
2353 dirobj->sect = clust2sect(clust);
2354 d32: f8 01 movw r30, r16
2355 d34: 22 87 std Z+10, r18 ; 0x0a
2356 d36: 33 87 std Z+11, r19 ; 0x0b
2357 d38: 44 87 std Z+12, r20 ; 0x0c
2358 d3a: 55 87 std Z+13, r21 ; 0x0d
2359 }
2360 }
2361 }
2362 dirobj->index = idx; /* Lower 4 bit of dirobj->index indicates offset in dirobj->sect */
2363 d3c: f8 01 movw r30, r16
2364 d3e: f3 82 std Z+3, r15 ; 0x03
2365 d40: e2 82 std Z+2, r14 ; 0x02
2366 d42: 81 e0 ldi r24, 0x01 ; 1
2367 d44: 01 c0 rjmp .+2 ; 0xd48 <next_dir_entry+0xf0>
2368 return TRUE;
2369 d46: 80 e0 ldi r24, 0x00 ; 0
2370 }
2371 d48: cd b7 in r28, 0x3d ; 61
2372 d4a: de b7 in r29, 0x3e ; 62
2373 d4c: e6 e0 ldi r30, 0x06 ; 6
2374 d4e: 0c 94 ef 14 jmp 0x29de ; 0x29de <__epilogue_restores__+0x18>
2375  
2376 00000d52 <f_sync>:
1234 kaklik 2377 /*-----------------------------------------------------------------------*/
2378  
2379 FRESULT f_sync (
2380 FIL *fp /* Pointer to the file object */
2381 )
2382 {
1296 kaklik 2383 d52: ef 92 push r14
2384 d54: ff 92 push r15
2385 d56: 0f 93 push r16
2386 d58: 1f 93 push r17
2387 d5a: cf 93 push r28
2388 d5c: df 93 push r29
2389 d5e: ec 01 movw r28, r24
1234 kaklik 2390 BYTE *dir;
2391 FRESULT res;
2392 FATFS *fs = fp->fs;
2393  
2394  
2395 res = validate(fs, fp->id); /* Check validity of the object */
1296 kaklik 2396 d60: 68 81 ld r22, Y
2397 d62: 79 81 ldd r23, Y+1 ; 0x01
2398 d64: 8c 81 ldd r24, Y+4 ; 0x04
2399 d66: 9d 81 ldd r25, Y+5 ; 0x05
2400 d68: 0e 94 46 03 call 0x68c ; 0x68c <validate>
2401 d6c: 7c 01 movw r14, r24
1234 kaklik 2402 if (res == FR_OK) {
1296 kaklik 2403 d6e: 00 97 sbiw r24, 0x00 ; 0
2404 d70: 09 f0 breq .+2 ; 0xd74 <f_sync+0x22>
2405 d72: 40 c0 rjmp .+128 ; 0xdf4 <f_sync+0xa2>
1234 kaklik 2406 if (fp->flag & FA__WRITTEN) { /* Has the file been written? */
1296 kaklik 2407 d74: 8a 81 ldd r24, Y+2 ; 0x02
2408 d76: 85 ff sbrs r24, 5
2409 d78: 3d c0 rjmp .+122 ; 0xdf4 <f_sync+0xa2>
1234 kaklik 2410 /* Update the directory entry */
2411 if (!move_window(fp->dir_sect))
1296 kaklik 2412 d7a: 6e 89 ldd r22, Y+22 ; 0x16
2413 d7c: 7f 89 ldd r23, Y+23 ; 0x17
2414 d7e: 88 8d ldd r24, Y+24 ; 0x18
2415 d80: 99 8d ldd r25, Y+25 ; 0x19
2416 d82: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
2417 d86: 88 23 and r24, r24
2418 d88: 91 f1 breq .+100 ; 0xdee <f_sync+0x9c>
1234 kaklik 2419 return FR_RW_ERROR;
2420 dir = fp->dir_ptr;
1296 kaklik 2421 d8a: 0a 8d ldd r16, Y+26 ; 0x1a
2422 d8c: 1b 8d ldd r17, Y+27 ; 0x1b
1234 kaklik 2423 dir[DIR_Attr] |= AM_ARC; /* Set archive bit */
1296 kaklik 2424 d8e: f8 01 movw r30, r16
2425 d90: 83 85 ldd r24, Z+11 ; 0x0b
2426 d92: 80 62 ori r24, 0x20 ; 32
2427 d94: 83 87 std Z+11, r24 ; 0x0b
1234 kaklik 2428 ST_DWORD(&dir[DIR_FileSize], fp->fsize); /* Update file size */
1296 kaklik 2429 d96: 8a 85 ldd r24, Y+10 ; 0x0a
2430 d98: 9b 85 ldd r25, Y+11 ; 0x0b
2431 d9a: ac 85 ldd r26, Y+12 ; 0x0c
2432 d9c: bd 85 ldd r27, Y+13 ; 0x0d
2433 d9e: 84 8f std Z+28, r24 ; 0x1c
2434 da0: 95 8f std Z+29, r25 ; 0x1d
2435 da2: a6 8f std Z+30, r26 ; 0x1e
2436 da4: b7 8f std Z+31, r27 ; 0x1f
1234 kaklik 2437 ST_WORD(&dir[DIR_FstClusLO], fp->org_clust); /* Update start cluster */
1296 kaklik 2438 da6: 8e 85 ldd r24, Y+14 ; 0x0e
2439 da8: 9f 85 ldd r25, Y+15 ; 0x0f
2440 daa: 93 8f std Z+27, r25 ; 0x1b
2441 dac: 82 8f std Z+26, r24 ; 0x1a
1234 kaklik 2442 #if _FAT32
2443 ST_WORD(&dir[DIR_FstClusHI], fp->org_clust >> 16);
2444 #endif
2445 tim = get_fattime(); /* Updated time */
1296 kaklik 2446 dae: 0e 94 b0 00 call 0x160 ; 0x160 <get_fattime>
1234 kaklik 2447 ST_DWORD(&dir[DIR_WrtTime], tim);
1296 kaklik 2448 db2: f8 01 movw r30, r16
2449 db4: 66 8b std Z+22, r22 ; 0x16
2450 db6: 77 8b std Z+23, r23 ; 0x17
2451 db8: 80 8f std Z+24, r24 ; 0x18
2452 dba: 91 8f std Z+25, r25 ; 0x19
1234 kaklik 2453 fp->flag &= ~FA__WRITTEN;
1296 kaklik 2454 dbc: 8a 81 ldd r24, Y+2 ; 0x02
2455 dbe: 8f 7d andi r24, 0xDF ; 223
2456 dc0: 8a 83 std Y+2, r24 ; 0x02
1234 kaklik 2457 FRESULT sync (void) /* FR_OK: successful, FR_RW_ERROR: failed */
2458 {
2459 FATFS *fs = FatFs;
2460  
2461  
2462 fs->winflag = 1;
1296 kaklik 2463 dc2: e0 91 10 01 lds r30, 0x0110
2464 dc6: f0 91 11 01 lds r31, 0x0111
2465 dca: 81 e0 ldi r24, 0x01 ; 1
2466 dcc: 87 8f std Z+31, r24 ; 0x1f
1234 kaklik 2467 if (!move_window(0)) return FR_RW_ERROR;
1296 kaklik 2468 dce: 60 e0 ldi r22, 0x00 ; 0
2469 dd0: 70 e0 ldi r23, 0x00 ; 0
2470 dd2: 80 e0 ldi r24, 0x00 ; 0
2471 dd4: 90 e0 ldi r25, 0x00 ; 0
2472 dd6: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
2473 dda: 88 23 and r24, r24
2474 ddc: 41 f0 breq .+16 ; 0xdee <f_sync+0x9c>
1234 kaklik 2475 ST_DWORD(&fs->win[FSI_Nxt_Free], fs->last_clust);
2476 disk_write(0, fs->win, fs->fsi_sector, 1);
2477 fs->fsi_flag = 0;
2478 }
2479 #endif
2480 if (disk_ioctl(0, CTRL_SYNC, NULL) != RES_OK) return FR_RW_ERROR;
1296 kaklik 2481 dde: 40 e0 ldi r20, 0x00 ; 0
2482 de0: 50 e0 ldi r21, 0x00 ; 0
2483 de2: 63 e0 ldi r22, 0x03 ; 3
2484 de4: 80 e0 ldi r24, 0x00 ; 0
2485 de6: 0e 94 77 10 call 0x20ee ; 0x20ee <disk_ioctl>
2486 dea: 89 2b or r24, r25
2487 dec: 19 f0 breq .+6 ; 0xdf4 <f_sync+0xa2>
2488 dee: b8 e0 ldi r27, 0x08 ; 8
2489 df0: eb 2e mov r14, r27
2490 df2: f1 2c mov r15, r1
1234 kaklik 2491 fp->flag &= ~FA__WRITTEN;
2492 res = sync();
2493 }
2494 }
2495 return res;
2496 }
1296 kaklik 2497 df4: c7 01 movw r24, r14
2498 df6: cd b7 in r28, 0x3d ; 61
2499 df8: de b7 in r29, 0x3e ; 62
2500 dfa: e6 e0 ldi r30, 0x06 ; 6
2501 dfc: 0c 94 ef 14 jmp 0x29de ; 0x29de <__epilogue_restores__+0x18>
1234 kaklik 2502  
1296 kaklik 2503 00000e00 <f_close>:
1234 kaklik 2504 /*-----------------------------------------------------------------------*/
2505  
2506 FRESULT f_close (
2507 FIL *fp /* Pointer to the file object to be closed */
2508 )
2509 {
1296 kaklik 2510 e00: cf 93 push r28
2511 e02: df 93 push r29
2512 e04: ec 01 movw r28, r24
1234 kaklik 2513 FRESULT res;
2514  
2515  
2516 #if !_FS_READONLY
2517 res = f_sync(fp);
1296 kaklik 2518 e06: 0e 94 a9 06 call 0xd52 ; 0xd52 <f_sync>
2519 e0a: 9c 01 movw r18, r24
1234 kaklik 2520 #else
2521 res = validate(fp->fs, fp->id);
2522 #endif
2523 if (res == FR_OK)
1296 kaklik 2524 e0c: 00 97 sbiw r24, 0x00 ; 0
2525 e0e: 11 f4 brne .+4 ; 0xe14 <f_close+0x14>
1234 kaklik 2526 fp->fs = NULL;
1296 kaklik 2527 e10: 1d 82 std Y+5, r1 ; 0x05
2528 e12: 1c 82 std Y+4, r1 ; 0x04
1234 kaklik 2529  
1296 kaklik 2530 return res;
2531 }
2532 e14: c9 01 movw r24, r18
2533 e16: df 91 pop r29
2534 e18: cf 91 pop r28
2535 e1a: 08 95 ret
2536  
2537 00000e1c <f_write>:
1234 kaklik 2538 FIL *fp, /* Pointer to the file object */
2539 const void *buff, /* Pointer to the data to be written */
2540 WORD btw, /* Number of bytes to write */
2541 WORD *bw /* Pointer to number of bytes written */
2542 )
2543 {
1296 kaklik 2544 e1c: a0 e0 ldi r26, 0x00 ; 0
2545 e1e: b0 e0 ldi r27, 0x00 ; 0
2546 e20: e4 e1 ldi r30, 0x14 ; 20
2547 e22: f7 e0 ldi r31, 0x07 ; 7
2548 e24: 0c 94 c8 14 jmp 0x2990 ; 0x2990 <__prologue_saves__+0x2>
2549 e28: ec 01 movw r28, r24
2550 e2a: 16 2f mov r17, r22
2551 e2c: 07 2f mov r16, r23
2552 e2e: 7a 01 movw r14, r20
2553 e30: 39 01 movw r6, r18
1234 kaklik 2554 WORD wcnt;
2555 CLUST clust;
2556 BYTE cc;
2557 FRESULT res;
2558 const BYTE *wbuff = buff;
2559 FATFS *fs = fp->fs;
1296 kaklik 2560 e32: ac 80 ldd r10, Y+4 ; 0x04
2561 e34: bd 80 ldd r11, Y+5 ; 0x05
1234 kaklik 2562  
2563  
2564 *bw = 0;
1296 kaklik 2565 e36: f9 01 movw r30, r18
2566 e38: 11 82 std Z+1, r1 ; 0x01
2567 e3a: 10 82 st Z, r1
1234 kaklik 2568 res = validate(fs, fp->id); /* Check validity of the object */
1296 kaklik 2569 e3c: 68 81 ld r22, Y
2570 e3e: 79 81 ldd r23, Y+1 ; 0x01
2571 e40: c5 01 movw r24, r10
2572 e42: 0e 94 46 03 call 0x68c ; 0x68c <validate>
2573 e46: 4c 01 movw r8, r24
1234 kaklik 2574 if (res) return res;
1296 kaklik 2575 e48: 00 97 sbiw r24, 0x00 ; 0
2576 e4a: 09 f0 breq .+2 ; 0xe4e <f_write+0x32>
2577 e4c: 3b c1 rjmp .+630 ; 0x10c4 <f_write+0x2a8>
1234 kaklik 2578 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
1296 kaklik 2579 e4e: 8a 81 ldd r24, Y+2 ; 0x02
2580 e50: 87 fd sbrc r24, 7
2581 e52: 35 c1 rjmp .+618 ; 0x10be <f_write+0x2a2>
1234 kaklik 2582 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
1296 kaklik 2583 e54: 81 fd sbrc r24, 1
2584 e56: 04 c0 rjmp .+8 ; 0xe60 <f_write+0x44>
2585 e58: 36 e0 ldi r19, 0x06 ; 6
2586 e5a: 83 2e mov r8, r19
2587 e5c: 91 2c mov r9, r1
2588 e5e: 32 c1 rjmp .+612 ; 0x10c4 <f_write+0x2a8>
1234 kaklik 2589 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
1296 kaklik 2590 e60: 2a 85 ldd r18, Y+10 ; 0x0a
2591 e62: 3b 85 ldd r19, Y+11 ; 0x0b
2592 e64: 4c 85 ldd r20, Y+12 ; 0x0c
2593 e66: 5d 85 ldd r21, Y+13 ; 0x0d
2594 e68: c7 01 movw r24, r14
2595 e6a: a0 e0 ldi r26, 0x00 ; 0
2596 e6c: b0 e0 ldi r27, 0x00 ; 0
2597 e6e: 82 0f add r24, r18
2598 e70: 93 1f adc r25, r19
2599 e72: a4 1f adc r26, r20
2600 e74: b5 1f adc r27, r21
2601 e76: 82 17 cp r24, r18
2602 e78: 93 07 cpc r25, r19
2603 e7a: a4 07 cpc r26, r20
2604 e7c: b5 07 cpc r27, r21
2605 e7e: 08 f4 brcc .+2 ; 0xe82 <f_write+0x66>
2606 e80: 21 c1 rjmp .+578 ; 0x10c4 <f_write+0x2a8>
1234 kaklik 2607 DWORD sect;
2608 WORD wcnt;
2609 CLUST clust;
2610 BYTE cc;
2611 FRESULT res;
2612 const BYTE *wbuff = buff;
1296 kaklik 2613 e82: 81 2f mov r24, r17
2614 e84: 90 2f mov r25, r16
2615 e86: 9c 01 movw r18, r24
2616 e88: 69 01 movw r12, r18
2617 fs->winsect = fp->curr_sect;
2618 }
1234 kaklik 2619 }
2620 if (!move_window(fp->curr_sect)) /* Move sector window */
2621 goto fw_error;
2622 wcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes bytes to sector window */
1296 kaklik 2623 e8a: 41 2c mov r4, r1
2624 e8c: 22 e0 ldi r18, 0x02 ; 2
2625 e8e: 52 2e mov r5, r18
1234 kaklik 2626 if (wcnt > btw) wcnt = btw;
2627 memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
1296 kaklik 2628 fs->winflag = 1;
2629 e90: 33 24 eor r3, r3
2630 e92: 33 94 inc r3
2631 e94: f8 c0 rjmp .+496 ; 0x1086 <f_write+0x26a>
1234 kaklik 2632 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2633 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2634  
2635 for ( ; btw; /* Repeat until all data transferred */
2636 wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
2637 if ((fp->fptr % 512) == 0) { /* On the sector boundary */
1296 kaklik 2638 e96: 2e 81 ldd r18, Y+6 ; 0x06
2639 e98: 3f 81 ldd r19, Y+7 ; 0x07
2640 e9a: 48 85 ldd r20, Y+8 ; 0x08
2641 e9c: 59 85 ldd r21, Y+9 ; 0x09
2642 e9e: da 01 movw r26, r20
2643 ea0: c9 01 movw r24, r18
2644 ea2: 91 70 andi r25, 0x01 ; 1
2645 ea4: a0 70 andi r26, 0x00 ; 0
2646 ea6: b0 70 andi r27, 0x00 ; 0
2647 ea8: 00 97 sbiw r24, 0x00 ; 0
2648 eaa: a1 05 cpc r26, r1
2649 eac: b1 05 cpc r27, r1
2650 eae: 09 f0 breq .+2 ; 0xeb2 <f_write+0x96>
2651 eb0: b1 c0 rjmp .+354 ; 0x1014 <f_write+0x1f8>
1234 kaklik 2652 if (--(fp->sect_clust)) { /* Decrement left sector counter */
1296 kaklik 2653 eb2: 8b 81 ldd r24, Y+3 ; 0x03
2654 eb4: 81 50 subi r24, 0x01 ; 1
2655 eb6: 8b 83 std Y+3, r24 ; 0x03
2656 eb8: 88 23 and r24, r24
2657 eba: 49 f0 breq .+18 ; 0xece <f_write+0xb2>
1234 kaklik 2658 sect = fp->curr_sect + 1; /* Get current sector */
1296 kaklik 2659 ebc: 2a 89 ldd r18, Y+18 ; 0x12
2660 ebe: 3b 89 ldd r19, Y+19 ; 0x13
2661 ec0: 4c 89 ldd r20, Y+20 ; 0x14
2662 ec2: 5d 89 ldd r21, Y+21 ; 0x15
2663 ec4: 2f 5f subi r18, 0xFF ; 255
2664 ec6: 3f 4f sbci r19, 0xFF ; 255
2665 ec8: 4f 4f sbci r20, 0xFF ; 255
2666 eca: 5f 4f sbci r21, 0xFF ; 255
2667 ecc: 51 c0 rjmp .+162 ; 0xf70 <f_write+0x154>
1234 kaklik 2668 } else { /* On the cluster boundary, get next cluster */
2669 if (fp->fptr == 0) { /* Is top of the file */
1296 kaklik 2670 ece: 21 15 cp r18, r1
2671 ed0: 31 05 cpc r19, r1
2672 ed2: 41 05 cpc r20, r1
2673 ed4: 51 05 cpc r21, r1
2674 ed6: 69 f4 brne .+26 ; 0xef2 <f_write+0xd6>
1234 kaklik 2675 clust = fp->org_clust;
1296 kaklik 2676 ed8: 6e 85 ldd r22, Y+14 ; 0x0e
2677 eda: 7f 85 ldd r23, Y+15 ; 0x0f
1234 kaklik 2678 if (clust == 0) /* No cluster is created yet */
1296 kaklik 2679 edc: 61 15 cp r22, r1
2680 ede: 71 05 cpc r23, r1
2681 ee0: 89 f4 brne .+34 ; 0xf04 <f_write+0xe8>
1234 kaklik 2682 fp->org_clust = clust = create_chain(0); /* Create a new cluster chain */
1296 kaklik 2683 ee2: 80 e0 ldi r24, 0x00 ; 0
2684 ee4: 90 e0 ldi r25, 0x00 ; 0
2685 ee6: 0e 94 d1 04 call 0x9a2 ; 0x9a2 <create_chain>
2686 eea: bc 01 movw r22, r24
2687 eec: 9f 87 std Y+15, r25 ; 0x0f
2688 eee: 8e 87 std Y+14, r24 ; 0x0e
2689 ef0: 05 c0 rjmp .+10 ; 0xefc <f_write+0xe0>
1234 kaklik 2690 } else { /* Middle or end of file */
2691 clust = create_chain(fp->curr_clust); /* Trace or streach cluster chain */
1296 kaklik 2692 ef2: 88 89 ldd r24, Y+16 ; 0x10
2693 ef4: 99 89 ldd r25, Y+17 ; 0x11
2694 ef6: 0e 94 d1 04 call 0x9a2 ; 0x9a2 <create_chain>
2695 efa: bc 01 movw r22, r24
1234 kaklik 2696 }
2697 if (clust == 0) break; /* Disk full */
1296 kaklik 2698 efc: 61 15 cp r22, r1
2699 efe: 71 05 cpc r23, r1
2700 f00: 09 f4 brne .+2 ; 0xf04 <f_write+0xe8>
2701 f02: c5 c0 rjmp .+394 ; 0x108e <f_write+0x272>
1234 kaklik 2702 if (clust == 1 || clust >= fs->max_clust) goto fw_error;
1296 kaklik 2703 f04: 61 30 cpi r22, 0x01 ; 1
2704 f06: 71 05 cpc r23, r1
2705 f08: 09 f4 brne .+2 ; 0xf0c <f_write+0xf0>
2706 f0a: d6 c0 rjmp .+428 ; 0x10b8 <f_write+0x29c>
2707 f0c: f5 01 movw r30, r10
2708 f0e: 86 89 ldd r24, Z+22 ; 0x16
2709 f10: 97 89 ldd r25, Z+23 ; 0x17
2710 f12: 68 17 cp r22, r24
2711 f14: 79 07 cpc r23, r25
2712 f16: 08 f0 brcs .+2 ; 0xf1a <f_write+0xfe>
2713 f18: cf c0 rjmp .+414 ; 0x10b8 <f_write+0x29c>
1234 kaklik 2714 fp->curr_clust = clust; /* Current cluster */
1296 kaklik 2715 f1a: 79 8b std Y+17, r23 ; 0x11
2716 f1c: 68 8b std Y+16, r22 ; 0x10
2717 static
2718 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
2719 CLUST clust /* Cluster# to be converted */
2720 )
2721 {
2722 FATFS *fs = FatFs;
2723 f1e: 00 91 10 01 lds r16, 0x0110
2724 f22: 10 91 11 01 lds r17, 0x0111
2725  
2726  
2727 clust -= 2;
2728 f26: 62 50 subi r22, 0x02 ; 2
2729 f28: 70 40 sbci r23, 0x00 ; 0
2730 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
2731 f2a: f8 01 movw r30, r16
2732 f2c: 86 89 ldd r24, Z+22 ; 0x16
2733 f2e: 97 89 ldd r25, Z+23 ; 0x17
2734 f30: 02 97 sbiw r24, 0x02 ; 2
2735 f32: 68 17 cp r22, r24
2736 f34: 79 07 cpc r23, r25
2737 f36: 28 f0 brcs .+10 ; 0xf42 <f_write+0x126>
2738 f38: 20 e0 ldi r18, 0x00 ; 0
2739 f3a: 30 e0 ldi r19, 0x00 ; 0
2740 f3c: 40 e0 ldi r20, 0x00 ; 0
2741 f3e: 50 e0 ldi r21, 0x00 ; 0
2742 f40: 14 c0 rjmp .+40 ; 0xf6a <f_write+0x14e>
2743 return (DWORD)clust * fs->sects_clust + fs->database;
2744 f42: 80 e0 ldi r24, 0x00 ; 0
2745 f44: 90 e0 ldi r25, 0x00 ; 0
2746 f46: f8 01 movw r30, r16
2747 f48: 25 8d ldd r18, Z+29 ; 0x1d
2748 f4a: 30 e0 ldi r19, 0x00 ; 0
2749 f4c: 40 e0 ldi r20, 0x00 ; 0
2750 f4e: 50 e0 ldi r21, 0x00 ; 0
2751 f50: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
2752 f54: 9b 01 movw r18, r22
2753 f56: ac 01 movw r20, r24
2754 f58: f8 01 movw r30, r16
2755 f5a: 80 89 ldd r24, Z+16 ; 0x10
2756 f5c: 91 89 ldd r25, Z+17 ; 0x11
2757 f5e: a2 89 ldd r26, Z+18 ; 0x12
2758 f60: b3 89 ldd r27, Z+19 ; 0x13
2759 f62: 28 0f add r18, r24
2760 f64: 39 1f adc r19, r25
2761 f66: 4a 1f adc r20, r26
2762 f68: 5b 1f adc r21, r27
2763 }
2764 if (clust == 0) break; /* Disk full */
2765 if (clust == 1 || clust >= fs->max_clust) goto fw_error;
2766 fp->curr_clust = clust; /* Current cluster */
1234 kaklik 2767 sect = clust2sect(clust); /* Get current sector */
2768 fp->sect_clust = fs->sects_clust; /* Re-initialize the left sector counter */
1296 kaklik 2769 f6a: f5 01 movw r30, r10
2770 f6c: 85 8d ldd r24, Z+29 ; 0x1d
2771 f6e: 8b 83 std Y+3, r24 ; 0x03
1234 kaklik 2772 }
2773 fp->curr_sect = sect; /* Update current sector */
1296 kaklik 2774 f70: 2a 8b std Y+18, r18 ; 0x12
2775 f72: 3b 8b std Y+19, r19 ; 0x13
2776 f74: 4c 8b std Y+20, r20 ; 0x14
2777 f76: 5d 8b std Y+21, r21 ; 0x15
1234 kaklik 2778 cc = btw / 512; /* When left bytes >= 512, */
1296 kaklik 2779 f78: 0f 2d mov r16, r15
2780 f7a: 06 95 lsr r16
1234 kaklik 2781 if (cc) { /* Write maximum contiguous sectors directly */
1296 kaklik 2782 f7c: 61 f1 breq .+88 ; 0xfd6 <f_write+0x1ba>
2783 f7e: 6b 81 ldd r22, Y+3 ; 0x03
2784 f80: 10 2f mov r17, r16
2785 f82: 60 17 cp r22, r16
2786 f84: 08 f4 brcc .+2 ; 0xf88 <f_write+0x16c>
2787 f86: 16 2f mov r17, r22
1234 kaklik 2788 if (cc > fp->sect_clust) cc = fp->sect_clust;
2789 if (disk_write(0, wbuff, sect, cc) != RES_OK)
1296 kaklik 2790 f88: 01 2f mov r16, r17
2791 f8a: b6 01 movw r22, r12
2792 f8c: 80 e0 ldi r24, 0x00 ; 0
2793 f8e: 0e 94 fb 0f call 0x1ff6 ; 0x1ff6 <disk_write>
2794 f92: 89 2b or r24, r25
2795 f94: 09 f0 breq .+2 ; 0xf98 <f_write+0x17c>
2796 f96: 90 c0 rjmp .+288 ; 0x10b8 <f_write+0x29c>
1234 kaklik 2797 goto fw_error;
2798 fp->sect_clust -= cc - 1;
1296 kaklik 2799 f98: 8b 81 ldd r24, Y+3 ; 0x03
2800 f9a: 8f 5f subi r24, 0xFF ; 255
2801 f9c: 81 1b sub r24, r17
2802 f9e: 8b 83 std Y+3, r24 ; 0x03
1234 kaklik 2803 fp->curr_sect += cc - 1;
1296 kaklik 2804 fa0: 81 2f mov r24, r17
2805 fa2: 90 e0 ldi r25, 0x00 ; 0
2806 fa4: 01 97 sbiw r24, 0x01 ; 1
2807 fa6: 9c 01 movw r18, r24
2808 fa8: 44 27 eor r20, r20
2809 faa: 37 fd sbrc r19, 7
2810 fac: 40 95 com r20
2811 fae: 54 2f mov r21, r20
2812 fb0: 8c 01 movw r16, r24
2813 fb2: 0f 5f subi r16, 0xFF ; 255
2814 fb4: 1f 4f sbci r17, 0xFF ; 255
2815 fb6: 8a 89 ldd r24, Y+18 ; 0x12
2816 fb8: 9b 89 ldd r25, Y+19 ; 0x13
2817 fba: ac 89 ldd r26, Y+20 ; 0x14
2818 fbc: bd 89 ldd r27, Y+21 ; 0x15
2819 fbe: 82 0f add r24, r18
2820 fc0: 93 1f adc r25, r19
2821 fc2: a4 1f adc r26, r20
2822 fc4: b5 1f adc r27, r21
2823 fc6: 8a 8b std Y+18, r24 ; 0x12
2824 fc8: 9b 8b std Y+19, r25 ; 0x13
2825 fca: ac 8b std Y+20, r26 ; 0x14
2826 fcc: bd 8b std Y+21, r27 ; 0x15
1234 kaklik 2827 wcnt = cc * 512; continue;
1296 kaklik 2828 fce: 10 2f mov r17, r16
2829 fd0: 00 27 eor r16, r16
2830 fd2: 11 0f add r17, r17
2831 fd4: 3e c0 rjmp .+124 ; 0x1052 <f_write+0x236>
1234 kaklik 2832 }
2833 if (fp->fptr >= fp->fsize) { /* Flush R/W window if needed */
1296 kaklik 2834 fd6: 2e 81 ldd r18, Y+6 ; 0x06
2835 fd8: 3f 81 ldd r19, Y+7 ; 0x07
2836 fda: 48 85 ldd r20, Y+8 ; 0x08
2837 fdc: 59 85 ldd r21, Y+9 ; 0x09
2838 fde: 8a 85 ldd r24, Y+10 ; 0x0a
2839 fe0: 9b 85 ldd r25, Y+11 ; 0x0b
2840 fe2: ac 85 ldd r26, Y+12 ; 0x0c
2841 fe4: bd 85 ldd r27, Y+13 ; 0x0d
2842 fe6: 28 17 cp r18, r24
2843 fe8: 39 07 cpc r19, r25
2844 fea: 4a 07 cpc r20, r26
2845 fec: 5b 07 cpc r21, r27
2846 fee: 90 f0 brcs .+36 ; 0x1014 <f_write+0x1f8>
1234 kaklik 2847 if (!move_window(0)) goto fw_error;
1296 kaklik 2848 ff0: 60 e0 ldi r22, 0x00 ; 0
2849 ff2: 70 e0 ldi r23, 0x00 ; 0
2850 ff4: 80 e0 ldi r24, 0x00 ; 0
2851 ff6: 90 e0 ldi r25, 0x00 ; 0
2852 ff8: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
2853 ffc: 88 23 and r24, r24
2854 ffe: 09 f4 brne .+2 ; 0x1002 <f_write+0x1e6>
2855 1000: 5b c0 rjmp .+182 ; 0x10b8 <f_write+0x29c>
1234 kaklik 2856 fs->winsect = fp->curr_sect;
1296 kaklik 2857 1002: 8a 89 ldd r24, Y+18 ; 0x12
2858 1004: 9b 89 ldd r25, Y+19 ; 0x13
2859 1006: ac 89 ldd r26, Y+20 ; 0x14
2860 1008: bd 89 ldd r27, Y+21 ; 0x15
2861 100a: f5 01 movw r30, r10
2862 100c: 84 83 std Z+4, r24 ; 0x04
2863 100e: 95 83 std Z+5, r25 ; 0x05
2864 1010: a6 83 std Z+6, r26 ; 0x06
2865 1012: b7 83 std Z+7, r27 ; 0x07
1234 kaklik 2866 }
2867 }
2868 if (!move_window(fp->curr_sect)) /* Move sector window */
1296 kaklik 2869 1014: 6a 89 ldd r22, Y+18 ; 0x12
2870 1016: 7b 89 ldd r23, Y+19 ; 0x13
2871 1018: 8c 89 ldd r24, Y+20 ; 0x14
2872 101a: 9d 89 ldd r25, Y+21 ; 0x15
2873 101c: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
2874 1020: 88 23 and r24, r24
2875 1022: 09 f4 brne .+2 ; 0x1026 <f_write+0x20a>
2876 1024: 49 c0 rjmp .+146 ; 0x10b8 <f_write+0x29c>
1234 kaklik 2877 goto fw_error;
2878 wcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes bytes to sector window */
1296 kaklik 2879 1026: 2e 81 ldd r18, Y+6 ; 0x06
2880 1028: 3f 81 ldd r19, Y+7 ; 0x07
2881 102a: 31 70 andi r19, 0x01 ; 1
2882 102c: c2 01 movw r24, r4
2883 102e: 82 1b sub r24, r18
2884 1030: 93 0b sbc r25, r19
2885 1032: 87 01 movw r16, r14
2886 1034: 8e 15 cp r24, r14
2887 1036: 9f 05 cpc r25, r15
2888 1038: 08 f4 brcc .+2 ; 0x103c <f_write+0x220>
2889 103a: 8c 01 movw r16, r24
1234 kaklik 2890 if (wcnt > btw) wcnt = btw;
2891 memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
1296 kaklik 2892 103c: 20 5e subi r18, 0xE0 ; 224
2893 103e: 3f 4f sbci r19, 0xFF ; 255
2894 1040: 2a 0d add r18, r10
2895 1042: 3b 1d adc r19, r11
2896 1044: a8 01 movw r20, r16
2897 1046: b6 01 movw r22, r12
2898 1048: c9 01 movw r24, r18
2899 104a: 0e 94 a3 11 call 0x2346 ; 0x2346 <memcpy>
1234 kaklik 2900 fs->winflag = 1;
1296 kaklik 2901 104e: f5 01 movw r30, r10
2902 1050: 37 8e std Z+31, r3 ; 0x1f
1234 kaklik 2903 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
2904 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2905 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2906  
2907 for ( ; btw; /* Repeat until all data transferred */
2908 wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
1296 kaklik 2909 1052: c0 0e add r12, r16
2910 1054: d1 1e adc r13, r17
2911 1056: c8 01 movw r24, r16
2912 1058: a0 e0 ldi r26, 0x00 ; 0
2913 105a: b0 e0 ldi r27, 0x00 ; 0
2914 105c: 2e 81 ldd r18, Y+6 ; 0x06
2915 105e: 3f 81 ldd r19, Y+7 ; 0x07
2916 1060: 48 85 ldd r20, Y+8 ; 0x08
2917 1062: 59 85 ldd r21, Y+9 ; 0x09
2918 1064: 28 0f add r18, r24
2919 1066: 39 1f adc r19, r25
2920 1068: 4a 1f adc r20, r26
2921 106a: 5b 1f adc r21, r27
2922 106c: 2e 83 std Y+6, r18 ; 0x06
2923 106e: 3f 83 std Y+7, r19 ; 0x07
2924 1070: 48 87 std Y+8, r20 ; 0x08
2925 1072: 59 87 std Y+9, r21 ; 0x09
2926 1074: f3 01 movw r30, r6
2927 1076: 80 81 ld r24, Z
2928 1078: 91 81 ldd r25, Z+1 ; 0x01
2929 107a: 80 0f add r24, r16
2930 107c: 91 1f adc r25, r17
2931 107e: 91 83 std Z+1, r25 ; 0x01
2932 1080: 80 83 st Z, r24
2933 1082: e0 1a sub r14, r16
2934 1084: f1 0a sbc r15, r17
1234 kaklik 2935 if (res) return res;
2936 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
2937 if (!(fp->flag & FA_WRITE)) return FR_DENIED; /* Check access mode */
2938 if (fp->fsize + btw < fp->fsize) return FR_OK; /* File size cannot reach 4GB */
2939  
2940 for ( ; btw; /* Repeat until all data transferred */
1296 kaklik 2941 1086: e1 14 cp r14, r1
2942 1088: f1 04 cpc r15, r1
2943 108a: 09 f0 breq .+2 ; 0x108e <f_write+0x272>
2944 108c: 04 cf rjmp .-504 ; 0xe96 <f_write+0x7a>
1234 kaklik 2945 if (wcnt > btw) wcnt = btw;
2946 memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
2947 fs->winflag = 1;
2948 }
2949  
2950 if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */
1296 kaklik 2951 108e: 2e 81 ldd r18, Y+6 ; 0x06
2952 1090: 3f 81 ldd r19, Y+7 ; 0x07
2953 1092: 48 85 ldd r20, Y+8 ; 0x08
2954 1094: 59 85 ldd r21, Y+9 ; 0x09
2955 1096: 8a 85 ldd r24, Y+10 ; 0x0a
2956 1098: 9b 85 ldd r25, Y+11 ; 0x0b
2957 109a: ac 85 ldd r26, Y+12 ; 0x0c
2958 109c: bd 85 ldd r27, Y+13 ; 0x0d
2959 109e: 82 17 cp r24, r18
2960 10a0: 93 07 cpc r25, r19
2961 10a2: a4 07 cpc r26, r20
2962 10a4: b5 07 cpc r27, r21
2963 10a6: 20 f4 brcc .+8 ; 0x10b0 <f_write+0x294>
2964 10a8: 2a 87 std Y+10, r18 ; 0x0a
2965 10aa: 3b 87 std Y+11, r19 ; 0x0b
2966 10ac: 4c 87 std Y+12, r20 ; 0x0c
2967 10ae: 5d 87 std Y+13, r21 ; 0x0d
1234 kaklik 2968 fp->flag |= FA__WRITTEN; /* Set file changed flag */
1296 kaklik 2969 10b0: 8a 81 ldd r24, Y+2 ; 0x02
2970 10b2: 80 62 ori r24, 0x20 ; 32
2971 10b4: 8a 83 std Y+2, r24 ; 0x02
2972 10b6: 06 c0 rjmp .+12 ; 0x10c4 <f_write+0x2a8>
1234 kaklik 2973 return FR_OK;
2974  
2975 fw_error: /* Abort this function due to an unrecoverable error */
2976 fp->flag |= FA__ERROR;
1296 kaklik 2977 10b8: 8a 81 ldd r24, Y+2 ; 0x02
2978 10ba: 80 68 ori r24, 0x80 ; 128
2979 10bc: 8a 83 std Y+2, r24 ; 0x02
2980 10be: 88 e0 ldi r24, 0x08 ; 8
2981 10c0: 88 2e mov r8, r24
2982 10c2: 91 2c mov r9, r1
1234 kaklik 2983 return FR_RW_ERROR;
2984 }
1296 kaklik 2985 10c4: c4 01 movw r24, r8
2986 10c6: cd b7 in r28, 0x3d ; 61
2987 10c8: de b7 in r29, 0x3e ; 62
2988 10ca: e1 e1 ldi r30, 0x11 ; 17
2989 10cc: 0c 94 e4 14 jmp 0x29c8 ; 0x29c8 <__epilogue_restores__+0x2>
1234 kaklik 2990  
1296 kaklik 2991 000010d0 <f_read>:
1234 kaklik 2992 FIL *fp, /* Pointer to the file object */
2993 void *buff, /* Pointer to data buffer */
2994 WORD btr, /* Number of bytes to read */
2995 WORD *br /* Pointer to number of bytes read */
2996 )
2997 {
1296 kaklik 2998 10d0: a0 e0 ldi r26, 0x00 ; 0
2999 10d2: b0 e0 ldi r27, 0x00 ; 0
3000 10d4: ee e6 ldi r30, 0x6E ; 110
3001 10d6: f8 e0 ldi r31, 0x08 ; 8
3002 10d8: 0c 94 c9 14 jmp 0x2992 ; 0x2992 <__prologue_saves__+0x4>
3003 10dc: ec 01 movw r28, r24
3004 10de: 16 2f mov r17, r22
3005 10e0: 07 2f mov r16, r23
3006 10e2: 7a 01 movw r14, r20
3007 10e4: 39 01 movw r6, r18
1234 kaklik 3008 DWORD sect, remain;
3009 WORD rcnt;
3010 CLUST clust;
3011 BYTE cc, *rbuff = buff;
3012 FRESULT res;
3013 FATFS *fs = fp->fs;
1296 kaklik 3014 10e6: 8c 80 ldd r8, Y+4 ; 0x04
3015 10e8: 9d 80 ldd r9, Y+5 ; 0x05
1234 kaklik 3016  
3017  
3018 *br = 0;
1296 kaklik 3019 10ea: f9 01 movw r30, r18
3020 10ec: 11 82 std Z+1, r1 ; 0x01
3021 10ee: 10 82 st Z, r1
1234 kaklik 3022 res = validate(fs, fp->id); /* Check validity of the object */
1296 kaklik 3023 10f0: 68 81 ld r22, Y
3024 10f2: 79 81 ldd r23, Y+1 ; 0x01
3025 10f4: c4 01 movw r24, r8
3026 10f6: 0e 94 46 03 call 0x68c ; 0x68c <validate>
3027 10fa: 5c 01 movw r10, r24
1234 kaklik 3028 if (res) return res;
1296 kaklik 3029 10fc: 00 97 sbiw r24, 0x00 ; 0
3030 10fe: 09 f0 breq .+2 ; 0x1102 <f_read+0x32>
3031 1100: f8 c0 rjmp .+496 ; 0x12f2 <f_read+0x222>
1234 kaklik 3032 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
1296 kaklik 3033 1102: 8a 81 ldd r24, Y+2 ; 0x02
3034 1104: 87 fd sbrc r24, 7
3035 1106: f2 c0 rjmp .+484 ; 0x12ec <f_read+0x21c>
1234 kaklik 3036 if (!(fp->flag & FA_READ)) return FR_DENIED; /* Check access mode */
1296 kaklik 3037 1108: 80 fd sbrc r24, 0
3038 110a: 04 c0 rjmp .+8 ; 0x1114 <f_read+0x44>
3039 110c: 76 e0 ldi r23, 0x06 ; 6
3040 110e: a7 2e mov r10, r23
3041 1110: b1 2c mov r11, r1
3042 1112: ef c0 rjmp .+478 ; 0x12f2 <f_read+0x222>
1234 kaklik 3043 remain = fp->fsize - fp->fptr;
1296 kaklik 3044 1114: 2a 85 ldd r18, Y+10 ; 0x0a
3045 1116: 3b 85 ldd r19, Y+11 ; 0x0b
3046 1118: 4c 85 ldd r20, Y+12 ; 0x0c
3047 111a: 5d 85 ldd r21, Y+13 ; 0x0d
3048 111c: 8e 81 ldd r24, Y+6 ; 0x06
3049 111e: 9f 81 ldd r25, Y+7 ; 0x07
3050 1120: a8 85 ldd r26, Y+8 ; 0x08
3051 1122: b9 85 ldd r27, Y+9 ; 0x09
3052 1124: 28 1b sub r18, r24
3053 1126: 39 0b sbc r19, r25
3054 1128: 4a 0b sbc r20, r26
3055 112a: 5b 0b sbc r21, r27
1234 kaklik 3056 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
1296 kaklik 3057 112c: c7 01 movw r24, r14
3058 112e: a0 e0 ldi r26, 0x00 ; 0
3059 1130: b0 e0 ldi r27, 0x00 ; 0
3060 1132: 28 17 cp r18, r24
3061 1134: 39 07 cpc r19, r25
3062 1136: 4a 07 cpc r20, r26
3063 1138: 5b 07 cpc r21, r27
3064 113a: 08 f4 brcc .+2 ; 0x113e <f_read+0x6e>
3065 113c: 79 01 movw r14, r18
1234 kaklik 3066 )
3067 {
3068 DWORD sect, remain;
3069 WORD rcnt;
3070 CLUST clust;
3071 BYTE cc, *rbuff = buff;
1296 kaklik 3072 113e: 81 2f mov r24, r17
3073 1140: 90 2f mov r25, r16
3074 1142: 9c 01 movw r18, r24
3075 1144: 69 01 movw r12, r18
3076 fp->curr_sect += cc - 1;
3077 rcnt = cc * 512; continue;
1234 kaklik 3078 }
3079 }
3080 if (!move_window(fp->curr_sect)) goto fr_error; /* Move sector window */
3081 rcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes from sector window */
1296 kaklik 3082 1146: 41 2c mov r4, r1
3083 1148: 62 e0 ldi r22, 0x02 ; 2
3084 114a: 56 2e mov r5, r22
3085 114c: c7 c0 rjmp .+398 ; 0x12dc <f_read+0x20c>
1234 kaklik 3086 remain = fp->fsize - fp->fptr;
3087 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
3088  
3089 for ( ; btr; /* Repeat until all data transferred */
3090 rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
3091 if ((fp->fptr % 512) == 0) { /* On the sector boundary */
1296 kaklik 3092 114e: 2e 81 ldd r18, Y+6 ; 0x06
3093 1150: 3f 81 ldd r19, Y+7 ; 0x07
3094 1152: 48 85 ldd r20, Y+8 ; 0x08
3095 1154: 59 85 ldd r21, Y+9 ; 0x09
3096 1156: da 01 movw r26, r20
3097 1158: c9 01 movw r24, r18
3098 115a: 91 70 andi r25, 0x01 ; 1
3099 115c: a0 70 andi r26, 0x00 ; 0
3100 115e: b0 70 andi r27, 0x00 ; 0
3101 1160: 00 97 sbiw r24, 0x00 ; 0
3102 1162: a1 05 cpc r26, r1
3103 1164: b1 05 cpc r27, r1
3104 1166: 09 f0 breq .+2 ; 0x116a <f_read+0x9a>
3105 1168: 84 c0 rjmp .+264 ; 0x1272 <f_read+0x1a2>
1234 kaklik 3106 if (--fp->sect_clust) { /* Decrement left sector counter */
1296 kaklik 3107 116a: 8b 81 ldd r24, Y+3 ; 0x03
3108 116c: 81 50 subi r24, 0x01 ; 1
3109 116e: 8b 83 std Y+3, r24 ; 0x03
3110 1170: 88 23 and r24, r24
3111 1172: 49 f0 breq .+18 ; 0x1186 <f_read+0xb6>
1234 kaklik 3112 sect = fp->curr_sect + 1; /* Get current sector */
1296 kaklik 3113 1174: 2a 89 ldd r18, Y+18 ; 0x12
3114 1176: 3b 89 ldd r19, Y+19 ; 0x13
3115 1178: 4c 89 ldd r20, Y+20 ; 0x14
3116 117a: 5d 89 ldd r21, Y+21 ; 0x15
3117 117c: 2f 5f subi r18, 0xFF ; 255
3118 117e: 3f 4f sbci r19, 0xFF ; 255
3119 1180: 4f 4f sbci r20, 0xFF ; 255
3120 1182: 5f 4f sbci r21, 0xFF ; 255
3121 1184: 43 c0 rjmp .+134 ; 0x120c <f_read+0x13c>
1234 kaklik 3122 } else { /* On the cluster boundary, get next cluster */
3123 clust = (fp->fptr == 0) ?
1296 kaklik 3124 1186: 21 15 cp r18, r1
3125 1188: 31 05 cpc r19, r1
3126 118a: 41 05 cpc r20, r1
3127 118c: 51 05 cpc r21, r1
3128 118e: 19 f4 brne .+6 ; 0x1196 <f_read+0xc6>
3129 1190: 6e 85 ldd r22, Y+14 ; 0x0e
3130 1192: 7f 85 ldd r23, Y+15 ; 0x0f
3131 1194: 05 c0 rjmp .+10 ; 0x11a0 <f_read+0xd0>
3132 1196: 88 89 ldd r24, Y+16 ; 0x10
3133 1198: 99 89 ldd r25, Y+17 ; 0x11
3134 119a: 0e 94 53 04 call 0x8a6 ; 0x8a6 <get_cluster>
3135 119e: bc 01 movw r22, r24
1234 kaklik 3136 fp->org_clust : get_cluster(fp->curr_clust);
3137 if (clust < 2 || clust >= fs->max_clust)
1296 kaklik 3138 11a0: 62 30 cpi r22, 0x02 ; 2
3139 11a2: 71 05 cpc r23, r1
3140 11a4: 08 f4 brcc .+2 ; 0x11a8 <f_read+0xd8>
3141 11a6: 9f c0 rjmp .+318 ; 0x12e6 <f_read+0x216>
3142 11a8: f4 01 movw r30, r8
3143 11aa: 86 89 ldd r24, Z+22 ; 0x16
3144 11ac: 97 89 ldd r25, Z+23 ; 0x17
3145 11ae: 68 17 cp r22, r24
3146 11b0: 79 07 cpc r23, r25
3147 11b2: 08 f0 brcs .+2 ; 0x11b6 <f_read+0xe6>
3148 11b4: 98 c0 rjmp .+304 ; 0x12e6 <f_read+0x216>
1234 kaklik 3149 goto fr_error;
3150 fp->curr_clust = clust; /* Current cluster */
1296 kaklik 3151 11b6: 79 8b std Y+17, r23 ; 0x11
3152 11b8: 68 8b std Y+16, r22 ; 0x10
3153 static
3154 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
3155 CLUST clust /* Cluster# to be converted */
3156 )
3157 {
3158 FATFS *fs = FatFs;
3159 11ba: 00 91 10 01 lds r16, 0x0110
3160 11be: 10 91 11 01 lds r17, 0x0111
3161  
3162  
3163 clust -= 2;
3164 11c2: 62 50 subi r22, 0x02 ; 2
3165 11c4: 70 40 sbci r23, 0x00 ; 0
3166 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
3167 11c6: f8 01 movw r30, r16
3168 11c8: 86 89 ldd r24, Z+22 ; 0x16
3169 11ca: 97 89 ldd r25, Z+23 ; 0x17
3170 11cc: 02 97 sbiw r24, 0x02 ; 2
3171 11ce: 68 17 cp r22, r24
3172 11d0: 79 07 cpc r23, r25
3173 11d2: 28 f0 brcs .+10 ; 0x11de <f_read+0x10e>
3174 11d4: 20 e0 ldi r18, 0x00 ; 0
3175 11d6: 30 e0 ldi r19, 0x00 ; 0
3176 11d8: 40 e0 ldi r20, 0x00 ; 0
3177 11da: 50 e0 ldi r21, 0x00 ; 0
3178 11dc: 14 c0 rjmp .+40 ; 0x1206 <f_read+0x136>
3179 return (DWORD)clust * fs->sects_clust + fs->database;
3180 11de: 80 e0 ldi r24, 0x00 ; 0
3181 11e0: 90 e0 ldi r25, 0x00 ; 0
3182 11e2: f8 01 movw r30, r16
3183 11e4: 25 8d ldd r18, Z+29 ; 0x1d
3184 11e6: 30 e0 ldi r19, 0x00 ; 0
3185 11e8: 40 e0 ldi r20, 0x00 ; 0
3186 11ea: 50 e0 ldi r21, 0x00 ; 0
3187 11ec: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
3188 11f0: 9b 01 movw r18, r22
3189 11f2: ac 01 movw r20, r24
3190 11f4: f8 01 movw r30, r16
3191 11f6: 80 89 ldd r24, Z+16 ; 0x10
3192 11f8: 91 89 ldd r25, Z+17 ; 0x11
3193 11fa: a2 89 ldd r26, Z+18 ; 0x12
3194 11fc: b3 89 ldd r27, Z+19 ; 0x13
3195 11fe: 28 0f add r18, r24
3196 1200: 39 1f adc r19, r25
3197 1202: 4a 1f adc r20, r26
3198 1204: 5b 1f adc r21, r27
3199 fp->org_clust : get_cluster(fp->curr_clust);
3200 if (clust < 2 || clust >= fs->max_clust)
3201 goto fr_error;
3202 fp->curr_clust = clust; /* Current cluster */
1234 kaklik 3203 sect = clust2sect(clust); /* Get current sector */
3204 fp->sect_clust = fs->sects_clust; /* Re-initialize the left sector counter */
1296 kaklik 3205 1206: f4 01 movw r30, r8
3206 1208: 85 8d ldd r24, Z+29 ; 0x1d
3207 120a: 8b 83 std Y+3, r24 ; 0x03
1234 kaklik 3208 }
3209 fp->curr_sect = sect; /* Update current sector */
1296 kaklik 3210 120c: 2a 8b std Y+18, r18 ; 0x12
3211 120e: 3b 8b std Y+19, r19 ; 0x13
3212 1210: 4c 8b std Y+20, r20 ; 0x14
3213 1212: 5d 8b std Y+21, r21 ; 0x15
1234 kaklik 3214 cc = btr / 512; /* When left bytes >= 512, */
1296 kaklik 3215 1214: 0f 2d mov r16, r15
3216 1216: 06 95 lsr r16
1234 kaklik 3217 if (cc) { /* Read maximum contiguous sectors directly */
1296 kaklik 3218 1218: 61 f1 breq .+88 ; 0x1272 <f_read+0x1a2>
3219 121a: 6b 81 ldd r22, Y+3 ; 0x03
3220 121c: 10 2f mov r17, r16
3221 121e: 60 17 cp r22, r16
3222 1220: 08 f4 brcc .+2 ; 0x1224 <f_read+0x154>
3223 1222: 16 2f mov r17, r22
1234 kaklik 3224 if (cc > fp->sect_clust) cc = fp->sect_clust;
3225 if (disk_read(0, rbuff, sect, cc) != RES_OK)
1296 kaklik 3226 1224: 01 2f mov r16, r17
3227 1226: b6 01 movw r22, r12
3228 1228: 80 e0 ldi r24, 0x00 ; 0
3229 122a: 0e 94 9c 0f call 0x1f38 ; 0x1f38 <disk_read>
3230 122e: 89 2b or r24, r25
3231 1230: 09 f0 breq .+2 ; 0x1234 <f_read+0x164>
3232 1232: 59 c0 rjmp .+178 ; 0x12e6 <f_read+0x216>
1234 kaklik 3233 goto fr_error;
3234 fp->sect_clust -= cc - 1;
1296 kaklik 3235 1234: 8b 81 ldd r24, Y+3 ; 0x03
3236 1236: 8f 5f subi r24, 0xFF ; 255
3237 1238: 81 1b sub r24, r17
3238 123a: 8b 83 std Y+3, r24 ; 0x03
1234 kaklik 3239 fp->curr_sect += cc - 1;
1296 kaklik 3240 123c: 81 2f mov r24, r17
3241 123e: 90 e0 ldi r25, 0x00 ; 0
3242 1240: 01 97 sbiw r24, 0x01 ; 1
3243 1242: 9c 01 movw r18, r24
3244 1244: 44 27 eor r20, r20
3245 1246: 37 fd sbrc r19, 7
3246 1248: 40 95 com r20
3247 124a: 54 2f mov r21, r20
3248 124c: 8c 01 movw r16, r24
3249 124e: 0f 5f subi r16, 0xFF ; 255
3250 1250: 1f 4f sbci r17, 0xFF ; 255
3251 1252: 8a 89 ldd r24, Y+18 ; 0x12
3252 1254: 9b 89 ldd r25, Y+19 ; 0x13
3253 1256: ac 89 ldd r26, Y+20 ; 0x14
3254 1258: bd 89 ldd r27, Y+21 ; 0x15
3255 125a: 82 0f add r24, r18
3256 125c: 93 1f adc r25, r19
3257 125e: a4 1f adc r26, r20
3258 1260: b5 1f adc r27, r21
3259 1262: 8a 8b std Y+18, r24 ; 0x12
3260 1264: 9b 8b std Y+19, r25 ; 0x13
3261 1266: ac 8b std Y+20, r26 ; 0x14
3262 1268: bd 8b std Y+21, r27 ; 0x15
1234 kaklik 3263 rcnt = cc * 512; continue;
1296 kaklik 3264 126a: 10 2f mov r17, r16
3265 126c: 00 27 eor r16, r16
3266 126e: 11 0f add r17, r17
3267 1270: 1b c0 rjmp .+54 ; 0x12a8 <f_read+0x1d8>
1234 kaklik 3268 }
3269 }
3270 if (!move_window(fp->curr_sect)) goto fr_error; /* Move sector window */
1296 kaklik 3271 1272: 6a 89 ldd r22, Y+18 ; 0x12
3272 1274: 7b 89 ldd r23, Y+19 ; 0x13
3273 1276: 8c 89 ldd r24, Y+20 ; 0x14
3274 1278: 9d 89 ldd r25, Y+21 ; 0x15
3275 127a: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
3276 127e: 88 23 and r24, r24
3277 1280: 91 f1 breq .+100 ; 0x12e6 <f_read+0x216>
1234 kaklik 3278 rcnt = 512 - (WORD)(fp->fptr % 512); /* Copy fractional bytes from sector window */
1296 kaklik 3279 1282: 8e 81 ldd r24, Y+6 ; 0x06
3280 1284: 9f 81 ldd r25, Y+7 ; 0x07
3281 1286: 91 70 andi r25, 0x01 ; 1
3282 1288: 92 01 movw r18, r4
3283 128a: 28 1b sub r18, r24
3284 128c: 39 0b sbc r19, r25
3285 128e: 87 01 movw r16, r14
3286 1290: 2e 15 cp r18, r14
3287 1292: 3f 05 cpc r19, r15
3288 1294: 08 f4 brcc .+2 ; 0x1298 <f_read+0x1c8>
3289 1296: 89 01 movw r16, r18
1234 kaklik 3290 if (rcnt > btr) rcnt = btr;
3291 memcpy(rbuff, &fs->win[(WORD)fp->fptr % 512], rcnt);
1296 kaklik 3292 1298: 80 96 adiw r24, 0x20 ; 32
3293 129a: 88 0d add r24, r8
3294 129c: 99 1d adc r25, r9
3295 129e: a8 01 movw r20, r16
3296 12a0: bc 01 movw r22, r24
3297 12a2: c6 01 movw r24, r12
3298 12a4: 0e 94 a3 11 call 0x2346 ; 0x2346 <memcpy>
1234 kaklik 3299 if (!(fp->flag & FA_READ)) return FR_DENIED; /* Check access mode */
3300 remain = fp->fsize - fp->fptr;
3301 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
3302  
3303 for ( ; btr; /* Repeat until all data transferred */
3304 rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
1296 kaklik 3305 12a8: c0 0e add r12, r16
3306 12aa: d1 1e adc r13, r17
3307 12ac: c8 01 movw r24, r16
3308 12ae: a0 e0 ldi r26, 0x00 ; 0
3309 12b0: b0 e0 ldi r27, 0x00 ; 0
3310 12b2: 2e 81 ldd r18, Y+6 ; 0x06
3311 12b4: 3f 81 ldd r19, Y+7 ; 0x07
3312 12b6: 48 85 ldd r20, Y+8 ; 0x08
3313 12b8: 59 85 ldd r21, Y+9 ; 0x09
3314 12ba: 28 0f add r18, r24
3315 12bc: 39 1f adc r19, r25
3316 12be: 4a 1f adc r20, r26
3317 12c0: 5b 1f adc r21, r27
3318 12c2: 2e 83 std Y+6, r18 ; 0x06
3319 12c4: 3f 83 std Y+7, r19 ; 0x07
3320 12c6: 48 87 std Y+8, r20 ; 0x08
3321 12c8: 59 87 std Y+9, r21 ; 0x09
3322 12ca: f3 01 movw r30, r6
3323 12cc: 80 81 ld r24, Z
3324 12ce: 91 81 ldd r25, Z+1 ; 0x01
3325 12d0: 80 0f add r24, r16
3326 12d2: 91 1f adc r25, r17
3327 12d4: 91 83 std Z+1, r25 ; 0x01
3328 12d6: 80 83 st Z, r24
3329 12d8: e0 1a sub r14, r16
3330 12da: f1 0a sbc r15, r17
1234 kaklik 3331 if (fp->flag & FA__ERROR) return FR_RW_ERROR; /* Check error flag */
3332 if (!(fp->flag & FA_READ)) return FR_DENIED; /* Check access mode */
3333 remain = fp->fsize - fp->fptr;
3334 if (btr > remain) btr = (WORD)remain; /* Truncate read count by number of bytes left */
3335  
3336 for ( ; btr; /* Repeat until all data transferred */
1296 kaklik 3337 12dc: e1 14 cp r14, r1
3338 12de: f1 04 cpc r15, r1
3339 12e0: 09 f0 breq .+2 ; 0x12e4 <f_read+0x214>
3340 12e2: 35 cf rjmp .-406 ; 0x114e <f_read+0x7e>
3341 12e4: 06 c0 rjmp .+12 ; 0x12f2 <f_read+0x222>
1234 kaklik 3342 }
3343  
3344 return FR_OK;
3345  
3346 fr_error: /* Abort this function due to an unrecoverable error */
3347 fp->flag |= FA__ERROR;
1296 kaklik 3348 12e6: 8a 81 ldd r24, Y+2 ; 0x02
3349 12e8: 80 68 ori r24, 0x80 ; 128
3350 12ea: 8a 83 std Y+2, r24 ; 0x02
3351 12ec: 48 e0 ldi r20, 0x08 ; 8
3352 12ee: a4 2e mov r10, r20
3353 12f0: b1 2c mov r11, r1
1234 kaklik 3354 return FR_RW_ERROR;
3355 }
1296 kaklik 3356 12f2: c5 01 movw r24, r10
3357 12f4: cd b7 in r28, 0x3d ; 61
3358 12f6: de b7 in r29, 0x3e ; 62
3359 12f8: e0 e1 ldi r30, 0x10 ; 16
3360 12fa: 0c 94 e5 14 jmp 0x29ca ; 0x29ca <__epilogue_restores__+0x4>
1234 kaklik 3361  
1296 kaklik 3362 000012fe <f_mount>:
1234 kaklik 3363  
3364 FRESULT f_mount (
3365 BYTE drv, /* Logical drive number to be mounted/unmounted */
3366 FATFS *fs /* Pointer to new file system object (NULL for unmount)*/
3367 )
3368 {
1296 kaklik 3369 12fe: cf 93 push r28
3370 1300: df 93 push r29
3371 1302: fb 01 movw r30, r22
1234 kaklik 3372 FATFS *fsobj;
3373  
3374  
3375 if (drv) return FR_INVALID_DRIVE;
1296 kaklik 3376 1304: 88 23 and r24, r24
3377 1306: 19 f0 breq .+6 ; 0x130e <f_mount+0x10>
3378 1308: 25 e0 ldi r18, 0x05 ; 5
3379 130a: 30 e0 ldi r19, 0x00 ; 0
3380 130c: 1d c0 rjmp .+58 ; 0x1348 <f_mount+0x4a>
1234 kaklik 3381 fsobj = FatFs;
1296 kaklik 3382 130e: a0 91 10 01 lds r26, 0x0110
3383 1312: b0 91 11 01 lds r27, 0x0111
1234 kaklik 3384 FatFs = fs;
1296 kaklik 3385 1316: 70 93 11 01 sts 0x0111, r23
3386 131a: 60 93 10 01 sts 0x0110, r22
1234 kaklik 3387 if (fsobj) memset(fsobj, 0, sizeof(FATFS));
1296 kaklik 3388 131e: 10 97 sbiw r26, 0x00 ; 0
3389 1320: 41 f0 breq .+16 ; 0x1332 <f_mount+0x34>
3390 1322: 80 e2 ldi r24, 0x20 ; 32
3391 1324: 92 e0 ldi r25, 0x02 ; 2
3392 1326: ed 01 movw r28, r26
3393 1328: 9c 01 movw r18, r24
3394 132a: 19 92 st Y+, r1
3395 132c: 21 50 subi r18, 0x01 ; 1
3396 132e: 30 40 sbci r19, 0x00 ; 0
3397 1330: e1 f7 brne .-8 ; 0x132a <f_mount+0x2c>
1234 kaklik 3398 if (fs) memset(fs, 0, sizeof(FATFS));
1296 kaklik 3399 1332: 30 97 sbiw r30, 0x00 ; 0
3400 1334: 39 f0 breq .+14 ; 0x1344 <f_mount+0x46>
3401 1336: 80 e2 ldi r24, 0x20 ; 32
3402 1338: 92 e0 ldi r25, 0x02 ; 2
3403 133a: df 01 movw r26, r30
3404 133c: ec 01 movw r28, r24
3405 133e: 1d 92 st X+, r1
3406 1340: 21 97 sbiw r28, 0x01 ; 1
3407 1342: e9 f7 brne .-6 ; 0x133e <f_mount+0x40>
3408 1344: 20 e0 ldi r18, 0x00 ; 0
3409 1346: 30 e0 ldi r19, 0x00 ; 0
1234 kaklik 3410  
3411 return FR_OK;
3412 }
1296 kaklik 3413 1348: c9 01 movw r24, r18
3414 134a: df 91 pop r29
3415 134c: cf 91 pop r28
3416 134e: 08 95 ret
1234 kaklik 3417  
1296 kaklik 3418 00001350 <check_fs>:
1234 kaklik 3419  
3420 static
3421 BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record or error */
3422 DWORD sect /* Sector# to check if it is a FAT boot record or not */
3423 )
3424 {
1296 kaklik 3425 1350: 0f 93 push r16
3426 1352: cf 93 push r28
3427 1354: df 93 push r29
3428 1356: 9b 01 movw r18, r22
3429 1358: ac 01 movw r20, r24
1234 kaklik 3430 FATFS *fs = FatFs;
1296 kaklik 3431 135a: c0 91 10 01 lds r28, 0x0110
3432 135e: d0 91 11 01 lds r29, 0x0111
1234 kaklik 3433  
3434 if (disk_read(0, fs->win, sect, 1) != RES_OK) /* Load boot record */
1296 kaklik 3435 1362: be 01 movw r22, r28
3436 1364: 60 5e subi r22, 0xE0 ; 224
3437 1366: 7f 4f sbci r23, 0xFF ; 255
3438 1368: 01 e0 ldi r16, 0x01 ; 1
3439 136a: 80 e0 ldi r24, 0x00 ; 0
3440 136c: 0e 94 9c 0f call 0x1f38 ; 0x1f38 <disk_read>
3441 1370: 89 2b or r24, r25
3442 1372: c1 f4 brne .+48 ; 0x13a4 <check_fs+0x54>
1234 kaklik 3443 return 2;
3444 if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature */
1296 kaklik 3445 1374: c2 5e subi r28, 0xE2 ; 226
3446 1376: dd 4f sbci r29, 0xFD ; 253
3447 1378: 88 81 ld r24, Y
3448 137a: 99 81 ldd r25, Y+1 ; 0x01
3449 137c: ce 51 subi r28, 0x1E ; 30
3450 137e: d2 40 sbci r29, 0x02 ; 2
3451 1380: 85 55 subi r24, 0x55 ; 85
3452 1382: 9a 4a sbci r25, 0xAA ; 170
3453 1384: 79 f4 brne .+30 ; 0x13a4 <check_fs+0x54>
1234 kaklik 3454 return 2;
3455  
3456 if (!memcmp(&fs->win[BS_FilSysType], "FAT", 3)) /* Check FAT signature */
1296 kaklik 3457 1386: 43 e0 ldi r20, 0x03 ; 3
3458 1388: 50 e0 ldi r21, 0x00 ; 0
3459 138a: 67 e0 ldi r22, 0x07 ; 7
3460 138c: 71 e0 ldi r23, 0x01 ; 1
3461 138e: ce 01 movw r24, r28
3462 1390: 8a 5a subi r24, 0xAA ; 170
3463 1392: 9f 4f sbci r25, 0xFF ; 255
3464 1394: 0e 94 96 11 call 0x232c ; 0x232c <memcmp>
3465 1398: 9c 01 movw r18, r24
3466 139a: 80 e0 ldi r24, 0x00 ; 0
3467 139c: 23 2b or r18, r19
3468 139e: 19 f0 breq .+6 ; 0x13a6 <check_fs+0x56>
3469 13a0: 81 e0 ldi r24, 0x01 ; 1
3470 13a2: 01 c0 rjmp .+2 ; 0x13a6 <check_fs+0x56>
3471 13a4: 82 e0 ldi r24, 0x02 ; 2
3472 #if _FAT32
3473 if (!memcmp(&fs->win[BS_FilSysType32], "FAT32", 5) && !(fs->win[BPB_ExtFlags] & 0x80))
3474 return 0;
3475 #endif
3476 return 1;
3477 }
3478 13a6: df 91 pop r29
3479 13a8: cf 91 pop r28
3480 13aa: 0f 91 pop r16
3481 13ac: 08 95 ret
1234 kaklik 3482  
1296 kaklik 3483 000013ae <f_open>:
1234 kaklik 3484 FRESULT f_open (
3485 FIL *fp, /* Pointer to the blank file object */
3486 const char *path, /* Pointer to the file name */
3487 BYTE mode /* Access mode and file open mode flags */
3488 )
3489 {
1296 kaklik 3490 13ae: ad e1 ldi r26, 0x1D ; 29
3491 13b0: b0 e0 ldi r27, 0x00 ; 0
3492 13b2: ed ed ldi r30, 0xDD ; 221
3493 13b4: f9 e0 ldi r31, 0x09 ; 9
3494 13b6: 0c 94 c7 14 jmp 0x298e ; 0x298e <__prologue_saves__>
3495 13ba: 9d 8f std Y+29, r25 ; 0x1d
3496 13bc: 8c 8f std Y+28, r24 ; 0x1c
3497 13be: 3b 01 movw r6, r22
1234 kaklik 3498 FRESULT res;
3499 BYTE *dir;
3500 DIR dirobj;
3501 char fn[8+3+1];
3502 FATFS *fs = FatFs;
1296 kaklik 3503 13c0: 80 90 10 01 lds r8, 0x0110
3504 13c4: 90 90 11 01 lds r9, 0x0111
1234 kaklik 3505  
3506  
3507 fp->fs = NULL;
1296 kaklik 3508 13c8: fc 01 movw r30, r24
3509 13ca: 15 82 std Z+5, r1 ; 0x05
3510 13cc: 14 82 std Z+4, r1 ; 0x04
3511 13ce: 03 c0 rjmp .+6 ; 0x13d6 <f_open+0x28>
1234 kaklik 3512 const char *p = *path;
3513 FATFS *fs = FatFs;
3514  
3515  
3516  
3517 while (*p == ' ') p++; /* Strip leading spaces */
1296 kaklik 3518 13d0: 08 94 sec
3519 13d2: 61 1c adc r6, r1
3520 13d4: 71 1c adc r7, r1
3521 13d6: f3 01 movw r30, r6
3522 13d8: 80 81 ld r24, Z
3523 13da: 80 32 cpi r24, 0x20 ; 32
3524 13dc: c9 f3 breq .-14 ; 0x13d0 <f_open+0x22>
1234 kaklik 3525 if (*p == '/') p++; /* Strip heading slash */
1296 kaklik 3526 13de: 8f 32 cpi r24, 0x2F ; 47
3527 13e0: 19 f4 brne .+6 ; 0x13e8 <f_open+0x3a>
3528 13e2: 08 94 sec
3529 13e4: 61 1c adc r6, r1
3530 13e6: 71 1c adc r7, r1
1234 kaklik 3531 *path = p; /* Return pointer to the path name */
3532  
3533 /* Is the file system object registered? */
3534 if (!fs) return FR_NOT_ENABLED;
1296 kaklik 3535 13e8: 81 14 cp r8, r1
3536 13ea: 91 04 cpc r9, r1
3537 13ec: 09 f4 brne .+2 ; 0x13f0 <f_open+0x42>
3538 13ee: 17 c1 rjmp .+558 ; 0x161e <f_open+0x270>
3539 FATFS *fs = FatFs;
1234 kaklik 3540  
3541  
3542 fp->fs = NULL;
3543 #if !_FS_READONLY
3544 mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW);
1296 kaklik 3545 13f0: f4 2f mov r31, r20
3546 13f2: ff 71 andi r31, 0x1F ; 31
3547 13f4: fb 8f std Y+27, r31 ; 0x1b
1234 kaklik 3548 res = auto_mount(&path, (BYTE)(mode & (FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)));
1296 kaklik 3549 13f6: 14 2f mov r17, r20
3550 13f8: 1e 71 andi r17, 0x1E ; 30
1234 kaklik 3551  
3552 /* Is the file system object registered? */
3553 if (!fs) return FR_NOT_ENABLED;
3554  
3555 /* Chekck if the logical drive has been mounted or not */
3556 if (fs->fs_type) {
1296 kaklik 3557 13fa: f4 01 movw r30, r8
3558 13fc: 84 8d ldd r24, Z+28 ; 0x1c
3559 13fe: 88 23 and r24, r24
3560 1400: 59 f0 breq .+22 ; 0x1418 <f_open+0x6a>
1234 kaklik 3561 stat = disk_status(0);
1296 kaklik 3562 1402: 80 e0 ldi r24, 0x00 ; 0
3563 1404: 0e 94 95 0f call 0x1f2a ; 0x1f2a <disk_status>
1234 kaklik 3564 if (!(stat & STA_NOINIT)) { /* If the physical drive is kept initialized */
1296 kaklik 3565 1408: 80 fd sbrc r24, 0
3566 140a: 06 c0 rjmp .+12 ; 0x1418 <f_open+0x6a>
1234 kaklik 3567 #if !_FS_READONLY
3568 if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
1296 kaklik 3569 140c: 11 23 and r17, r17
3570 140e: 09 f4 brne .+2 ; 0x1412 <f_open+0x64>
3571 1410: ab c3 rjmp .+1878 ; 0x1b68 <f_open+0x7ba>
3572 1412: 82 fd sbrc r24, 2
3573 1414: 07 c1 rjmp .+526 ; 0x1624 <f_open+0x276>
3574 1416: a8 c3 rjmp .+1872 ; 0x1b68 <f_open+0x7ba>
1234 kaklik 3575 }
3576 }
3577  
3578 /* The logical drive has not been mounted, following code attempts to mount the logical drive */
3579  
3580 memset(fs, 0, sizeof(FATFS)); /* Clean-up the file system object */
1296 kaklik 3581 1418: 80 e2 ldi r24, 0x20 ; 32
3582 141a: 92 e0 ldi r25, 0x02 ; 2
3583 141c: f4 01 movw r30, r8
3584 141e: 9c 01 movw r18, r24
3585 1420: 11 92 st Z+, r1
3586 1422: 21 50 subi r18, 0x01 ; 1
3587 1424: 30 40 sbci r19, 0x00 ; 0
3588 1426: e1 f7 brne .-8 ; 0x1420 <f_open+0x72>
1234 kaklik 3589 stat = disk_initialize(0); /* Initialize low level disk I/O layer */
1296 kaklik 3590 1428: 80 e0 ldi r24, 0x00 ; 0
3591 142a: 0e 94 b8 0e call 0x1d70 ; 0x1d70 <disk_initialize>
1234 kaklik 3592 if (stat & STA_NOINIT) /* Check if the drive is ready */
1296 kaklik 3593 142e: 80 ff sbrs r24, 0
3594 1430: 03 c0 rjmp .+6 ; 0x1438 <f_open+0x8a>
3595 1432: 21 e0 ldi r18, 0x01 ; 1
3596 1434: 30 e0 ldi r19, 0x00 ; 0
3597 1436: 8b c3 rjmp .+1814 ; 0x1b4e <f_open+0x7a0>
1234 kaklik 3598 return FR_NOT_READY;
3599 #if !_FS_READONLY
3600 if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
1296 kaklik 3601 1438: 11 23 and r17, r17
3602 143a: 11 f0 breq .+4 ; 0x1440 <f_open+0x92>
3603 143c: 82 fd sbrc r24, 2
3604 143e: f2 c0 rjmp .+484 ; 0x1624 <f_open+0x276>
1234 kaklik 3605 return FR_WRITE_PROTECTED;
3606 #endif
3607  
3608 /* Search FAT partition on the drive */
3609 fmt = check_fs(bootsect = 0); /* Check sector 0 as an SFD format */
1296 kaklik 3610 1440: 60 e0 ldi r22, 0x00 ; 0
3611 1442: 70 e0 ldi r23, 0x00 ; 0
3612 1444: 80 e0 ldi r24, 0x00 ; 0
3613 1446: 90 e0 ldi r25, 0x00 ; 0
3614 1448: 0e 94 a8 09 call 0x1350 ; 0x1350 <check_fs>
1234 kaklik 3615 if (fmt == 1) { /* Not a FAT boot record, it may be patitioned */
1296 kaklik 3616 144c: 81 30 cpi r24, 0x01 ; 1
3617 144e: 21 f0 breq .+8 ; 0x1458 <f_open+0xaa>
3618 1450: ee 24 eor r14, r14
3619 1452: ff 24 eor r15, r15
3620 1454: 87 01 movw r16, r14
3621 1456: 1e c0 rjmp .+60 ; 0x1494 <f_open+0xe6>
1234 kaklik 3622 /* Check a partition listed in top of the partition table */
3623 if (fs->win[MBR_Table+4]) { /* Is the 1st partition existing? */
1296 kaklik 3624 1458: 82 ee ldi r24, 0xE2 ; 226
3625 145a: 91 e0 ldi r25, 0x01 ; 1
3626 145c: 88 0e add r8, r24
3627 145e: 99 1e adc r9, r25
3628 1460: f4 01 movw r30, r8
3629 1462: 80 81 ld r24, Z
3630 1464: 2e e1 ldi r18, 0x1E ; 30
3631 1466: 3e ef ldi r19, 0xFE ; 254
3632 1468: 82 0e add r8, r18
3633 146a: 93 1e adc r9, r19
3634 146c: 88 23 and r24, r24
3635 146e: 09 f4 brne .+2 ; 0x1472 <f_open+0xc4>
3636 1470: dc c0 rjmp .+440 ; 0x162a <f_open+0x27c>
1234 kaklik 3637 bootsect = LD_DWORD(&fs->win[MBR_Table+8]); /* Partition offset in LBA */
1296 kaklik 3638 1472: 86 ee ldi r24, 0xE6 ; 230
3639 1474: 91 e0 ldi r25, 0x01 ; 1
3640 1476: 88 0e add r8, r24
3641 1478: 99 1e adc r9, r25
3642 147a: f4 01 movw r30, r8
3643 147c: e0 80 ld r14, Z
3644 147e: f1 80 ldd r15, Z+1 ; 0x01
3645 1480: 02 81 ldd r16, Z+2 ; 0x02
3646 1482: 13 81 ldd r17, Z+3 ; 0x03
3647 1484: 2a e1 ldi r18, 0x1A ; 26
3648 1486: 3e ef ldi r19, 0xFE ; 254
3649 1488: 82 0e add r8, r18
3650 148a: 93 1e adc r9, r19
1234 kaklik 3651 fmt = check_fs(bootsect); /* Check the partition */
1296 kaklik 3652 148c: c8 01 movw r24, r16
3653 148e: b7 01 movw r22, r14
3654 1490: 0e 94 a8 09 call 0x1350 ; 0x1350 <check_fs>
1234 kaklik 3655 }
3656 }
3657 if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512) /* No valid FAT patition is found */
1296 kaklik 3658 1494: 88 23 and r24, r24
3659 1496: 09 f0 breq .+2 ; 0x149a <f_open+0xec>
3660 1498: c8 c0 rjmp .+400 ; 0x162a <f_open+0x27c>
3661 149a: f4 01 movw r30, r8
3662 149c: 83 a5 ldd r24, Z+43 ; 0x2b
3663 149e: 94 a5 ldd r25, Z+44 ; 0x2c
3664 14a0: 80 50 subi r24, 0x00 ; 0
3665 14a2: 92 40 sbci r25, 0x02 ; 2
3666 14a4: 09 f0 breq .+2 ; 0x14a8 <f_open+0xfa>
3667 14a6: c1 c0 rjmp .+386 ; 0x162a <f_open+0x27c>
1234 kaklik 3668 return FR_NO_FILESYSTEM;
3669  
3670 /* Initialize the file system object */
3671 fatsize = LD_WORD(&fs->win[BPB_FATSz16]); /* Number of sectors per FAT */
1296 kaklik 3672 14a8: f4 01 movw r30, r8
3673 14aa: 86 a9 ldd r24, Z+54 ; 0x36
3674 14ac: 97 a9 ldd r25, Z+55 ; 0x37
3675 14ae: bc 01 movw r22, r24
3676 14b0: 80 e0 ldi r24, 0x00 ; 0
3677 14b2: 90 e0 ldi r25, 0x00 ; 0
1234 kaklik 3678 if (!fatsize) fatsize = LD_DWORD(&fs->win[BPB_FATSz32]);
1296 kaklik 3679 14b4: 61 15 cp r22, r1
3680 14b6: 71 05 cpc r23, r1
3681 14b8: 81 05 cpc r24, r1
3682 14ba: 91 05 cpc r25, r1
3683 14bc: 69 f4 brne .+26 ; 0x14d8 <f_open+0x12a>
3684 14be: 24 e4 ldi r18, 0x44 ; 68
3685 14c0: 30 e0 ldi r19, 0x00 ; 0
3686 14c2: 82 0e add r8, r18
3687 14c4: 93 1e adc r9, r19
3688 14c6: f4 01 movw r30, r8
3689 14c8: 60 81 ld r22, Z
3690 14ca: 71 81 ldd r23, Z+1 ; 0x01
3691 14cc: 82 81 ldd r24, Z+2 ; 0x02
3692 14ce: 93 81 ldd r25, Z+3 ; 0x03
3693 14d0: 2c eb ldi r18, 0xBC ; 188
3694 14d2: 3f ef ldi r19, 0xFF ; 255
3695 14d4: 82 0e add r8, r18
3696 14d6: 93 1e adc r9, r19
1234 kaklik 3697 fs->sects_fat = (CLUST)fatsize;
1296 kaklik 3698 14d8: f4 01 movw r30, r8
3699 14da: 75 8b std Z+21, r23 ; 0x15
3700 14dc: 64 8b std Z+20, r22 ; 0x14
1234 kaklik 3701 fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */
1296 kaklik 3702 14de: 20 a9 ldd r18, Z+48 ; 0x30
3703 14e0: 26 8f std Z+30, r18 ; 0x1e
1234 kaklik 3704 fatsize *= fs->n_fats; /* (Number of sectors in FAT area) */
1296 kaklik 3705 14e2: 30 e0 ldi r19, 0x00 ; 0
3706 14e4: 40 e0 ldi r20, 0x00 ; 0
3707 14e6: 50 e0 ldi r21, 0x00 ; 0
3708 14e8: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
3709 14ec: 5b 01 movw r10, r22
3710 14ee: 6c 01 movw r12, r24
1234 kaklik 3711 fs->fatbase = bootsect + LD_WORD(&fs->win[BPB_RsvdSecCnt]); /* FAT start sector (lba) */
1296 kaklik 3712 14f0: f4 01 movw r30, r8
3713 14f2: 86 a5 ldd r24, Z+46 ; 0x2e
3714 14f4: 97 a5 ldd r25, Z+47 ; 0x2f
3715 14f6: a0 e0 ldi r26, 0x00 ; 0
3716 14f8: b0 e0 ldi r27, 0x00 ; 0
3717 14fa: e8 0e add r14, r24
3718 14fc: f9 1e adc r15, r25
3719 14fe: 0a 1f adc r16, r26
3720 1500: 1b 1f adc r17, r27
3721 1502: e0 86 std Z+8, r14 ; 0x08
3722 1504: f1 86 std Z+9, r15 ; 0x09
3723 1506: 02 87 std Z+10, r16 ; 0x0a
3724 1508: 13 87 std Z+11, r17 ; 0x0b
1234 kaklik 3725 fs->sects_clust = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */
1296 kaklik 3726 150a: 85 a5 ldd r24, Z+45 ; 0x2d
3727 150c: 85 8f std Z+29, r24 ; 0x1d
1234 kaklik 3728 fs->n_rootdir = LD_WORD(&fs->win[BPB_RootEntCnt]); /* Nmuber of root directory entries */
1296 kaklik 3729 150e: 21 a9 ldd r18, Z+49 ; 0x31
3730 1510: 32 a9 ldd r19, Z+50 ; 0x32
3731 1512: 33 83 std Z+3, r19 ; 0x03
3732 1514: 22 83 std Z+2, r18 ; 0x02
1234 kaklik 3733 totalsect = LD_WORD(&fs->win[BPB_TotSec16]); /* Number of sectors on the file system */
1296 kaklik 3734 1516: 83 a9 ldd r24, Z+51 ; 0x33
3735 1518: 94 a9 ldd r25, Z+52 ; 0x34
3736 151a: 7c 01 movw r14, r24
3737 151c: 00 e0 ldi r16, 0x00 ; 0
3738 151e: 10 e0 ldi r17, 0x00 ; 0
1234 kaklik 3739 if (!totalsect) totalsect = LD_DWORD(&fs->win[BPB_TotSec32]);
1296 kaklik 3740 1520: e1 14 cp r14, r1
3741 1522: f1 04 cpc r15, r1
3742 1524: 01 05 cpc r16, r1
3743 1526: 11 05 cpc r17, r1
3744 1528: 69 f4 brne .+26 ; 0x1544 <f_open+0x196>
3745 152a: 80 e4 ldi r24, 0x40 ; 64
3746 152c: 90 e0 ldi r25, 0x00 ; 0
3747 152e: 88 0e add r8, r24
3748 1530: 99 1e adc r9, r25
3749 1532: f4 01 movw r30, r8
3750 1534: e0 80 ld r14, Z
3751 1536: f1 80 ldd r15, Z+1 ; 0x01
3752 1538: 02 81 ldd r16, Z+2 ; 0x02
3753 153a: 13 81 ldd r17, Z+3 ; 0x03
3754 153c: 80 ec ldi r24, 0xC0 ; 192
3755 153e: 9f ef ldi r25, 0xFF ; 255
3756 1540: 88 0e add r8, r24
3757 1542: 99 1e adc r9, r25
1234 kaklik 3758 fs->max_clust = maxclust = (totalsect /* Last cluster# + 1 */
1296 kaklik 3759 1544: f4 01 movw r30, r8
3760 1546: 86 a5 ldd r24, Z+46 ; 0x2e
3761 1548: 97 a5 ldd r25, Z+47 ; 0x2f
3762 154a: a0 e0 ldi r26, 0x00 ; 0
3763 154c: b0 e0 ldi r27, 0x00 ; 0
3764 154e: e8 1a sub r14, r24
3765 1550: f9 0a sbc r15, r25
3766 1552: 0a 0b sbc r16, r26
3767 1554: 1b 0b sbc r17, r27
3768 1556: ea 18 sub r14, r10
3769 1558: fb 08 sbc r15, r11
3770 155a: 0c 09 sbc r16, r12
3771 155c: 1d 09 sbc r17, r13
3772 155e: a4 e0 ldi r26, 0x04 ; 4
3773 1560: 36 95 lsr r19
3774 1562: 27 95 ror r18
3775 1564: aa 95 dec r26
3776 1566: e1 f7 brne .-8 ; 0x1560 <f_open+0x1b2>
3777 1568: c9 01 movw r24, r18
3778 156a: a0 e0 ldi r26, 0x00 ; 0
3779 156c: b0 e0 ldi r27, 0x00 ; 0
3780 156e: e8 1a sub r14, r24
3781 1570: f9 0a sbc r15, r25
3782 1572: 0a 0b sbc r16, r26
3783 1574: 1b 0b sbc r17, r27
3784 1576: 25 8d ldd r18, Z+29 ; 0x1d
3785 1578: 30 e0 ldi r19, 0x00 ; 0
3786 157a: 40 e0 ldi r20, 0x00 ; 0
3787 157c: 50 e0 ldi r21, 0x00 ; 0
3788 157e: c8 01 movw r24, r16
3789 1580: b7 01 movw r22, r14
3790 1582: 0e 94 a5 14 call 0x294a ; 0x294a <__udivmodsi4>
3791 1586: 2e 5f subi r18, 0xFE ; 254
3792 1588: 3f 4f sbci r19, 0xFF ; 255
3793 158a: 4f 4f sbci r20, 0xFF ; 255
3794 158c: 5f 4f sbci r21, 0xFF ; 255
3795 158e: f4 01 movw r30, r8
3796 1590: 37 8b std Z+23, r19 ; 0x17
3797 1592: 26 8b std Z+22, r18 ; 0x16
1234 kaklik 3798 - LD_WORD(&fs->win[BPB_RsvdSecCnt]) - fatsize - fs->n_rootdir / 16
3799 ) / fs->sects_clust + 2;
3800  
3801 fmt = FS_FAT12; /* Determine the FAT sub type */
3802 if (maxclust > 0xFF7) fmt = FS_FAT16;
1296 kaklik 3803 1594: 28 3f cpi r18, 0xF8 ; 248
3804 1596: ff e0 ldi r31, 0x0F ; 15
3805 1598: 3f 07 cpc r19, r31
3806 159a: f0 e0 ldi r31, 0x00 ; 0
3807 159c: 4f 07 cpc r20, r31
3808 159e: f0 e0 ldi r31, 0x00 ; 0
3809 15a0: 5f 07 cpc r21, r31
3810 15a2: 10 f4 brcc .+4 ; 0x15a8 <f_open+0x1fa>
3811 15a4: 61 e0 ldi r22, 0x01 ; 1
3812 15a6: 06 c0 rjmp .+12 ; 0x15b4 <f_open+0x206>
1234 kaklik 3813 if (maxclust > 0xFFF7)
1296 kaklik 3814 15a8: 28 5f subi r18, 0xF8 ; 248
3815 15aa: 3f 4f sbci r19, 0xFF ; 255
3816 15ac: 40 40 sbci r20, 0x00 ; 0
3817 15ae: 50 40 sbci r21, 0x00 ; 0
3818 15b0: e0 f5 brcc .+120 ; 0x162a <f_open+0x27c>
3819 15b2: 62 e0 ldi r22, 0x02 ; 2
1234 kaklik 3820 fmt = FS_FAT32;
3821 if (fmt == FS_FAT32)
3822 fs->dirbase = LD_DWORD(&fs->win[BPB_RootClus]); /* Root directory start cluster */
3823 else
3824 #endif
3825 fs->dirbase = fs->fatbase + fatsize; /* Root directory start sector (lba) */
1296 kaklik 3826 15b4: f4 01 movw r30, r8
3827 15b6: 20 85 ldd r18, Z+8 ; 0x08
3828 15b8: 31 85 ldd r19, Z+9 ; 0x09
3829 15ba: 42 85 ldd r20, Z+10 ; 0x0a
3830 15bc: 53 85 ldd r21, Z+11 ; 0x0b
3831 15be: d6 01 movw r26, r12
3832 15c0: c5 01 movw r24, r10
3833 15c2: 82 0f add r24, r18
3834 15c4: 93 1f adc r25, r19
3835 15c6: a4 1f adc r26, r20
3836 15c8: b5 1f adc r27, r21
3837 15ca: 84 87 std Z+12, r24 ; 0x0c
3838 15cc: 95 87 std Z+13, r25 ; 0x0d
3839 15ce: a6 87 std Z+14, r26 ; 0x0e
3840 15d0: b7 87 std Z+15, r27 ; 0x0f
1234 kaklik 3841 fs->database = fs->fatbase + fatsize + fs->n_rootdir / 16; /* Data start sector (lba) */
1296 kaklik 3842 15d2: 82 81 ldd r24, Z+2 ; 0x02
3843 15d4: 93 81 ldd r25, Z+3 ; 0x03
3844 15d6: 74 e0 ldi r23, 0x04 ; 4
3845 15d8: 96 95 lsr r25
3846 15da: 87 95 ror r24
3847 15dc: 7a 95 dec r23
3848 15de: e1 f7 brne .-8 ; 0x15d8 <f_open+0x22a>
3849 15e0: a0 e0 ldi r26, 0x00 ; 0
3850 15e2: b0 e0 ldi r27, 0x00 ; 0
3851 15e4: 82 0f add r24, r18
3852 15e6: 93 1f adc r25, r19
3853 15e8: a4 1f adc r26, r20
3854 15ea: b5 1f adc r27, r21
3855 15ec: 8a 0d add r24, r10
3856 15ee: 9b 1d adc r25, r11
3857 15f0: ac 1d adc r26, r12
3858 15f2: bd 1d adc r27, r13
3859 15f4: 80 8b std Z+16, r24 ; 0x10
3860 15f6: 91 8b std Z+17, r25 ; 0x11
3861 15f8: a2 8b std Z+18, r26 ; 0x12
3862 15fa: b3 8b std Z+19, r27 ; 0x13
1234 kaklik 3863 fs->fs_type = fmt; /* FAT sub-type */
1296 kaklik 3864 15fc: 64 8f std Z+28, r22 ; 0x1c
1234 kaklik 3865  
3866 #if !_FS_READONLY
3867 fs->free_clust = (CLUST)0xFFFFFFFF;
1296 kaklik 3868 15fe: 8f ef ldi r24, 0xFF ; 255
3869 1600: 9f ef ldi r25, 0xFF ; 255
3870 1602: 93 8f std Z+27, r25 ; 0x1b
3871 1604: 82 8f std Z+26, r24 ; 0x1a
1234 kaklik 3872 fs->free_clust = LD_DWORD(&fs->win[FSI_Free_Count]);
3873 }
3874 }
3875 #endif
3876 #endif
3877 fs->id = ++fsid; /* File system mount ID */
1296 kaklik 3878 1606: 80 91 12 01 lds r24, 0x0112
3879 160a: 90 91 13 01 lds r25, 0x0113
3880 160e: 01 96 adiw r24, 0x01 ; 1
3881 1610: 90 93 13 01 sts 0x0113, r25
3882 1614: 80 93 12 01 sts 0x0112, r24
3883 1618: 91 83 std Z+1, r25 ; 0x01
3884 161a: 80 83 st Z, r24
3885 161c: a5 c2 rjmp .+1354 ; 0x1b68 <f_open+0x7ba>
3886 161e: 2a e0 ldi r18, 0x0A ; 10
3887 1620: 30 e0 ldi r19, 0x00 ; 0
3888 1622: 95 c2 rjmp .+1322 ; 0x1b4e <f_open+0x7a0>
3889 1624: 29 e0 ldi r18, 0x09 ; 9
3890 1626: 30 e0 ldi r19, 0x00 ; 0
3891 1628: 92 c2 rjmp .+1316 ; 0x1b4e <f_open+0x7a0>
3892 162a: 2b e0 ldi r18, 0x0B ; 11
3893 162c: 30 e0 ldi r19, 0x00 ; 0
3894 162e: 8f c2 rjmp .+1310 ; 0x1b4e <f_open+0x7a0>
1234 kaklik 3895 )
3896 {
3897 BYTE n, t, c, a, b;
3898  
3899  
3900 memset(dirname, ' ', 8+3); /* Fill buffer with spaces */
1296 kaklik 3901 1630: 2e 01 movw r4, r28
3902 1632: 08 94 sec
3903 1634: 41 1c adc r4, r1
3904 1636: 51 1c adc r5, r1
3905 ((DWORD)LD_WORD(&dptr[DIR_FstClusHI]) << 16) |
3906 #endif
3907 LD_WORD(&dptr[DIR_FstClusLO]);
3908 dirobj->clust = dirobj->sclust = clust; /* Restart scannig with the new directory */
3909 dirobj->sect = clust2sect(clust);
3910 dirobj->index = 2;
3911 1638: 92 e0 ldi r25, 0x02 ; 2
3912 163a: 29 2e mov r2, r25
3913 163c: 31 2c mov r3, r1
1234 kaklik 3914 )
3915 {
3916 BYTE n, t, c, a, b;
3917  
3918  
3919 memset(dirname, ' ', 8+3); /* Fill buffer with spaces */
1296 kaklik 3920 163e: 4b e0 ldi r20, 0x0B ; 11
3921 1640: 50 e0 ldi r21, 0x00 ; 0
3922 1642: 60 e2 ldi r22, 0x20 ; 32
3923 1644: 70 e0 ldi r23, 0x00 ; 0
3924 1646: c2 01 movw r24, r4
3925 1648: 0e 94 ac 11 call 0x2358 ; 0x2358 <memset>
3926 164c: 20 e0 ldi r18, 0x00 ; 0
3927 164e: 48 e0 ldi r20, 0x08 ; 8
3928 1650: 90 e0 ldi r25, 0x00 ; 0
3929 1652: 38 e1 ldi r19, 0x18 ; 24
3930 1654: 02 c0 rjmp .+4 ; 0x165a <f_open+0x2ac>
3931 1656: 28 e0 ldi r18, 0x08 ; 8
3932 1658: 4b e0 ldi r20, 0x0B ; 11
1234 kaklik 3933 a = 0; b = 0x18; /* NT flag */
3934 n = 0; t = 8;
3935 for (;;) {
3936 c = *(*path)++;
1296 kaklik 3937 165a: f3 01 movw r30, r6
3938 165c: 11 91 ld r17, Z+
3939 165e: 3f 01 movw r6, r30
1234 kaklik 3940 if (c == '\0' || c == '/') { /* Reached to end of str or directory separator */
1296 kaklik 3941 1660: 11 23 and r17, r17
3942 1662: 11 f0 breq .+4 ; 0x1668 <f_open+0x2ba>
3943 1664: 1f 32 cpi r17, 0x2F ; 47
3944 1666: 49 f4 brne .+18 ; 0x167a <f_open+0x2cc>
1234 kaklik 3945 if (n == 0) break;
1296 kaklik 3946 1668: 22 23 and r18, r18
3947 166a: 09 f4 brne .+2 ; 0x166e <f_open+0x2c0>
3948 166c: c7 c0 rjmp .+398 ; 0x17fc <f_open+0x44e>
1234 kaklik 3949 dirname[11] = _USE_NTFLAG ? (a & b) : 0;
1296 kaklik 3950 166e: 39 23 and r19, r25
3951 1670: 3c 87 std Y+12, r19 ; 0x0c
3952 *dir = NULL; return FR_OK;
3953 }
1234 kaklik 3954  
3955 for (;;) {
1296 kaklik 3956 ds = make_dirfile(&path, fn); /* Get a paragraph into fn[] */
3957 if (ds == 1) return FR_INVALID_NAME;
3958 1672: 11 30 cpi r17, 0x01 ; 1
3959 1674: 09 f0 breq .+2 ; 0x1678 <f_open+0x2ca>
3960 1676: 44 c0 rjmp .+136 ; 0x1700 <f_open+0x352>
3961 1678: c1 c0 rjmp .+386 ; 0x17fc <f_open+0x44e>
1234 kaklik 3962 if (c == '\0' || c == '/') { /* Reached to end of str or directory separator */
3963 if (n == 0) break;
3964 dirname[11] = _USE_NTFLAG ? (a & b) : 0;
3965 return c;
3966 }
3967 if (c <= ' ' || c == 0x7F) break; /* Reject invisible chars */
1296 kaklik 3968 167a: 11 32 cpi r17, 0x21 ; 33
3969 167c: 08 f4 brcc .+2 ; 0x1680 <f_open+0x2d2>
3970 167e: be c0 rjmp .+380 ; 0x17fc <f_open+0x44e>
3971 1680: 1f 37 cpi r17, 0x7F ; 127
3972 1682: 09 f4 brne .+2 ; 0x1686 <f_open+0x2d8>
3973 1684: bb c0 rjmp .+374 ; 0x17fc <f_open+0x44e>
1234 kaklik 3974 if (c == '.') {
1296 kaklik 3975 1686: 1e 32 cpi r17, 0x2E ; 46
3976 1688: 41 f4 brne .+16 ; 0x169a <f_open+0x2ec>
1234 kaklik 3977 if (!(a & 1) && n >= 1 && n <= 8) { /* Enter extension part */
1296 kaklik 3978 168a: 90 fd sbrc r25, 0
3979 168c: b7 c0 rjmp .+366 ; 0x17fc <f_open+0x44e>
3980 168e: 22 23 and r18, r18
3981 1690: 09 f4 brne .+2 ; 0x1694 <f_open+0x2e6>
3982 1692: b4 c0 rjmp .+360 ; 0x17fc <f_open+0x44e>
3983 1694: 29 30 cpi r18, 0x09 ; 9
3984 1696: f8 f2 brcs .-66 ; 0x1656 <f_open+0x2a8>
3985 1698: b1 c0 rjmp .+354 ; 0x17fc <f_open+0x44e>
1234 kaklik 3986 (c >= 0xE0 && c <= 0xFC))) {
3987 if (n == 0 && c == 0xE5) /* Change heading \xE5 to \x05 */
3988 c = 0x05;
3989 a ^= 1; goto md_l2;
3990 }
3991 if (c == '"') break; /* Reject " */
1296 kaklik 3992 169a: 12 32 cpi r17, 0x22 ; 34
3993 169c: 09 f4 brne .+2 ; 0x16a0 <f_open+0x2f2>
3994 169e: ae c0 rjmp .+348 ; 0x17fc <f_open+0x44e>
1234 kaklik 3995 if (c <= ')') goto md_l1; /* Accept ! # $ % & ' ( ) */
1296 kaklik 3996 16a0: 1a 32 cpi r17, 0x2A ; 42
3997 16a2: 20 f1 brcs .+72 ; 0x16ec <f_open+0x33e>
1234 kaklik 3998 if (c <= ',') break; /* Reject * + , */
1296 kaklik 3999 16a4: 1d 32 cpi r17, 0x2D ; 45
4000 16a6: 08 f4 brcc .+2 ; 0x16aa <f_open+0x2fc>
4001 16a8: a9 c0 rjmp .+338 ; 0x17fc <f_open+0x44e>
1234 kaklik 4002 if (c <= '9') goto md_l1; /* Accept - 0-9 */
1296 kaklik 4003 16aa: 1a 33 cpi r17, 0x3A ; 58
4004 16ac: f8 f0 brcs .+62 ; 0x16ec <f_open+0x33e>
1234 kaklik 4005 if (c <= '?') break; /* Reject : ; < = > ? */
1296 kaklik 4006 16ae: 10 34 cpi r17, 0x40 ; 64
4007 16b0: 08 f4 brcc .+2 ; 0x16b4 <f_open+0x306>
4008 16b2: a4 c0 rjmp .+328 ; 0x17fc <f_open+0x44e>
1234 kaklik 4009 if (!(a & 1)) { /* These checks are not applied to S-JIS 2nd byte */
1296 kaklik 4010 16b4: 90 fd sbrc r25, 0
4011 16b6: 1a c0 rjmp .+52 ; 0x16ec <f_open+0x33e>
1234 kaklik 4012 if (c == '|') break; /* Reject | */
1296 kaklik 4013 16b8: 1c 37 cpi r17, 0x7C ; 124
4014 16ba: 09 f4 brne .+2 ; 0x16be <f_open+0x310>
4015 16bc: 9f c0 rjmp .+318 ; 0x17fc <f_open+0x44e>
1234 kaklik 4016 if (c >= '[' && c <= ']') break;/* Reject [ \ ] */
1296 kaklik 4017 16be: 81 2f mov r24, r17
4018 16c0: 8b 55 subi r24, 0x5B ; 91
4019 16c2: 83 30 cpi r24, 0x03 ; 3
4020 16c4: 08 f4 brcc .+2 ; 0x16c8 <f_open+0x31a>
4021 16c6: 9a c0 rjmp .+308 ; 0x17fc <f_open+0x44e>
1234 kaklik 4022 if (_USE_NTFLAG && c >= 'A' && c <= 'Z')
1296 kaklik 4023 16c8: 86 5e subi r24, 0xE6 ; 230
4024 16ca: 8a 31 cpi r24, 0x1A ; 26
4025 16cc: 28 f4 brcc .+10 ; 0x16d8 <f_open+0x32a>
1234 kaklik 4026 (t == 8) ? (b &= ~0x08) : (b &= ~0x10);
1296 kaklik 4027 16ce: 48 30 cpi r20, 0x08 ; 8
4028 16d0: 11 f4 brne .+4 ; 0x16d6 <f_open+0x328>
4029 16d2: 37 7f andi r19, 0xF7 ; 247
4030 16d4: 01 c0 rjmp .+2 ; 0x16d8 <f_open+0x32a>
4031 16d6: 3f 7e andi r19, 0xEF ; 239
1234 kaklik 4032 if (c >= 'a' && c <= 'z') { /* Convert to upper case */
1296 kaklik 4033 16d8: 81 2f mov r24, r17
4034 16da: 81 56 subi r24, 0x61 ; 97
4035 16dc: 8a 31 cpi r24, 0x1A ; 26
4036 16de: 30 f4 brcc .+12 ; 0x16ec <f_open+0x33e>
1234 kaklik 4037 c -= 0x20;
1296 kaklik 4038 16e0: 10 52 subi r17, 0x20 ; 32
1234 kaklik 4039 if (_USE_NTFLAG) (t == 8) ? (a |= 0x08) : (a |= 0x10);
1296 kaklik 4040 16e2: 48 30 cpi r20, 0x08 ; 8
4041 16e4: 11 f4 brne .+4 ; 0x16ea <f_open+0x33c>
4042 16e6: 98 60 ori r25, 0x08 ; 8
4043 16e8: 01 c0 rjmp .+2 ; 0x16ec <f_open+0x33e>
4044 16ea: 90 61 ori r25, 0x10 ; 16
1234 kaklik 4045 }
4046 }
4047 md_l1:
4048 a &= ~1;
4049 md_l2:
4050 if (n >= t) break;
1296 kaklik 4051 16ec: 24 17 cp r18, r20
4052 16ee: 08 f0 brcs .+2 ; 0x16f2 <f_open+0x344>
4053 16f0: 85 c0 rjmp .+266 ; 0x17fc <f_open+0x44e>
1234 kaklik 4054 c -= 0x20;
4055 if (_USE_NTFLAG) (t == 8) ? (a |= 0x08) : (a |= 0x10);
4056 }
4057 }
4058 md_l1:
4059 a &= ~1;
1296 kaklik 4060 16f2: 9e 7f andi r25, 0xFE ; 254
1234 kaklik 4061 md_l2:
4062 if (n >= t) break;
4063 dirname[n++] = c;
1296 kaklik 4064 16f4: f2 01 movw r30, r4
4065 16f6: e2 0f add r30, r18
4066 16f8: f1 1d adc r31, r1
4067 16fa: 10 83 st Z, r17
4068 16fc: 2f 5f subi r18, 0xFF ; 255
4069 16fe: ad cf rjmp .-166 ; 0x165a <f_open+0x2ac>
1234 kaklik 4070  
4071 for (;;) {
4072 ds = make_dirfile(&path, fn); /* Get a paragraph into fn[] */
4073 if (ds == 1) return FR_INVALID_NAME;
4074 for (;;) {
4075 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
1296 kaklik 4076 1700: 6f 89 ldd r22, Y+23 ; 0x17
4077 1702: 78 8d ldd r23, Y+24 ; 0x18
4078 1704: 89 8d ldd r24, Y+25 ; 0x19
4079 1706: 9a 8d ldd r25, Y+26 ; 0x1a
4080 1708: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
4081 170c: 88 23 and r24, r24
4082 170e: 31 f4 brne .+12 ; 0x171c <f_open+0x36e>
4083 1710: 90 e0 ldi r25, 0x00 ; 0
4084 1712: 9c 01 movw r18, r24
4085 1714: 59 01 movw r10, r18
4086 1716: 28 e0 ldi r18, 0x08 ; 8
4087 1718: 30 e0 ldi r19, 0x00 ; 0
4088 171a: 84 c0 rjmp .+264 ; 0x1824 <f_open+0x476>
1234 kaklik 4089 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
1296 kaklik 4090 171c: 2f 85 ldd r18, Y+15 ; 0x0f
4091 171e: 38 89 ldd r19, Y+16 ; 0x10
4092 1720: 2f 70 andi r18, 0x0F ; 15
4093 1722: 30 70 andi r19, 0x00 ; 0
4094 1724: 85 e0 ldi r24, 0x05 ; 5
4095 1726: 22 0f add r18, r18
4096 1728: 33 1f adc r19, r19
4097 172a: 8a 95 dec r24
4098 172c: e1 f7 brne .-8 ; 0x1726 <f_open+0x378>
1234 kaklik 4099 if (dptr[DIR_Name] == 0) /* Has it reached to end of dir? */
1296 kaklik 4100 172e: f6 01 movw r30, r12
4101 1730: e2 0f add r30, r18
4102 1732: f3 1f adc r31, r19
4103 1734: 80 a1 ldd r24, Z+32 ; 0x20
4104 1736: 88 23 and r24, r24
4105 1738: e1 f0 breq .+56 ; 0x1772 <f_open+0x3c4>
1234 kaklik 4106 return !ds ? FR_NO_FILE : FR_NO_PATH;
4107 if (dptr[DIR_Name] != 0xE5 /* Matched? */
1296 kaklik 4108 173a: 85 3e cpi r24, 0xE5 ; 229
4109 173c: a1 f0 breq .+40 ; 0x1766 <f_open+0x3b8>
4110 for (;;) {
4111 ds = make_dirfile(&path, fn); /* Get a paragraph into fn[] */
4112 if (ds == 1) return FR_INVALID_NAME;
4113 for (;;) {
4114 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
4115 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
4116 173e: 00 e2 ldi r16, 0x20 ; 32
4117 1740: a0 2e mov r10, r16
4118 1742: b1 2c mov r11, r1
4119 1744: a2 0e add r10, r18
4120 1746: b3 1e adc r11, r19
4121 1748: ac 0c add r10, r12
4122 174a: bd 1c adc r11, r13
4123 if (dptr[DIR_Name] == 0) /* Has it reached to end of dir? */
4124 return !ds ? FR_NO_FILE : FR_NO_PATH;
4125 if (dptr[DIR_Name] != 0xE5 /* Matched? */
4126 174c: f5 01 movw r30, r10
4127 174e: 83 85 ldd r24, Z+11 ; 0x0b
4128 1750: 08 2f mov r16, r24
4129 1752: 83 fd sbrc r24, 3
4130 1754: 08 c0 rjmp .+16 ; 0x1766 <f_open+0x3b8>
4131 1756: 4b e0 ldi r20, 0x0B ; 11
4132 1758: 50 e0 ldi r21, 0x00 ; 0
4133 175a: b2 01 movw r22, r4
4134 175c: c5 01 movw r24, r10
4135 175e: 0e 94 96 11 call 0x232c ; 0x232c <memcmp>
4136 1762: 00 97 sbiw r24, 0x00 ; 0
4137 1764: 51 f0 breq .+20 ; 0x177a <f_open+0x3cc>
1234 kaklik 4138 && !(dptr[DIR_Attr] & AM_VOL)
4139 && !memcmp(&dptr[DIR_Name], fn, 8+3) ) break;
4140 if (!next_dir_entry(dirobj)) /* Next directory pointer */
1296 kaklik 4141 1766: ce 01 movw r24, r28
4142 1768: 0d 96 adiw r24, 0x0d ; 13
4143 176a: 0e 94 2c 06 call 0xc58 ; 0xc58 <next_dir_entry>
4144 176e: 88 23 and r24, r24
4145 1770: 39 f6 brne .-114 ; 0x1700 <f_open+0x352>
1234 kaklik 4146 return !ds ? FR_NO_FILE : FR_NO_PATH;
1296 kaklik 4147 1772: 11 23 and r17, r17
4148 1774: 09 f0 breq .+2 ; 0x1778 <f_open+0x3ca>
4149 1776: 49 c0 rjmp .+146 ; 0x180a <f_open+0x45c>
4150 1778: 4f c0 rjmp .+158 ; 0x1818 <f_open+0x46a>
1234 kaklik 4151 }
4152 if (!ds) { *dir = dptr; return FR_OK; } /* Matched with end of path */
1296 kaklik 4153 177a: 11 23 and r17, r17
4154 177c: 19 f4 brne .+6 ; 0x1784 <f_open+0x3d6>
4155 177e: 20 e0 ldi r18, 0x00 ; 0
4156 1780: 30 e0 ldi r19, 0x00 ; 0
4157 1782: 50 c0 rjmp .+160 ; 0x1824 <f_open+0x476>
1234 kaklik 4158 if (!(dptr[DIR_Attr] & AM_DIR)) return FR_NO_PATH; /* Cannot trace because it is a file */
1296 kaklik 4159 1784: 04 ff sbrs r16, 4
4160 1786: 41 c0 rjmp .+130 ; 0x180a <f_open+0x45c>
1234 kaklik 4161 clust = /* Get cluster# of the directory */
1296 kaklik 4162 1788: f5 01 movw r30, r10
4163 178a: e2 8c ldd r14, Z+26 ; 0x1a
4164 178c: f3 8c ldd r15, Z+27 ; 0x1b
1234 kaklik 4165 #if _FAT32
4166 ((DWORD)LD_WORD(&dptr[DIR_FstClusHI]) << 16) |
4167 #endif
4168 LD_WORD(&dptr[DIR_FstClusLO]);
4169 dirobj->clust = dirobj->sclust = clust; /* Restart scannig with the new directory */
1296 kaklik 4170 178e: fe 8a std Y+22, r15 ; 0x16
4171 1790: ed 8a std Y+21, r14 ; 0x15
4172 static
4173 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
4174 CLUST clust /* Cluster# to be converted */
4175 )
4176 {
4177 FATFS *fs = FatFs;
4178 1792: 00 91 10 01 lds r16, 0x0110
4179 1796: 10 91 11 01 lds r17, 0x0111
4180  
4181  
4182 clust -= 2;
4183 179a: b7 01 movw r22, r14
4184 179c: 62 50 subi r22, 0x02 ; 2
4185 179e: 70 40 sbci r23, 0x00 ; 0
4186 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
4187 17a0: f8 01 movw r30, r16
4188 17a2: 86 89 ldd r24, Z+22 ; 0x16
4189 17a4: 97 89 ldd r25, Z+23 ; 0x17
4190 17a6: 02 97 sbiw r24, 0x02 ; 2
4191 17a8: 68 17 cp r22, r24
4192 17aa: 79 07 cpc r23, r25
4193 17ac: 28 f0 brcs .+10 ; 0x17b8 <f_open+0x40a>
4194 17ae: 20 e0 ldi r18, 0x00 ; 0
4195 17b0: 30 e0 ldi r19, 0x00 ; 0
4196 17b2: 40 e0 ldi r20, 0x00 ; 0
4197 17b4: 50 e0 ldi r21, 0x00 ; 0
4198 17b6: 14 c0 rjmp .+40 ; 0x17e0 <f_open+0x432>
4199 return (DWORD)clust * fs->sects_clust + fs->database;
4200 17b8: 80 e0 ldi r24, 0x00 ; 0
4201 17ba: 90 e0 ldi r25, 0x00 ; 0
4202 17bc: f8 01 movw r30, r16
4203 17be: 25 8d ldd r18, Z+29 ; 0x1d
4204 17c0: 30 e0 ldi r19, 0x00 ; 0
4205 17c2: 40 e0 ldi r20, 0x00 ; 0
4206 17c4: 50 e0 ldi r21, 0x00 ; 0
4207 17c6: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
4208 17ca: 9b 01 movw r18, r22
4209 17cc: ac 01 movw r20, r24
4210 17ce: f8 01 movw r30, r16
4211 17d0: 80 89 ldd r24, Z+16 ; 0x10
4212 17d2: 91 89 ldd r25, Z+17 ; 0x11
4213 17d4: a2 89 ldd r26, Z+18 ; 0x12
4214 17d6: b3 89 ldd r27, Z+19 ; 0x13
4215 17d8: 28 0f add r18, r24
4216 17da: 39 1f adc r19, r25
4217 17dc: 4a 1f adc r20, r26
4218 17de: 5b 1f adc r21, r27
4219 clust = /* Get cluster# of the directory */
4220 #if _FAT32
4221 ((DWORD)LD_WORD(&dptr[DIR_FstClusHI]) << 16) |
4222 #endif
4223 LD_WORD(&dptr[DIR_FstClusLO]);
4224 dirobj->clust = dirobj->sclust = clust; /* Restart scannig with the new directory */
4225 17e0: fc 8a std Y+20, r15 ; 0x14
4226 17e2: eb 8a std Y+19, r14 ; 0x13
1234 kaklik 4227 dirobj->sect = clust2sect(clust);
1296 kaklik 4228 17e4: 2f 8b std Y+23, r18 ; 0x17
4229 17e6: 38 8f std Y+24, r19 ; 0x18
4230 17e8: 49 8f std Y+25, r20 ; 0x19
4231 17ea: 5a 8f std Y+26, r21 ; 0x1a
1234 kaklik 4232 dirobj->index = 2;
1296 kaklik 4233 17ec: 38 8a std Y+16, r3 ; 0x10
4234 17ee: 2f 86 std Y+15, r2 ; 0x0f
4235 17f0: 26 cf rjmp .-436 ; 0x163e <f_open+0x290>
4236 17f2: 20 e0 ldi r18, 0x00 ; 0
4237 17f4: 30 e0 ldi r19, 0x00 ; 0
4238 17f6: aa 24 eor r10, r10
4239 17f8: bb 24 eor r11, r11
4240 17fa: 14 c0 rjmp .+40 ; 0x1824 <f_open+0x476>
4241 17fc: 80 e0 ldi r24, 0x00 ; 0
4242 17fe: 90 e0 ldi r25, 0x00 ; 0
4243 1800: 9c 01 movw r18, r24
4244 1802: 59 01 movw r10, r18
4245 1804: 24 e0 ldi r18, 0x04 ; 4
4246 1806: 30 e0 ldi r19, 0x00 ; 0
4247 1808: 0d c0 rjmp .+26 ; 0x1824 <f_open+0x476>
4248 180a: 80 e0 ldi r24, 0x00 ; 0
4249 180c: 90 e0 ldi r25, 0x00 ; 0
4250 180e: 9c 01 movw r18, r24
4251 1810: 59 01 movw r10, r18
4252 1812: 23 e0 ldi r18, 0x03 ; 3
4253 1814: 30 e0 ldi r19, 0x00 ; 0
4254 1816: 06 c0 rjmp .+12 ; 0x1824 <f_open+0x476>
4255 1818: 80 e0 ldi r24, 0x00 ; 0
4256 181a: 90 e0 ldi r25, 0x00 ; 0
4257 181c: 9c 01 movw r18, r24
4258 181e: 59 01 movw r10, r18
4259 1820: 22 e0 ldi r18, 0x02 ; 2
4260 1822: 30 e0 ldi r19, 0x00 ; 0
1234 kaklik 4261 /* Trace the file path */
4262 res = trace_path(&dirobj, fn, path, &dir); /* Trace the file path */
4263  
4264 #if !_FS_READONLY
4265 /* Create or Open a File */
4266 if (mode & (FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)) {
1296 kaklik 4267 1824: fb 8d ldd r31, Y+27 ; 0x1b
4268 1826: 4f 2f mov r20, r31
4269 1828: 50 e0 ldi r21, 0x00 ; 0
4270 182a: ca 01 movw r24, r20
4271 182c: 8c 71 andi r24, 0x1C ; 28
4272 182e: 90 70 andi r25, 0x00 ; 0
4273 1830: 89 2b or r24, r25
4274 1832: 09 f4 brne .+2 ; 0x1836 <f_open+0x488>
4275 1834: 41 c1 rjmp .+642 ; 0x1ab8 <f_open+0x70a>
1234 kaklik 4276 CLUST rs;
4277 DWORD dw;
4278 if (res != FR_OK) { /* No file, create new */
1296 kaklik 4279 1836: 21 15 cp r18, r1
4280 1838: 31 05 cpc r19, r1
4281 183a: 09 f4 brne .+2 ; 0x183e <f_open+0x490>
4282 183c: d6 c0 rjmp .+428 ; 0x19ea <f_open+0x63c>
1234 kaklik 4283 if (res != FR_NO_FILE) return res;
1296 kaklik 4284 183e: 22 30 cpi r18, 0x02 ; 2
4285 1840: 31 05 cpc r19, r1
4286 1842: 09 f0 breq .+2 ; 0x1846 <f_open+0x498>
4287 1844: 84 c1 rjmp .+776 ; 0x1b4e <f_open+0x7a0>
1234 kaklik 4288 )
4289 {
4290 CLUST clust;
4291 DWORD sector;
4292 BYTE c, n, *dptr;
4293 FATFS *fs = FatFs;
1296 kaklik 4294 1846: 60 90 10 01 lds r6, 0x0110
4295 184a: 70 90 11 01 lds r7, 0x0111
1234 kaklik 4296  
4297  
4298 /* Re-initialize directory object */
4299 clust = dirobj->sclust;
1296 kaklik 4300 184e: 0b 89 ldd r16, Y+19 ; 0x13
4301 1850: 1c 89 ldd r17, Y+20 ; 0x14
1234 kaklik 4302 if (clust) { /* Dyanmic directory table */
1296 kaklik 4303 1852: 01 15 cp r16, r1
4304 1854: 11 05 cpc r17, r1
4305 1856: 51 f1 breq .+84 ; 0x18ac <f_open+0x4fe>
1234 kaklik 4306 dirobj->clust = clust;
1296 kaklik 4307 1858: 1e 8b std Y+22, r17 ; 0x16
4308 185a: 0d 8b std Y+21, r16 ; 0x15
4309 )
4310 {
4311 FATFS *fs = FatFs;
4312  
4313  
4314 clust -= 2;
4315 185c: b8 01 movw r22, r16
4316 185e: 62 50 subi r22, 0x02 ; 2
4317 1860: 70 40 sbci r23, 0x00 ; 0
4318 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
4319 1862: f3 01 movw r30, r6
4320 1864: 86 89 ldd r24, Z+22 ; 0x16
4321 1866: 97 89 ldd r25, Z+23 ; 0x17
4322 1868: 02 97 sbiw r24, 0x02 ; 2
4323 186a: 68 17 cp r22, r24
4324 186c: 79 07 cpc r23, r25
4325 186e: 28 f0 brcs .+10 ; 0x187a <f_open+0x4cc>
4326 1870: 20 e0 ldi r18, 0x00 ; 0
4327 1872: 30 e0 ldi r19, 0x00 ; 0
4328 1874: 40 e0 ldi r20, 0x00 ; 0
4329 1876: 50 e0 ldi r21, 0x00 ; 0
4330 1878: 14 c0 rjmp .+40 ; 0x18a2 <f_open+0x4f4>
4331 return (DWORD)clust * fs->sects_clust + fs->database;
4332 187a: 80 e0 ldi r24, 0x00 ; 0
4333 187c: 90 e0 ldi r25, 0x00 ; 0
4334 187e: f3 01 movw r30, r6
4335 1880: 25 8d ldd r18, Z+29 ; 0x1d
4336 1882: 30 e0 ldi r19, 0x00 ; 0
4337 1884: 40 e0 ldi r20, 0x00 ; 0
4338 1886: 50 e0 ldi r21, 0x00 ; 0
4339 1888: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
4340 188c: 9b 01 movw r18, r22
4341 188e: ac 01 movw r20, r24
4342 1890: f3 01 movw r30, r6
4343 1892: 80 89 ldd r24, Z+16 ; 0x10
4344 1894: 91 89 ldd r25, Z+17 ; 0x11
4345 1896: a2 89 ldd r26, Z+18 ; 0x12
4346 1898: b3 89 ldd r27, Z+19 ; 0x13
4347 189a: 28 0f add r18, r24
4348 189c: 39 1f adc r19, r25
4349 189e: 4a 1f adc r20, r26
4350 18a0: 5b 1f adc r21, r27
4351  
4352 /* Re-initialize directory object */
4353 clust = dirobj->sclust;
4354 if (clust) { /* Dyanmic directory table */
4355 dirobj->clust = clust;
1234 kaklik 4356 dirobj->sect = clust2sect(clust);
1296 kaklik 4357 18a2: 2f 8b std Y+23, r18 ; 0x17
4358 18a4: 38 8f std Y+24, r19 ; 0x18
4359 18a6: 49 8f std Y+25, r20 ; 0x19
4360 18a8: 5a 8f std Y+26, r21 ; 0x1a
4361 18aa: 09 c0 rjmp .+18 ; 0x18be <f_open+0x510>
1234 kaklik 4362 } else { /* Static directory table */
4363 dirobj->sect = fs->dirbase;
1296 kaklik 4364 18ac: f3 01 movw r30, r6
4365 18ae: 84 85 ldd r24, Z+12 ; 0x0c
4366 18b0: 95 85 ldd r25, Z+13 ; 0x0d
4367 18b2: a6 85 ldd r26, Z+14 ; 0x0e
4368 18b4: b7 85 ldd r27, Z+15 ; 0x0f
4369 18b6: 8f 8b std Y+23, r24 ; 0x17
4370 18b8: 98 8f std Y+24, r25 ; 0x18
4371 18ba: a9 8f std Y+25, r26 ; 0x19
4372 18bc: ba 8f std Y+26, r27 ; 0x1a
1234 kaklik 4373 }
4374 dirobj->index = 0;
1296 kaklik 4375 18be: 18 8a std Y+16, r1 ; 0x10
4376 18c0: 1f 86 std Y+15, r1 ; 0x0f
1234 kaklik 4377 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
4378 c = dptr[DIR_Name];
4379 if (c == 0 || c == 0xE5) { /* Found an empty entry! */
4380 *dir = dptr; return FR_OK;
4381 }
4382 } while (next_dir_entry(dirobj)); /* Next directory pointer */
1296 kaklik 4383 18c2: bd e0 ldi r27, 0x0D ; 13
4384 18c4: eb 2e mov r14, r27
4385 18c6: f1 2c mov r15, r1
4386 18c8: ec 0e add r14, r28
4387 18ca: fd 1e adc r15, r29
1234 kaklik 4388 dirobj->sect = fs->dirbase;
4389 }
4390 dirobj->index = 0;
4391  
4392 do {
4393 if (!move_window(dirobj->sect)) return FR_RW_ERROR;
1296 kaklik 4394 18cc: 6f 89 ldd r22, Y+23 ; 0x17
4395 18ce: 78 8d ldd r23, Y+24 ; 0x18
4396 18d0: 89 8d ldd r24, Y+25 ; 0x19
4397 18d2: 9a 8d ldd r25, Y+26 ; 0x1a
4398 18d4: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
4399 18d8: 88 23 and r24, r24
4400 18da: 09 f4 brne .+2 ; 0x18de <f_open+0x530>
4401 18dc: 33 c1 rjmp .+614 ; 0x1b44 <f_open+0x796>
1234 kaklik 4402 dptr = &fs->win[(dirobj->index & 15) * 32]; /* Pointer to the directory entry */
1296 kaklik 4403 18de: ef 85 ldd r30, Y+15 ; 0x0f
4404 18e0: f8 89 ldd r31, Y+16 ; 0x10
4405 18e2: ef 70 andi r30, 0x0F ; 15
4406 18e4: f0 70 andi r31, 0x00 ; 0
4407 18e6: a5 e0 ldi r26, 0x05 ; 5
4408 18e8: ee 0f add r30, r30
4409 18ea: ff 1f adc r31, r31
4410 18ec: aa 95 dec r26
4411 18ee: e1 f7 brne .-8 ; 0x18e8 <f_open+0x53a>
4412 18f0: b0 96 adiw r30, 0x20 ; 32
4413 18f2: 53 01 movw r10, r6
4414 18f4: ae 0e add r10, r30
4415 18f6: bf 1e adc r11, r31
4416 18f8: b0 97 sbiw r30, 0x20 ; 32
1234 kaklik 4417 c = dptr[DIR_Name];
1296 kaklik 4418 18fa: e6 0d add r30, r6
4419 18fc: f7 1d adc r31, r7
4420 18fe: 80 a1 ldd r24, Z+32 ; 0x20
1234 kaklik 4421 if (c == 0 || c == 0xE5) { /* Found an empty entry! */
1296 kaklik 4422 1900: 88 23 and r24, r24
4423 1902: 09 f4 brne .+2 ; 0x1906 <f_open+0x558>
4424 1904: 4c c1 rjmp .+664 ; 0x1b9e <f_open+0x7f0>
4425 1906: 85 3e cpi r24, 0xE5 ; 229
4426 1908: 09 f4 brne .+2 ; 0x190c <f_open+0x55e>
4427 190a: 49 c1 rjmp .+658 ; 0x1b9e <f_open+0x7f0>
1234 kaklik 4428 *dir = dptr; return FR_OK;
4429 }
4430 } while (next_dir_entry(dirobj)); /* Next directory pointer */
1296 kaklik 4431 190c: c7 01 movw r24, r14
4432 190e: 0e 94 2c 06 call 0xc58 ; 0xc58 <next_dir_entry>
4433 1912: 88 23 and r24, r24
4434 1914: d9 f6 brne .-74 ; 0x18cc <f_open+0x51e>
1234 kaklik 4435 /* Reached to end of the directory table */
4436  
4437 /* Abort when static table or could not stretch dynamic table */
4438 if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
1296 kaklik 4439 1916: 01 15 cp r16, r1
4440 1918: 11 05 cpc r17, r1
4441 191a: 09 f4 brne .+2 ; 0x191e <f_open+0x570>
4442 191c: 10 c1 rjmp .+544 ; 0x1b3e <f_open+0x790>
4443 191e: 8d 89 ldd r24, Y+21 ; 0x15
4444 1920: 9e 89 ldd r25, Y+22 ; 0x16
4445 1922: 0e 94 d1 04 call 0x9a2 ; 0x9a2 <create_chain>
4446 1926: 8c 01 movw r16, r24
4447 1928: 00 97 sbiw r24, 0x00 ; 0
4448 192a: 09 f4 brne .+2 ; 0x192e <f_open+0x580>
4449 192c: 08 c1 rjmp .+528 ; 0x1b3e <f_open+0x790>
1234 kaklik 4450 if (clust == 1 || !move_window(0)) return FR_RW_ERROR;
1296 kaklik 4451 192e: 81 30 cpi r24, 0x01 ; 1
4452 1930: 91 05 cpc r25, r1
4453 1932: 09 f4 brne .+2 ; 0x1936 <f_open+0x588>
4454 1934: 07 c1 rjmp .+526 ; 0x1b44 <f_open+0x796>
4455 1936: 60 e0 ldi r22, 0x00 ; 0
4456 1938: 70 e0 ldi r23, 0x00 ; 0
4457 193a: 80 e0 ldi r24, 0x00 ; 0
4458 193c: 90 e0 ldi r25, 0x00 ; 0
4459 193e: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
4460 1942: 88 23 and r24, r24
4461 1944: 09 f4 brne .+2 ; 0x1948 <f_open+0x59a>
4462 1946: fe c0 rjmp .+508 ; 0x1b44 <f_open+0x796>
4463 static
4464 DWORD clust2sect ( /* !=0: sector number, 0: failed - invalid cluster# */
4465 CLUST clust /* Cluster# to be converted */
4466 )
4467 {
4468 FATFS *fs = FatFs;
4469 1948: a0 90 10 01 lds r10, 0x0110
4470 194c: b0 90 11 01 lds r11, 0x0111
1234 kaklik 4471  
1296 kaklik 4472  
4473 clust -= 2;
4474 1950: b8 01 movw r22, r16
4475 1952: 62 50 subi r22, 0x02 ; 2
4476 1954: 70 40 sbci r23, 0x00 ; 0
4477 if (clust >= (fs->max_clust - 2)) return 0; /* Invalid cluster# */
4478 1956: f5 01 movw r30, r10
4479 1958: 86 89 ldd r24, Z+22 ; 0x16
4480 195a: 97 89 ldd r25, Z+23 ; 0x17
4481 195c: 02 97 sbiw r24, 0x02 ; 2
4482 195e: 68 17 cp r22, r24
4483 1960: 79 07 cpc r23, r25
4484 1962: 20 f0 brcs .+8 ; 0x196c <f_open+0x5be>
4485 1964: cc 24 eor r12, r12
4486 1966: dd 24 eor r13, r13
4487 1968: 76 01 movw r14, r12
4488 196a: 14 c0 rjmp .+40 ; 0x1994 <f_open+0x5e6>
4489 return (DWORD)clust * fs->sects_clust + fs->database;
4490 196c: 80 e0 ldi r24, 0x00 ; 0
4491 196e: 90 e0 ldi r25, 0x00 ; 0
4492 1970: f5 01 movw r30, r10
4493 1972: 25 8d ldd r18, Z+29 ; 0x1d
4494 1974: 30 e0 ldi r19, 0x00 ; 0
4495 1976: 40 e0 ldi r20, 0x00 ; 0
4496 1978: 50 e0 ldi r21, 0x00 ; 0
4497 197a: 0e 94 86 14 call 0x290c ; 0x290c <__mulsi3>
4498 197e: 6b 01 movw r12, r22
4499 1980: 7c 01 movw r14, r24
4500 1982: f5 01 movw r30, r10
4501 1984: 80 89 ldd r24, Z+16 ; 0x10
4502 1986: 91 89 ldd r25, Z+17 ; 0x11
4503 1988: a2 89 ldd r26, Z+18 ; 0x12
4504 198a: b3 89 ldd r27, Z+19 ; 0x13
4505 198c: c8 0e add r12, r24
4506 198e: d9 1e adc r13, r25
4507 1990: ea 1e adc r14, r26
4508 1992: fb 1e adc r15, r27
4509  
4510 /* Abort when static table or could not stretch dynamic table */
4511 if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
4512 if (clust == 1 || !move_window(0)) return FR_RW_ERROR;
4513  
1234 kaklik 4514 fs->winsect = sector = clust2sect(clust); /* Cleanup the expanded table */
1296 kaklik 4515 1994: f3 01 movw r30, r6
4516 1996: c4 82 std Z+4, r12 ; 0x04
4517 1998: d5 82 std Z+5, r13 ; 0x05
4518 199a: e6 82 std Z+6, r14 ; 0x06
4519 199c: f7 82 std Z+7, r15 ; 0x07
1234 kaklik 4520 memset(fs->win, 0, 512);
1296 kaklik 4521 199e: e0 e2 ldi r30, 0x20 ; 32
4522 19a0: ae 2e mov r10, r30
4523 19a2: b1 2c mov r11, r1
4524 19a4: a6 0c add r10, r6
4525 19a6: b7 1c adc r11, r7
4526 19a8: 80 e0 ldi r24, 0x00 ; 0
4527 19aa: 92 e0 ldi r25, 0x02 ; 2
4528 19ac: f5 01 movw r30, r10
4529 19ae: 9c 01 movw r18, r24
4530 19b0: 11 92 st Z+, r1
4531 19b2: 21 50 subi r18, 0x01 ; 1
4532 19b4: 30 40 sbci r19, 0x00 ; 0
4533 19b6: e1 f7 brne .-8 ; 0x19b0 <f_open+0x602>
1234 kaklik 4534 for (n = fs->sects_clust; n; n--) {
1296 kaklik 4535 19b8: f3 01 movw r30, r6
4536 19ba: 15 8d ldd r17, Z+29 ; 0x1d
4537 19bc: 10 c0 rjmp .+32 ; 0x19de <f_open+0x630>
1234 kaklik 4538 if (disk_write(0, fs->win, sector, 1) != RES_OK)
1296 kaklik 4539 19be: 01 e0 ldi r16, 0x01 ; 1
4540 19c0: a7 01 movw r20, r14
4541 19c2: 96 01 movw r18, r12
4542 19c4: b5 01 movw r22, r10
4543 19c6: 80 e0 ldi r24, 0x00 ; 0
4544 19c8: 0e 94 fb 0f call 0x1ff6 ; 0x1ff6 <disk_write>
4545 19cc: 89 2b or r24, r25
4546 19ce: 09 f0 breq .+2 ; 0x19d2 <f_open+0x624>
4547 19d0: b9 c0 rjmp .+370 ; 0x1b44 <f_open+0x796>
1234 kaklik 4548 return FR_RW_ERROR;
4549 sector++;
1296 kaklik 4550 19d2: 08 94 sec
4551 19d4: c1 1c adc r12, r1
4552 19d6: d1 1c adc r13, r1
4553 19d8: e1 1c adc r14, r1
4554 19da: f1 1c adc r15, r1
1234 kaklik 4555 if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
4556 if (clust == 1 || !move_window(0)) return FR_RW_ERROR;
4557  
4558 fs->winsect = sector = clust2sect(clust); /* Cleanup the expanded table */
4559 memset(fs->win, 0, 512);
4560 for (n = fs->sects_clust; n; n--) {
1296 kaklik 4561 19dc: 11 50 subi r17, 0x01 ; 1
4562 19de: 11 23 and r17, r17
4563 19e0: 71 f7 brne .-36 ; 0x19be <f_open+0x610>
1234 kaklik 4564 if (disk_write(0, fs->win, sector, 1) != RES_OK)
4565 return FR_RW_ERROR;
4566 sector++;
4567 }
4568 fs->winflag = 1;
1296 kaklik 4569 19e2: 81 e0 ldi r24, 0x01 ; 1
4570 19e4: f3 01 movw r30, r6
4571 19e6: 87 8f std Z+31, r24 ; 0x1f
4572 19e8: da c0 rjmp .+436 ; 0x1b9e <f_open+0x7f0>
1234 kaklik 4573 memset(dir, 0, 32); /* Initialize the new entry */
4574 memcpy(&dir[DIR_Name], fn, 8+3);
4575 dir[DIR_NTres] = fn[11];
4576 mode |= FA_CREATE_ALWAYS;
4577 } else { /* Any object is already existing */
4578 if (mode & FA_CREATE_NEW) /* Cannot create new */
1296 kaklik 4579 19ea: f2 ff sbrs r31, 2
4580 19ec: 03 c0 rjmp .+6 ; 0x19f4 <f_open+0x646>
4581 19ee: 27 e0 ldi r18, 0x07 ; 7
4582 19f0: 30 e0 ldi r19, 0x00 ; 0
4583 19f2: ad c0 rjmp .+346 ; 0x1b4e <f_open+0x7a0>
1234 kaklik 4584 return FR_EXIST;
4585 if (dir == NULL || (dir[DIR_Attr] & (AM_RDO|AM_DIR))) /* Cannot overwrite (R/O or DIR) */
1296 kaklik 4586 19f4: a1 14 cp r10, r1
4587 19f6: b1 04 cpc r11, r1
4588 19f8: 09 f4 brne .+2 ; 0x19fc <f_open+0x64e>
4589 19fa: a1 c0 rjmp .+322 ; 0x1b3e <f_open+0x790>
4590 19fc: f5 01 movw r30, r10
4591 19fe: 83 85 ldd r24, Z+11 ; 0x0b
4592 1a00: 81 71 andi r24, 0x11 ; 17
4593 1a02: 09 f0 breq .+2 ; 0x1a06 <f_open+0x658>
4594 1a04: 9c c0 rjmp .+312 ; 0x1b3e <f_open+0x790>
1234 kaklik 4595 return FR_DENIED;
4596 if (mode & FA_CREATE_ALWAYS) { /* Resize it to zero */
1296 kaklik 4597 1a06: 43 ff sbrs r20, 3
4598 1a08: 42 c0 rjmp .+132 ; 0x1a8e <f_open+0x6e0>
1234 kaklik 4599 #if _FAT32
4600 rs = ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) | LD_WORD(&dir[DIR_FstClusLO]);
4601 ST_WORD(&dir[DIR_FstClusHI], 0);
4602 #else
4603 rs = LD_WORD(&dir[DIR_FstClusLO]);
1296 kaklik 4604 1a0a: c2 8c ldd r12, Z+26 ; 0x1a
4605 1a0c: d3 8c ldd r13, Z+27 ; 0x1b
1234 kaklik 4606 #endif
4607 ST_WORD(&dir[DIR_FstClusLO], 0); /* cluster = 0 */
1296 kaklik 4608 1a0e: 13 8e std Z+27, r1 ; 0x1b
4609 1a10: 12 8e std Z+26, r1 ; 0x1a
1234 kaklik 4610 ST_DWORD(&dir[DIR_FileSize], 0); /* size = 0 */
1296 kaklik 4611 1a12: 14 8e std Z+28, r1 ; 0x1c
4612 1a14: 15 8e std Z+29, r1 ; 0x1d
4613 1a16: 16 8e std Z+30, r1 ; 0x1e
4614 1a18: 17 8e std Z+31, r1 ; 0x1f
1234 kaklik 4615 fs->winflag = 1;
1296 kaklik 4616 1a1a: 81 e0 ldi r24, 0x01 ; 1
4617 1a1c: f4 01 movw r30, r8
4618 1a1e: 87 8f std Z+31, r24 ; 0x1f
1234 kaklik 4619 dw = fs->winsect; /* Remove the cluster chain */
1296 kaklik 4620 1a20: 24 80 ldd r2, Z+4 ; 0x04
4621 1a22: 35 80 ldd r3, Z+5 ; 0x05
4622 1a24: 46 80 ldd r4, Z+6 ; 0x06
4623 1a26: 57 80 ldd r5, Z+7 ; 0x07
1234 kaklik 4624 BOOL remove_chain ( /* TRUE: successful, FALSE: failed */
4625 CLUST clust /* Cluster# to remove chain from */
4626 )
4627 {
4628 CLUST nxt;
4629 FATFS *fs = FatFs;
1296 kaklik 4630 1a28: e0 90 10 01 lds r14, 0x0110
4631 1a2c: f0 90 11 01 lds r15, 0x0111
4632 1a30: 86 01 movw r16, r12
4633 1a32: 1c c0 rjmp .+56 ; 0x1a6c <f_open+0x6be>
1234 kaklik 4634  
4635  
4636 while (clust >= 2 && clust < fs->max_clust) {
4637 nxt = get_cluster(clust);
1296 kaklik 4638 1a34: c8 01 movw r24, r16
4639 1a36: 0e 94 53 04 call 0x8a6 ; 0x8a6 <get_cluster>
4640 1a3a: 3c 01 movw r6, r24
1234 kaklik 4641 if (nxt == 1) return FALSE;
1296 kaklik 4642 1a3c: 81 30 cpi r24, 0x01 ; 1
4643 1a3e: 91 05 cpc r25, r1
4644 1a40: 09 f4 brne .+2 ; 0x1a44 <f_open+0x696>
4645 1a42: 80 c0 rjmp .+256 ; 0x1b44 <f_open+0x796>
1234 kaklik 4646 if (!put_cluster(clust, 0)) return FALSE;
1296 kaklik 4647 1a44: 60 e0 ldi r22, 0x00 ; 0
4648 1a46: 70 e0 ldi r23, 0x00 ; 0
4649 1a48: c8 01 movw r24, r16
4650 1a4a: 0e 94 c4 03 call 0x788 ; 0x788 <put_cluster>
4651 1a4e: 88 23 and r24, r24
4652 1a50: 09 f4 brne .+2 ; 0x1a54 <f_open+0x6a6>
4653 1a52: 78 c0 rjmp .+240 ; 0x1b44 <f_open+0x796>
1234 kaklik 4654 if (fs->free_clust != (CLUST)0xFFFFFFFF) {
1296 kaklik 4655 1a54: f7 01 movw r30, r14
4656 1a56: 82 8d ldd r24, Z+26 ; 0x1a
4657 1a58: 93 8d ldd r25, Z+27 ; 0x1b
4658 1a5a: ff ef ldi r31, 0xFF ; 255
4659 1a5c: 8f 3f cpi r24, 0xFF ; 255
4660 1a5e: 9f 07 cpc r25, r31
4661 1a60: 21 f0 breq .+8 ; 0x1a6a <f_open+0x6bc>
1234 kaklik 4662 fs->free_clust++;
1296 kaklik 4663 1a62: 01 96 adiw r24, 0x01 ; 1
4664 1a64: f7 01 movw r30, r14
4665 1a66: 93 8f std Z+27, r25 ; 0x1b
4666 1a68: 82 8f std Z+26, r24 ; 0x1a
4667 1a6a: 83 01 movw r16, r6
1234 kaklik 4668 {
4669 CLUST nxt;
4670 FATFS *fs = FatFs;
4671  
4672  
4673 while (clust >= 2 && clust < fs->max_clust) {
1296 kaklik 4674 1a6c: 02 30 cpi r16, 0x02 ; 2
4675 1a6e: 11 05 cpc r17, r1
4676 1a70: 08 f4 brcc .+2 ; 0x1a74 <f_open+0x6c6>
4677 1a72: 72 c0 rjmp .+228 ; 0x1b58 <f_open+0x7aa>
4678 1a74: f7 01 movw r30, r14
4679 1a76: 86 89 ldd r24, Z+22 ; 0x16
4680 1a78: 97 89 ldd r25, Z+23 ; 0x17
4681 1a7a: 08 17 cp r16, r24
4682 1a7c: 19 07 cpc r17, r25
4683 1a7e: d0 f2 brcs .-76 ; 0x1a34 <f_open+0x686>
4684 1a80: 6b c0 rjmp .+214 ; 0x1b58 <f_open+0x7aa>
1234 kaklik 4685 ST_DWORD(&dir[DIR_FileSize], 0); /* size = 0 */
4686 fs->winflag = 1;
4687 dw = fs->winsect; /* Remove the cluster chain */
4688 if (!remove_chain(rs) || !move_window(dw))
4689 return FR_RW_ERROR;
4690 fs->last_clust = rs - 1; /* Reuse the cluster hole */
1296 kaklik 4691 1a82: 08 94 sec
4692 1a84: c1 08 sbc r12, r1
4693 1a86: d1 08 sbc r13, r1
4694 1a88: f4 01 movw r30, r8
4695 1a8a: d1 8e std Z+25, r13 ; 0x19
4696 1a8c: c0 8e std Z+24, r12 ; 0x18
1234 kaklik 4697 }
4698 }
4699 if (mode & FA_CREATE_ALWAYS) {
1296 kaklik 4700 1a8e: fb 8d ldd r31, Y+27 ; 0x1b
4701 1a90: f3 ff sbrs r31, 3
4702 1a92: 22 c0 rjmp .+68 ; 0x1ad8 <f_open+0x72a>
1234 kaklik 4703 dir[DIR_Attr] = AM_ARC; /* New attribute */
1296 kaklik 4704 1a94: 80 e2 ldi r24, 0x20 ; 32
4705 1a96: f5 01 movw r30, r10
4706 1a98: 83 87 std Z+11, r24 ; 0x0b
1234 kaklik 4707 dw = get_fattime();
1296 kaklik 4708 1a9a: 0e 94 b0 00 call 0x160 ; 0x160 <get_fattime>
1234 kaklik 4709 ST_DWORD(&dir[DIR_WrtTime], dw); /* Updated time */
1296 kaklik 4710 1a9e: f5 01 movw r30, r10
4711 1aa0: 66 8b std Z+22, r22 ; 0x16
4712 1aa2: 77 8b std Z+23, r23 ; 0x17
4713 1aa4: 80 8f std Z+24, r24 ; 0x18
4714 1aa6: 91 8f std Z+25, r25 ; 0x19
1234 kaklik 4715 ST_DWORD(&dir[DIR_CrtTime], dw); /* Created time */
1296 kaklik 4716 1aa8: 66 87 std Z+14, r22 ; 0x0e
4717 1aaa: 77 87 std Z+15, r23 ; 0x0f
4718 1aac: 80 8b std Z+16, r24 ; 0x10
4719 1aae: 91 8b std Z+17, r25 ; 0x11
1234 kaklik 4720 fs->winflag = 1;
1296 kaklik 4721 1ab0: 81 e0 ldi r24, 0x01 ; 1
4722 1ab2: f4 01 movw r30, r8
4723 1ab4: 87 8f std Z+31, r24 ; 0x1f
4724 1ab6: 10 c0 rjmp .+32 ; 0x1ad8 <f_open+0x72a>
1234 kaklik 4725 }
4726 }
4727 /* Open a File */
4728 else {
4729 #endif /* !_FS_READONLY */
4730 if (res != FR_OK) return res; /* Trace failed */
1296 kaklik 4731 1ab8: 21 15 cp r18, r1
4732 1aba: 31 05 cpc r19, r1
4733 1abc: 09 f0 breq .+2 ; 0x1ac0 <f_open+0x712>
4734 1abe: 47 c0 rjmp .+142 ; 0x1b4e <f_open+0x7a0>
1234 kaklik 4735 if (dir == NULL || (dir[DIR_Attr] & AM_DIR)) /* It is a directory */
1296 kaklik 4736 1ac0: a1 14 cp r10, r1
4737 1ac2: b1 04 cpc r11, r1
4738 1ac4: 09 f4 brne .+2 ; 0x1ac8 <f_open+0x71a>
4739 1ac6: 41 c0 rjmp .+130 ; 0x1b4a <f_open+0x79c>
4740 1ac8: f5 01 movw r30, r10
4741 1aca: 83 85 ldd r24, Z+11 ; 0x0b
4742 1acc: 84 fd sbrc r24, 4
4743 1ace: 3d c0 rjmp .+122 ; 0x1b4a <f_open+0x79c>
1234 kaklik 4744 return FR_NO_FILE;
4745 #if !_FS_READONLY
4746 if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */
1296 kaklik 4747 1ad0: 41 ff sbrs r20, 1
4748 1ad2: 02 c0 rjmp .+4 ; 0x1ad8 <f_open+0x72a>
4749 1ad4: 80 fd sbrc r24, 0
4750 1ad6: 33 c0 rjmp .+102 ; 0x1b3e <f_open+0x790>
1234 kaklik 4751 return FR_DENIED;
4752 }
4753  
4754 fp->dir_sect = fs->winsect; /* Pointer to the directory entry */
1296 kaklik 4755 1ad8: f4 01 movw r30, r8
4756 1ada: 84 81 ldd r24, Z+4 ; 0x04
4757 1adc: 95 81 ldd r25, Z+5 ; 0x05
4758 1ade: a6 81 ldd r26, Z+6 ; 0x06
4759 1ae0: b7 81 ldd r27, Z+7 ; 0x07
4760 1ae2: ec 8d ldd r30, Y+28 ; 0x1c
4761 1ae4: fd 8d ldd r31, Y+29 ; 0x1d
4762 1ae6: 86 8b std Z+22, r24 ; 0x16
4763 1ae8: 97 8b std Z+23, r25 ; 0x17
4764 1aea: a0 8f std Z+24, r26 ; 0x18
4765 1aec: b1 8f std Z+25, r27 ; 0x19
1234 kaklik 4766 fp->dir_ptr = dir;
1296 kaklik 4767 1aee: b3 8e std Z+27, r11 ; 0x1b
4768 1af0: a2 8e std Z+26, r10 ; 0x1a
1234 kaklik 4769 #endif
4770 fp->flag = mode; /* File access mode */
1296 kaklik 4771 1af2: 2b 8d ldd r18, Y+27 ; 0x1b
4772 1af4: 22 83 std Z+2, r18 ; 0x02
1234 kaklik 4773 fp->org_clust = /* File start cluster */
1296 kaklik 4774 1af6: f5 01 movw r30, r10
4775 1af8: 82 8d ldd r24, Z+26 ; 0x1a
4776 1afa: 93 8d ldd r25, Z+27 ; 0x1b
4777 1afc: ec 8d ldd r30, Y+28 ; 0x1c
4778 1afe: fd 8d ldd r31, Y+29 ; 0x1d
4779 1b00: 97 87 std Z+15, r25 ; 0x0f
4780 1b02: 86 87 std Z+14, r24 ; 0x0e
1234 kaklik 4781 #if _FAT32
4782 ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) |
4783 #endif
4784 LD_WORD(&dir[DIR_FstClusLO]);
4785 fp->fsize = LD_DWORD(&dir[DIR_FileSize]); /* File size */
1296 kaklik 4786 1b04: f5 01 movw r30, r10
4787 1b06: 84 8d ldd r24, Z+28 ; 0x1c
4788 1b08: 95 8d ldd r25, Z+29 ; 0x1d
4789 1b0a: a6 8d ldd r26, Z+30 ; 0x1e
4790 1b0c: b7 8d ldd r27, Z+31 ; 0x1f
4791 1b0e: ec 8d ldd r30, Y+28 ; 0x1c
4792 1b10: fd 8d ldd r31, Y+29 ; 0x1d
4793 1b12: 82 87 std Z+10, r24 ; 0x0a
4794 1b14: 93 87 std Z+11, r25 ; 0x0b
4795 1b16: a4 87 std Z+12, r26 ; 0x0c
4796 1b18: b5 87 std Z+13, r27 ; 0x0d
1234 kaklik 4797 fp->fptr = 0; /* File ptr */
1296 kaklik 4798 1b1a: 16 82 std Z+6, r1 ; 0x06
4799 1b1c: 17 82 std Z+7, r1 ; 0x07
4800 1b1e: 10 86 std Z+8, r1 ; 0x08
4801 1b20: 11 86 std Z+9, r1 ; 0x09
1234 kaklik 4802 fp->sect_clust = 1; /* Sector counter */
1296 kaklik 4803 1b22: 81 e0 ldi r24, 0x01 ; 1
4804 1b24: 83 83 std Z+3, r24 ; 0x03
1234 kaklik 4805 fp->fs = fs; fp->id = fs->id; /* Owner file system object of the file */
1296 kaklik 4806 1b26: 95 82 std Z+5, r9 ; 0x05
4807 1b28: 84 82 std Z+4, r8 ; 0x04
4808 1b2a: f4 01 movw r30, r8
4809 1b2c: 80 81 ld r24, Z
4810 1b2e: 91 81 ldd r25, Z+1 ; 0x01
4811 1b30: ec 8d ldd r30, Y+28 ; 0x1c
4812 1b32: fd 8d ldd r31, Y+29 ; 0x1d
4813 1b34: 91 83 std Z+1, r25 ; 0x01
4814 1b36: 80 83 st Z, r24
4815 1b38: 20 e0 ldi r18, 0x00 ; 0
4816 1b3a: 30 e0 ldi r19, 0x00 ; 0
4817 1b3c: 08 c0 rjmp .+16 ; 0x1b4e <f_open+0x7a0>
1234 kaklik 4818  
4819 return FR_OK;
1296 kaklik 4820 1b3e: 26 e0 ldi r18, 0x06 ; 6
4821 1b40: 30 e0 ldi r19, 0x00 ; 0
4822 1b42: 05 c0 rjmp .+10 ; 0x1b4e <f_open+0x7a0>
4823 1b44: 28 e0 ldi r18, 0x08 ; 8
4824 1b46: 30 e0 ldi r19, 0x00 ; 0
4825 1b48: 02 c0 rjmp .+4 ; 0x1b4e <f_open+0x7a0>
4826 1b4a: 22 e0 ldi r18, 0x02 ; 2
4827 1b4c: 30 e0 ldi r19, 0x00 ; 0
4828 }
4829 1b4e: c9 01 movw r24, r18
4830 1b50: 6d 96 adiw r28, 0x1d ; 29
4831 1b52: e2 e1 ldi r30, 0x12 ; 18
4832 1b54: 0c 94 e3 14 jmp 0x29c6 ; 0x29c6 <__epilogue_restores__>
4833 #endif
4834 ST_WORD(&dir[DIR_FstClusLO], 0); /* cluster = 0 */
4835 ST_DWORD(&dir[DIR_FileSize], 0); /* size = 0 */
4836 fs->winflag = 1;
4837 dw = fs->winsect; /* Remove the cluster chain */
4838 if (!remove_chain(rs) || !move_window(dw))
4839 1b58: c2 01 movw r24, r4
4840 1b5a: b1 01 movw r22, r2
4841 1b5c: 0e 94 5a 03 call 0x6b4 ; 0x6b4 <move_window>
4842 1b60: 88 23 and r24, r24
4843 1b62: 09 f0 breq .+2 ; 0x1b66 <f_open+0x7b8>
4844 1b64: 8e cf rjmp .-228 ; 0x1a82 <f_open+0x6d4>
4845 1b66: ee cf rjmp .-36 ; 0x1b44 <f_open+0x796>
1234 kaklik 4846 )
4847 {
4848 CLUST clust;
4849 char ds;
4850 BYTE *dptr = NULL;
4851 FATFS *fs = FatFs;
1296 kaklik 4852 1b68: c0 90 10 01 lds r12, 0x0110
4853 1b6c: d0 90 11 01 lds r13, 0x0111
1234 kaklik 4854  
4855 /* Initialize directory object */
4856 clust = fs->dirbase;
1296 kaklik 4857 1b70: f6 01 movw r30, r12
4858 1b72: 84 85 ldd r24, Z+12 ; 0x0c
4859 1b74: 95 85 ldd r25, Z+13 ; 0x0d
1234 kaklik 4860 dirobj->clust = dirobj->sclust = clust;
4861 dirobj->sect = clust2sect(clust);
4862 } else
4863 #endif
4864 {
4865 dirobj->clust = dirobj->sclust = 0;
1296 kaklik 4866 1b76: 1c 8a std Y+20, r1 ; 0x14
4867 1b78: 1b 8a std Y+19, r1 ; 0x13
4868 1b7a: 1e 8a std Y+22, r1 ; 0x16
4869 1b7c: 1d 8a std Y+21, r1 ; 0x15
1234 kaklik 4870 dirobj->sect = clust;
1296 kaklik 4871 1b7e: a0 e0 ldi r26, 0x00 ; 0
4872 1b80: b0 e0 ldi r27, 0x00 ; 0
4873 1b82: 8f 8b std Y+23, r24 ; 0x17
4874 1b84: 98 8f std Y+24, r25 ; 0x18
4875 1b86: a9 8f std Y+25, r26 ; 0x19
4876 1b88: ba 8f std Y+26, r27 ; 0x1a
1234 kaklik 4877 }
4878 dirobj->index = 0;
1296 kaklik 4879 1b8a: 18 8a std Y+16, r1 ; 0x10
4880 1b8c: 1f 86 std Y+15, r1 ; 0x0f
1234 kaklik 4881 dirobj->fs = fs;
1296 kaklik 4882 1b8e: da 8a std Y+18, r13 ; 0x12
4883 1b90: c9 8a std Y+17, r12 ; 0x11
1234 kaklik 4884  
4885 if (*path == '\0') { /* Null path means the root directory */
1296 kaklik 4886 1b92: f3 01 movw r30, r6
4887 1b94: 80 81 ld r24, Z
4888 1b96: 88 23 and r24, r24
4889 1b98: 09 f0 breq .+2 ; 0x1b9c <f_open+0x7ee>
4890 1b9a: 4a cd rjmp .-1388 ; 0x1630 <f_open+0x282>
4891 1b9c: 2a ce rjmp .-940 ; 0x17f2 <f_open+0x444>
1234 kaklik 4892 DWORD dw;
4893 if (res != FR_OK) { /* No file, create new */
4894 if (res != FR_NO_FILE) return res;
4895 res = reserve_direntry(&dirobj, &dir);
4896 if (res != FR_OK) return res;
4897 memset(dir, 0, 32); /* Initialize the new entry */
1296 kaklik 4898 1b9e: 80 e2 ldi r24, 0x20 ; 32
4899 1ba0: f5 01 movw r30, r10
4900 1ba2: 11 92 st Z+, r1
4901 1ba4: 8a 95 dec r24
4902 1ba6: e9 f7 brne .-6 ; 0x1ba2 <f_open+0x7f4>
1234 kaklik 4903 memcpy(&dir[DIR_Name], fn, 8+3);
1296 kaklik 4904 1ba8: d5 01 movw r26, r10
4905 1baa: fe 01 movw r30, r28
4906 1bac: 31 96 adiw r30, 0x01 ; 1
4907 1bae: 8b e0 ldi r24, 0x0B ; 11
4908 1bb0: 01 90 ld r0, Z+
4909 1bb2: 0d 92 st X+, r0
4910 1bb4: 81 50 subi r24, 0x01 ; 1
4911 1bb6: e1 f7 brne .-8 ; 0x1bb0 <f_open+0x802>
1234 kaklik 4912 dir[DIR_NTres] = fn[11];
1296 kaklik 4913 1bb8: 8c 85 ldd r24, Y+12 ; 0x0c
4914 1bba: f5 01 movw r30, r10
4915 1bbc: 84 87 std Z+12, r24 ; 0x0c
1234 kaklik 4916 mode |= FA_CREATE_ALWAYS;
1296 kaklik 4917 1bbe: fb 8d ldd r31, Y+27 ; 0x1b
4918 1bc0: f8 60 ori r31, 0x08 ; 8
4919 1bc2: fb 8f std Y+27, r31 ; 0x1b
4920 1bc4: 64 cf rjmp .-312 ; 0x1a8e <f_open+0x6e0>
1234 kaklik 4921  
1296 kaklik 4922 00001bc6 <rcvr_datablock>:
1234 kaklik 4923 static
4924 BOOL rcvr_datablock (
4925 BYTE *buff, /* Data buffer to store received data */
4926 UINT btr /* Byte count (must be even number) */
4927 )
4928 {
1296 kaklik 4929 1bc6: fc 01 movw r30, r24
1234 kaklik 4930 BYTE token;
4931  
4932  
4933 Timer1 = 10;
1296 kaklik 4934 1bc8: 8a e0 ldi r24, 0x0A ; 10
4935 1bca: 80 93 15 01 sts 0x0115, r24
1234 kaklik 4936 /*-----------------------------------------------------------------------*/
4937  
4938 static
4939 BYTE rcvr_spi (void)
4940 {
4941 SPDR = 0xFF;
1296 kaklik 4942 1bce: 9f ef ldi r25, 0xFF ; 255
4943 1bd0: 9e bd out 0x2e, r25 ; 46
1234 kaklik 4944 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 4945 1bd2: 0d b4 in r0, 0x2d ; 45
4946 1bd4: 07 fe sbrs r0, 7
4947 1bd6: fd cf rjmp .-6 ; 0x1bd2 <rcvr_datablock+0xc>
1234 kaklik 4948 return SPDR;
1296 kaklik 4949 1bd8: 8e b5 in r24, 0x2e ; 46
1234 kaklik 4950  
4951  
4952 Timer1 = 10;
4953 do { /* Wait for data packet in timeout of 100ms */
4954 token = rcvr_spi();
4955 } while ((token == 0xFF) && Timer1);
1296 kaklik 4956 1bda: 8f 3f cpi r24, 0xFF ; 255
4957 1bdc: 29 f4 brne .+10 ; 0x1be8 <rcvr_datablock+0x22>
4958 1bde: 80 91 15 01 lds r24, 0x0115
4959 1be2: 88 23 and r24, r24
4960 1be4: a9 f7 brne .-22 ; 0x1bd0 <rcvr_datablock+0xa>
4961 1be6: 22 c0 rjmp .+68 ; 0x1c2c <rcvr_datablock+0x66>
1234 kaklik 4962 if(token != 0xFE) return FALSE; /* If not valid data token, retutn with error */
1296 kaklik 4963 1be8: 8e 3f cpi r24, 0xFE ; 254
4964 1bea: 01 f5 brne .+64 ; 0x1c2c <rcvr_datablock+0x66>
1234 kaklik 4965  
4966 do { /* Receive the data block into buffer */
4967 rcvr_spi_m(buff++);
1296 kaklik 4968 1bec: 9f ef ldi r25, 0xFF ; 255
4969 1bee: 9e bd out 0x2e, r25 ; 46
4970 1bf0: 0d b4 in r0, 0x2d ; 45
4971 1bf2: 07 fe sbrs r0, 7
4972 1bf4: fd cf rjmp .-6 ; 0x1bf0 <rcvr_datablock+0x2a>
4973 1bf6: 8e b5 in r24, 0x2e ; 46
4974 1bf8: 80 83 st Z, r24
1234 kaklik 4975 rcvr_spi_m(buff++);
1296 kaklik 4976 1bfa: 9e bd out 0x2e, r25 ; 46
4977 1bfc: 0d b4 in r0, 0x2d ; 45
4978 1bfe: 07 fe sbrs r0, 7
4979 1c00: fd cf rjmp .-6 ; 0x1bfc <rcvr_datablock+0x36>
4980 1c02: 8e b5 in r24, 0x2e ; 46
4981 1c04: 81 83 std Z+1, r24 ; 0x01
1234 kaklik 4982 } while (btr -= 2);
1296 kaklik 4983 1c06: 62 50 subi r22, 0x02 ; 2
4984 1c08: 70 40 sbci r23, 0x00 ; 0
4985 1c0a: 11 f0 breq .+4 ; 0x1c10 <rcvr_datablock+0x4a>
4986 static
4987 BOOL rcvr_datablock (
4988 BYTE *buff, /* Data buffer to store received data */
4989 UINT btr /* Byte count (must be even number) */
4990 )
4991 {
4992 1c0c: 32 96 adiw r30, 0x02 ; 2
4993 1c0e: ef cf rjmp .-34 ; 0x1bee <rcvr_datablock+0x28>
1234 kaklik 4994 /*-----------------------------------------------------------------------*/
4995  
4996 static
4997 BYTE rcvr_spi (void)
4998 {
4999 SPDR = 0xFF;
1296 kaklik 5000 1c10: 8f ef ldi r24, 0xFF ; 255
5001 1c12: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5002 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5003 1c14: 0d b4 in r0, 0x2d ; 45
5004 1c16: 07 fe sbrs r0, 7
5005 1c18: fd cf rjmp .-6 ; 0x1c14 <rcvr_datablock+0x4e>
1234 kaklik 5006 return SPDR;
1296 kaklik 5007 1c1a: 8e b5 in r24, 0x2e ; 46
1234 kaklik 5008 /*-----------------------------------------------------------------------*/
5009  
5010 static
5011 BYTE rcvr_spi (void)
5012 {
5013 SPDR = 0xFF;
1296 kaklik 5014 1c1c: 8f ef ldi r24, 0xFF ; 255
5015 1c1e: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5016 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5017 1c20: 0d b4 in r0, 0x2d ; 45
5018 1c22: 07 fe sbrs r0, 7
5019 1c24: fd cf rjmp .-6 ; 0x1c20 <rcvr_datablock+0x5a>
1234 kaklik 5020 return SPDR;
1296 kaklik 5021 1c26: 8e b5 in r24, 0x2e ; 46
5022 1c28: 81 e0 ldi r24, 0x01 ; 1
5023 1c2a: 08 95 ret
1234 kaklik 5024 rcvr_spi_m(buff++);
5025 } while (btr -= 2);
5026 rcvr_spi(); /* Discard CRC */
5027 rcvr_spi();
5028  
5029 return TRUE; /* Return with success */
1296 kaklik 5030 1c2c: 80 e0 ldi r24, 0x00 ; 0
1234 kaklik 5031 }
1296 kaklik 5032 1c2e: 08 95 ret
1234 kaklik 5033  
1296 kaklik 5034 00001c30 <xmit_datablock>:
1234 kaklik 5035 static
5036 BOOL xmit_datablock (
5037 const BYTE *buff, /* 512 byte data block to be transmitted */
5038 BYTE token /* Data/Stop token */
5039 )
5040 {
1296 kaklik 5041 1c30: fc 01 movw r30, r24
5042 BYTE wait_ready (void)
5043 {
5044 BYTE res;
5045  
5046  
5047 Timer2 = 50; /* Wait for ready in timeout of 500ms */
5048 1c32: 82 e3 ldi r24, 0x32 ; 50
5049 1c34: 80 93 16 01 sts 0x0116, r24
5050 /*-----------------------------------------------------------------------*/
5051  
5052 static
5053 BYTE rcvr_spi (void)
5054 {
5055 SPDR = 0xFF;
5056 1c38: 8f ef ldi r24, 0xFF ; 255
5057 1c3a: 8e bd out 0x2e, r24 ; 46
5058 loop_until_bit_is_set(SPSR, SPIF);
5059 1c3c: 0d b4 in r0, 0x2d ; 45
5060 1c3e: 07 fe sbrs r0, 7
5061 1c40: fd cf rjmp .-6 ; 0x1c3c <xmit_datablock+0xc>
5062 return SPDR;
5063 1c42: 8e b5 in r24, 0x2e ; 46
5064 /*-----------------------------------------------------------------------*/
5065  
5066 static
5067 BYTE rcvr_spi (void)
5068 {
5069 SPDR = 0xFF;
5070 1c44: 9f ef ldi r25, 0xFF ; 255
5071 1c46: 9e bd out 0x2e, r25 ; 46
5072 loop_until_bit_is_set(SPSR, SPIF);
5073 1c48: 0d b4 in r0, 0x2d ; 45
5074 1c4a: 07 fe sbrs r0, 7
5075 1c4c: fd cf rjmp .-6 ; 0x1c48 <xmit_datablock+0x18>
5076 return SPDR;
5077 1c4e: 8e b5 in r24, 0x2e ; 46
5078  
5079 Timer2 = 50; /* Wait for ready in timeout of 500ms */
5080 rcvr_spi();
5081 do
5082 res = rcvr_spi();
5083 while ((res != 0xFF) && Timer2);
5084 1c50: 8f 3f cpi r24, 0xFF ; 255
5085 1c52: 31 f0 breq .+12 ; 0x1c60 <xmit_datablock+0x30>
5086 1c54: 80 91 16 01 lds r24, 0x0116
5087 1c58: 88 23 and r24, r24
5088 1c5a: a9 f7 brne .-22 ; 0x1c46 <xmit_datablock+0x16>
5089 1c5c: 90 e0 ldi r25, 0x00 ; 0
5090 1c5e: 2e c0 rjmp .+92 ; 0x1cbc <xmit_datablock+0x8c>
1234 kaklik 5091 BYTE resp, wc;
5092  
5093  
5094 if (wait_ready() != 0xFF) return FALSE;
5095  
5096 xmit_spi(token); /* Xmit data token */
1296 kaklik 5097 1c60: 6e bd out 0x2e, r22 ; 46
5098 1c62: 0d b4 in r0, 0x2d ; 45
5099 1c64: 07 fe sbrs r0, 7
5100 1c66: fd cf rjmp .-6 ; 0x1c62 <xmit_datablock+0x32>
1234 kaklik 5101 if (token != 0xFD) { /* Is data token */
1296 kaklik 5102 1c68: 6d 3f cpi r22, 0xFD ; 253
5103 1c6a: 11 f4 brne .+4 ; 0x1c70 <xmit_datablock+0x40>
5104 1c6c: 91 e0 ldi r25, 0x01 ; 1
5105 1c6e: 26 c0 rjmp .+76 ; 0x1cbc <xmit_datablock+0x8c>
5106 1c70: 90 e0 ldi r25, 0x00 ; 0
1234 kaklik 5107 wc = 0;
5108 do { /* Xmit the 512 byte data block to MMC */
5109 xmit_spi(*buff++);
1296 kaklik 5110 1c72: 80 81 ld r24, Z
5111 1c74: 8e bd out 0x2e, r24 ; 46
5112 1c76: 0d b4 in r0, 0x2d ; 45
5113 1c78: 07 fe sbrs r0, 7
5114 1c7a: fd cf rjmp .-6 ; 0x1c76 <xmit_datablock+0x46>
1234 kaklik 5115 xmit_spi(*buff++);
1296 kaklik 5116 1c7c: 81 81 ldd r24, Z+1 ; 0x01
5117 1c7e: 8e bd out 0x2e, r24 ; 46
5118 1c80: 0d b4 in r0, 0x2d ; 45
5119 1c82: 07 fe sbrs r0, 7
5120 1c84: fd cf rjmp .-6 ; 0x1c80 <xmit_datablock+0x50>
1234 kaklik 5121 } while (--wc);
1296 kaklik 5122 1c86: 91 50 subi r25, 0x01 ; 1
5123 1c88: 11 f0 breq .+4 ; 0x1c8e <xmit_datablock+0x5e>
5124 static
5125 BOOL xmit_datablock (
5126 const BYTE *buff, /* 512 byte data block to be transmitted */
5127 BYTE token /* Data/Stop token */
5128 )
5129 {
5130 1c8a: 32 96 adiw r30, 0x02 ; 2
5131 1c8c: f2 cf rjmp .-28 ; 0x1c72 <xmit_datablock+0x42>
5132 wc = 0;
5133 do { /* Xmit the 512 byte data block to MMC */
5134 xmit_spi(*buff++);
5135 xmit_spi(*buff++);
5136 } while (--wc);
1234 kaklik 5137 xmit_spi(0xFF); /* CRC (Dummy) */
1296 kaklik 5138 1c8e: 8f ef ldi r24, 0xFF ; 255
5139 1c90: 8e bd out 0x2e, r24 ; 46
5140 1c92: 0d b4 in r0, 0x2d ; 45
5141 1c94: 07 fe sbrs r0, 7
5142 1c96: fd cf rjmp .-6 ; 0x1c92 <xmit_datablock+0x62>
1234 kaklik 5143 xmit_spi(0xFF);
1296 kaklik 5144 1c98: 8f ef ldi r24, 0xFF ; 255
5145 1c9a: 8e bd out 0x2e, r24 ; 46
5146 1c9c: 0d b4 in r0, 0x2d ; 45
5147 1c9e: 07 fe sbrs r0, 7
5148 1ca0: fd cf rjmp .-6 ; 0x1c9c <xmit_datablock+0x6c>
1234 kaklik 5149 /*-----------------------------------------------------------------------*/
5150  
5151 static
5152 BYTE rcvr_spi (void)
5153 {
5154 SPDR = 0xFF;
1296 kaklik 5155 1ca2: 8f ef ldi r24, 0xFF ; 255
5156 1ca4: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5157 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5158 1ca6: 0d b4 in r0, 0x2d ; 45
5159 1ca8: 07 fe sbrs r0, 7
5160 1caa: fd cf rjmp .-6 ; 0x1ca6 <xmit_datablock+0x76>
1234 kaklik 5161 return SPDR;
1296 kaklik 5162 1cac: 8e b5 in r24, 0x2e ; 46
5163 1cae: 90 e0 ldi r25, 0x00 ; 0
5164 1cb0: 8f 71 andi r24, 0x1F ; 31
5165 1cb2: 85 30 cpi r24, 0x05 ; 5
5166 1cb4: 09 f0 breq .+2 ; 0x1cb8 <xmit_datablock+0x88>
5167 1cb6: 91 e0 ldi r25, 0x01 ; 1
5168 1cb8: 81 e0 ldi r24, 0x01 ; 1
5169 1cba: 98 27 eor r25, r24
5170 if ((resp & 0x1F) != 0x05) /* If not accepted, return with error */
5171 return FALSE;
5172 }
1234 kaklik 5173  
1296 kaklik 5174 return TRUE;
5175 }
5176 1cbc: 89 2f mov r24, r25
5177 1cbe: 08 95 ret
5178  
5179 00001cc0 <send_cmd>:
1234 kaklik 5180 static
5181 BYTE send_cmd (
5182 BYTE cmd, /* Command byte */
5183 DWORD arg /* Argument */
5184 )
5185 {
1296 kaklik 5186 1cc0: 28 2f mov r18, r24
5187 BYTE wait_ready (void)
5188 {
5189 BYTE res;
1234 kaklik 5190  
5191  
1296 kaklik 5192 Timer2 = 50; /* Wait for ready in timeout of 500ms */
5193 1cc2: 82 e3 ldi r24, 0x32 ; 50
5194 1cc4: 80 93 16 01 sts 0x0116, r24
5195 /*-----------------------------------------------------------------------*/
5196  
5197 static
5198 BYTE rcvr_spi (void)
5199 {
5200 SPDR = 0xFF;
5201 1cc8: 8f ef ldi r24, 0xFF ; 255
5202 1cca: 8e bd out 0x2e, r24 ; 46
5203 loop_until_bit_is_set(SPSR, SPIF);
5204 1ccc: 0d b4 in r0, 0x2d ; 45
5205 1cce: 07 fe sbrs r0, 7
5206 1cd0: fd cf rjmp .-6 ; 0x1ccc <send_cmd+0xc>
5207 return SPDR;
5208 1cd2: 8e b5 in r24, 0x2e ; 46
5209 /*-----------------------------------------------------------------------*/
5210  
5211 static
5212 BYTE rcvr_spi (void)
5213 {
5214 SPDR = 0xFF;
5215 1cd4: 9f ef ldi r25, 0xFF ; 255
5216 1cd6: 9e bd out 0x2e, r25 ; 46
5217 loop_until_bit_is_set(SPSR, SPIF);
5218 1cd8: 0d b4 in r0, 0x2d ; 45
5219 1cda: 07 fe sbrs r0, 7
5220 1cdc: fd cf rjmp .-6 ; 0x1cd8 <send_cmd+0x18>
5221 return SPDR;
5222 1cde: 8e b5 in r24, 0x2e ; 46
5223  
5224 Timer2 = 50; /* Wait for ready in timeout of 500ms */
5225 rcvr_spi();
5226 do
5227 res = rcvr_spi();
5228 while ((res != 0xFF) && Timer2);
5229 1ce0: 8f 3f cpi r24, 0xFF ; 255
5230 1ce2: 31 f0 breq .+12 ; 0x1cf0 <send_cmd+0x30>
5231 1ce4: 80 91 16 01 lds r24, 0x0116
5232 1ce8: 88 23 and r24, r24
5233 1cea: a9 f7 brne .-22 ; 0x1cd6 <send_cmd+0x16>
5234 1cec: 8f ef ldi r24, 0xFF ; 255
5235 1cee: 08 95 ret
5236  
5237  
1234 kaklik 5238 if (wait_ready() != 0xFF) return 0xFF;
5239  
5240 /* Send command packet */
5241 xmit_spi(cmd); /* Command */
1296 kaklik 5242 1cf0: 2e bd out 0x2e, r18 ; 46
5243 1cf2: 0d b4 in r0, 0x2d ; 45
5244 1cf4: 07 fe sbrs r0, 7
5245 1cf6: fd cf rjmp .-6 ; 0x1cf2 <send_cmd+0x32>
1234 kaklik 5246 xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
1296 kaklik 5247 1cf8: 87 2f mov r24, r23
5248 1cfa: 99 27 eor r25, r25
5249 1cfc: aa 27 eor r26, r26
5250 1cfe: bb 27 eor r27, r27
5251 1d00: 8e bd out 0x2e, r24 ; 46
5252 1d02: 0d b4 in r0, 0x2d ; 45
5253 1d04: 07 fe sbrs r0, 7
5254 1d06: fd cf rjmp .-6 ; 0x1d02 <send_cmd+0x42>
1234 kaklik 5255 xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */
1296 kaklik 5256 1d08: cb 01 movw r24, r22
5257 1d0a: aa 27 eor r26, r26
5258 1d0c: bb 27 eor r27, r27
5259 1d0e: 8e bd out 0x2e, r24 ; 46
5260 1d10: 0d b4 in r0, 0x2d ; 45
5261 1d12: 07 fe sbrs r0, 7
5262 1d14: fd cf rjmp .-6 ; 0x1d10 <send_cmd+0x50>
1234 kaklik 5263 xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */
1296 kaklik 5264 1d16: bb 27 eor r27, r27
5265 1d18: a7 2f mov r26, r23
5266 1d1a: 96 2f mov r25, r22
5267 1d1c: 85 2f mov r24, r21
5268 1d1e: 8e bd out 0x2e, r24 ; 46
5269 1d20: 0d b4 in r0, 0x2d ; 45
5270 1d22: 07 fe sbrs r0, 7
5271 1d24: fd cf rjmp .-6 ; 0x1d20 <send_cmd+0x60>
1234 kaklik 5272 xmit_spi((BYTE)arg); /* Argument[7..0] */
1296 kaklik 5273 1d26: 4e bd out 0x2e, r20 ; 46
5274 1d28: 0d b4 in r0, 0x2d ; 45
5275 1d2a: 07 fe sbrs r0, 7
5276 1d2c: fd cf rjmp .-6 ; 0x1d28 <send_cmd+0x68>
1234 kaklik 5277 n = 0;
5278 if (cmd == CMD0) n = 0x95; /* CRC for CMD0(0) */
1296 kaklik 5279 1d2e: 20 34 cpi r18, 0x40 ; 64
5280 1d30: 11 f4 brne .+4 ; 0x1d36 <send_cmd+0x76>
5281 1d32: 85 e9 ldi r24, 0x95 ; 149
5282 1d34: 05 c0 rjmp .+10 ; 0x1d40 <send_cmd+0x80>
1234 kaklik 5283 if (cmd == CMD8) n = 0x87; /* CRC for CMD8(0x1AA) */
1296 kaklik 5284 1d36: 28 34 cpi r18, 0x48 ; 72
5285 1d38: 11 f4 brne .+4 ; 0x1d3e <send_cmd+0x7e>
5286 1d3a: 87 e8 ldi r24, 0x87 ; 135
5287 1d3c: 01 c0 rjmp .+2 ; 0x1d40 <send_cmd+0x80>
5288 1d3e: 80 e0 ldi r24, 0x00 ; 0
1234 kaklik 5289 xmit_spi(n);
1296 kaklik 5290 1d40: 8e bd out 0x2e, r24 ; 46
5291 1d42: 0d b4 in r0, 0x2d ; 45
5292 1d44: 07 fe sbrs r0, 7
5293 1d46: fd cf rjmp .-6 ; 0x1d42 <send_cmd+0x82>
1234 kaklik 5294  
5295 /* Receive command response */
5296 if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */
1296 kaklik 5297 1d48: 2c 34 cpi r18, 0x4C ; 76
5298 1d4a: 31 f4 brne .+12 ; 0x1d58 <send_cmd+0x98>
1234 kaklik 5299 /*-----------------------------------------------------------------------*/
5300  
5301 static
5302 BYTE rcvr_spi (void)
5303 {
5304 SPDR = 0xFF;
1296 kaklik 5305 1d4c: 8f ef ldi r24, 0xFF ; 255
5306 1d4e: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5307 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5308 1d50: 0d b4 in r0, 0x2d ; 45
5309 1d52: 07 fe sbrs r0, 7
5310 1d54: fd cf rjmp .-6 ; 0x1d50 <send_cmd+0x90>
1234 kaklik 5311 return SPDR;
1296 kaklik 5312 1d56: 8e b5 in r24, 0x2e ; 46
5313 1d58: 9a e0 ldi r25, 0x0A ; 10
1234 kaklik 5314 /*-----------------------------------------------------------------------*/
5315  
5316 static
5317 BYTE rcvr_spi (void)
5318 {
5319 SPDR = 0xFF;
1296 kaklik 5320 1d5a: 2f ef ldi r18, 0xFF ; 255
5321 1d5c: 2e bd out 0x2e, r18 ; 46
1234 kaklik 5322 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5323 1d5e: 0d b4 in r0, 0x2d ; 45
5324 1d60: 07 fe sbrs r0, 7
5325 1d62: fd cf rjmp .-6 ; 0x1d5e <send_cmd+0x9e>
1234 kaklik 5326 return SPDR;
1296 kaklik 5327 1d64: 8e b5 in r24, 0x2e ; 46
1234 kaklik 5328 /* Receive command response */
5329 if (cmd == CMD12) rcvr_spi(); /* Skip a stuff byte when stop reading */
5330 n = 10; /* Wait for a valid response in timeout of 10 attempts */
5331 do
5332 res = rcvr_spi();
5333 while ((res & 0x80) && --n);
1296 kaklik 5334 1d66: 87 ff sbrs r24, 7
5335 1d68: 02 c0 rjmp .+4 ; 0x1d6e <send_cmd+0xae>
5336 1d6a: 91 50 subi r25, 0x01 ; 1
5337 1d6c: b9 f7 brne .-18 ; 0x1d5c <send_cmd+0x9c>
1234 kaklik 5338  
5339 return res; /* Return with the response value */
5340 }
1296 kaklik 5341 1d6e: 08 95 ret
1234 kaklik 5342  
1296 kaklik 5343 00001d70 <disk_initialize>:
1234 kaklik 5344 /*-----------------------------------------------------------------------*/
5345  
1296 kaklik 5346 DSTATUS disk_initialize (
1234 kaklik 5347 BYTE drv /* Physical drive nmuber (0) */
5348 )
5349 {
1296 kaklik 5350 1d70: a4 e0 ldi r26, 0x04 ; 4
5351 1d72: b0 e0 ldi r27, 0x00 ; 0
5352 1d74: ee eb ldi r30, 0xBE ; 190
5353 1d76: fe e0 ldi r31, 0x0E ; 14
5354 1d78: 0c 94 d3 14 jmp 0x29a6 ; 0x29a6 <__prologue_saves__+0x18>
5355 BYTE n, ty, ocr[4];
1234 kaklik 5356  
5357  
1296 kaklik 5358 if (drv) return STA_NOINIT; /* Supports only single drive */
5359 1d7c: 88 23 and r24, r24
5360 1d7e: 11 f0 breq .+4 ; 0x1d84 <disk_initialize+0x14>
5361 1d80: 81 e0 ldi r24, 0x01 ; 1
5362 1d82: cf c0 rjmp .+414 ; 0x1f22 <disk_initialize+0x1b2>
5363 if (Stat & STA_NODISK) return Stat; /* No card in the socket */
5364 1d84: 80 91 0b 01 lds r24, 0x010B
5365 1d88: 81 fd sbrc r24, 1
5366 1d8a: c9 c0 rjmp .+402 ; 0x1f1e <disk_initialize+0x1ae>
5367 1d8c: 8a e0 ldi r24, 0x0A ; 10
5368 /*-----------------------------------------------------------------------*/
5369  
5370 static
5371 BYTE rcvr_spi (void)
1234 kaklik 5372 {
1296 kaklik 5373 SPDR = 0xFF;
5374 1d8e: 9f ef ldi r25, 0xFF ; 255
5375 1d90: 9e bd out 0x2e, r25 ; 46
5376 loop_until_bit_is_set(SPSR, SPIF);
5377 1d92: 0d b4 in r0, 0x2d ; 45
5378 1d94: 07 fe sbrs r0, 7
5379 1d96: fd cf rjmp .-6 ; 0x1d92 <disk_initialize+0x22>
5380 return SPDR;
5381 1d98: 2e b5 in r18, 0x2e ; 46
1234 kaklik 5382  
5383  
1296 kaklik 5384 if (drv) return STA_NOINIT; /* Supports only single drive */
5385 if (Stat & STA_NODISK) return Stat; /* No card in the socket */
1234 kaklik 5386  
1296 kaklik 5387 for (n = 10; n; n--) rcvr_spi(); /* 80 dummy clocks */
5388 1d9a: 81 50 subi r24, 0x01 ; 1
5389 1d9c: c9 f7 brne .-14 ; 0x1d90 <disk_initialize+0x20>
1234 kaklik 5390  
1296 kaklik 5391 SELECT(); /* CS = L */
5392 1d9e: 2a 98 cbi 0x05, 2 ; 5
5393 ty = 0;
5394 if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
5395 1da0: 40 e0 ldi r20, 0x00 ; 0
5396 1da2: 50 e0 ldi r21, 0x00 ; 0
5397 1da4: 60 e0 ldi r22, 0x00 ; 0
5398 1da6: 70 e0 ldi r23, 0x00 ; 0
5399 1da8: 80 e4 ldi r24, 0x40 ; 64
5400 1daa: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5401 1dae: 81 30 cpi r24, 0x01 ; 1
5402 1db0: 09 f0 breq .+2 ; 0x1db4 <disk_initialize+0x44>
5403 1db2: a0 c0 rjmp .+320 ; 0x1ef4 <disk_initialize+0x184>
5404 Timer1 = 100; /* Initialization timeout of 1000 msec */
5405 1db4: 84 e6 ldi r24, 0x64 ; 100
5406 1db6: 80 93 15 01 sts 0x0115, r24
5407 if (send_cmd(CMD8, 0x1AA) == 1) { /* SDC Ver2+ */
5408 1dba: 4a ea ldi r20, 0xAA ; 170
5409 1dbc: 51 e0 ldi r21, 0x01 ; 1
5410 1dbe: 60 e0 ldi r22, 0x00 ; 0
5411 1dc0: 70 e0 ldi r23, 0x00 ; 0
5412 1dc2: 88 e4 ldi r24, 0x48 ; 72
5413 1dc4: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5414 1dc8: 81 30 cpi r24, 0x01 ; 1
5415 1dca: 09 f0 breq .+2 ; 0x1dce <disk_initialize+0x5e>
5416 1dcc: 54 c0 rjmp .+168 ; 0x1e76 <disk_initialize+0x106>
5417 1dce: 7e 01 movw r14, r28
5418 1dd0: 08 94 sec
5419 1dd2: e1 1c adc r14, r1
5420 1dd4: f1 1c adc r15, r1
5421 1dd6: 87 01 movw r16, r14
5422 /*-----------------------------------------------------------------------*/
1234 kaklik 5423  
1296 kaklik 5424 static
5425 BYTE rcvr_spi (void)
1234 kaklik 5426 {
1296 kaklik 5427 SPDR = 0xFF;
5428 1dd8: 9f ef ldi r25, 0xFF ; 255
5429 SELECT(); /* CS = L */
5430 ty = 0;
5431 if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
5432 Timer1 = 100; /* Initialization timeout of 1000 msec */
5433 if (send_cmd(CMD8, 0x1AA) == 1) { /* SDC Ver2+ */
5434 for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
5435 1dda: 9e 01 movw r18, r28
5436 1ddc: 2b 5f subi r18, 0xFB ; 251
5437 1dde: 3f 4f sbci r19, 0xFF ; 255
5438 /*-----------------------------------------------------------------------*/
1234 kaklik 5439  
1296 kaklik 5440 static
5441 BYTE rcvr_spi (void)
1234 kaklik 5442 {
1296 kaklik 5443 SPDR = 0xFF;
5444 1de0: 9e bd out 0x2e, r25 ; 46
5445 loop_until_bit_is_set(SPSR, SPIF);
5446 1de2: 0d b4 in r0, 0x2d ; 45
5447 1de4: 07 fe sbrs r0, 7
5448 1de6: fd cf rjmp .-6 ; 0x1de2 <disk_initialize+0x72>
5449 return SPDR;
5450 1de8: 8e b5 in r24, 0x2e ; 46
5451 SELECT(); /* CS = L */
5452 ty = 0;
5453 if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */
5454 Timer1 = 100; /* Initialization timeout of 1000 msec */
5455 if (send_cmd(CMD8, 0x1AA) == 1) { /* SDC Ver2+ */
5456 for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
5457 1dea: f8 01 movw r30, r16
5458 1dec: 81 93 st Z+, r24
5459 1dee: 8f 01 movw r16, r30
5460 1df0: e2 17 cp r30, r18
5461 1df2: f3 07 cpc r31, r19
5462 1df4: a9 f7 brne .-22 ; 0x1de0 <disk_initialize+0x70>
5463 if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */
5464 1df6: 8b 81 ldd r24, Y+3 ; 0x03
5465 1df8: 81 30 cpi r24, 0x01 ; 1
5466 1dfa: 09 f0 breq .+2 ; 0x1dfe <disk_initialize+0x8e>
5467 1dfc: 7b c0 rjmp .+246 ; 0x1ef4 <disk_initialize+0x184>
5468 1dfe: 8c 81 ldd r24, Y+4 ; 0x04
5469 1e00: 8a 3a cpi r24, 0xAA ; 170
5470 1e02: 09 f0 breq .+2 ; 0x1e06 <disk_initialize+0x96>
5471 1e04: 77 c0 rjmp .+238 ; 0x1ef4 <disk_initialize+0x184>
5472 do {
5473 if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 1UL << 30) == 0) break; /* ACMD41 with HCS bit */
5474 1e06: 40 e0 ldi r20, 0x00 ; 0
5475 1e08: 50 e0 ldi r21, 0x00 ; 0
5476 1e0a: 60 e0 ldi r22, 0x00 ; 0
5477 1e0c: 70 e0 ldi r23, 0x00 ; 0
5478 1e0e: 87 e7 ldi r24, 0x77 ; 119
5479 1e10: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5480 1e14: 82 30 cpi r24, 0x02 ; 2
5481 1e16: 48 f4 brcc .+18 ; 0x1e2a <disk_initialize+0xba>
5482 1e18: 40 e0 ldi r20, 0x00 ; 0
5483 1e1a: 50 e0 ldi r21, 0x00 ; 0
5484 1e1c: 60 e0 ldi r22, 0x00 ; 0
5485 1e1e: 70 e4 ldi r23, 0x40 ; 64
5486 1e20: 89 e6 ldi r24, 0x69 ; 105
5487 1e22: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5488 1e26: 88 23 and r24, r24
5489 1e28: 21 f0 breq .+8 ; 0x1e32 <disk_initialize+0xc2>
5490 } while (Timer1);
5491 1e2a: 80 91 15 01 lds r24, 0x0115
5492 1e2e: 88 23 and r24, r24
5493 1e30: 51 f7 brne .-44 ; 0x1e06 <disk_initialize+0x96>
5494 if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit */
5495 1e32: 80 91 15 01 lds r24, 0x0115
5496 1e36: 88 23 and r24, r24
5497 1e38: 09 f4 brne .+2 ; 0x1e3c <disk_initialize+0xcc>
5498 1e3a: 5c c0 rjmp .+184 ; 0x1ef4 <disk_initialize+0x184>
5499 1e3c: 40 e0 ldi r20, 0x00 ; 0
5500 1e3e: 50 e0 ldi r21, 0x00 ; 0
5501 1e40: 60 e0 ldi r22, 0x00 ; 0
5502 1e42: 70 e0 ldi r23, 0x00 ; 0
5503 1e44: 8a e7 ldi r24, 0x7A ; 122
5504 1e46: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5505 1e4a: 88 23 and r24, r24
5506 1e4c: 09 f0 breq .+2 ; 0x1e50 <disk_initialize+0xe0>
5507 1e4e: 52 c0 rjmp .+164 ; 0x1ef4 <disk_initialize+0x184>
1234 kaklik 5508 /*-----------------------------------------------------------------------*/
5509  
5510 static
5511 BYTE rcvr_spi (void)
5512 {
5513 SPDR = 0xFF;
1296 kaklik 5514 1e50: 9f ef ldi r25, 0xFF ; 255
5515 1e52: 9e bd out 0x2e, r25 ; 46
1234 kaklik 5516 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5517 1e54: 0d b4 in r0, 0x2d ; 45
5518 1e56: 07 fe sbrs r0, 7
5519 1e58: fd cf rjmp .-6 ; 0x1e54 <disk_initialize+0xe4>
1234 kaklik 5520 return SPDR;
1296 kaklik 5521 1e5a: 8e b5 in r24, 0x2e ; 46
5522 if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */
5523 do {
5524 if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 1UL << 30) == 0) break; /* ACMD41 with HCS bit */
5525 } while (Timer1);
5526 if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit */
5527 for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
5528 1e5c: f7 01 movw r30, r14
5529 1e5e: 81 93 st Z+, r24
5530 1e60: 7f 01 movw r14, r30
5531 1e62: e0 17 cp r30, r16
5532 1e64: f1 07 cpc r31, r17
5533 1e66: a9 f7 brne .-22 ; 0x1e52 <disk_initialize+0xe2>
5534 ty = (ocr[0] & 0x40) ? 6 : 2;
5535 1e68: 89 81 ldd r24, Y+1 ; 0x01
5536 1e6a: 86 fd sbrc r24, 6
5537 1e6c: 02 c0 rjmp .+4 ; 0x1e72 <disk_initialize+0x102>
5538 1e6e: 12 e0 ldi r17, 0x02 ; 2
5539 1e70: 42 c0 rjmp .+132 ; 0x1ef6 <disk_initialize+0x186>
5540 1e72: 16 e0 ldi r17, 0x06 ; 6
5541 1e74: 40 c0 rjmp .+128 ; 0x1ef6 <disk_initialize+0x186>
5542 }
5543 }
5544 } else { /* SDC Ver1 or MMC */
5545 ty = (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 0) <= 1) ? 2 : 1; /* SDC : MMC */
5546 1e76: 40 e0 ldi r20, 0x00 ; 0
5547 1e78: 50 e0 ldi r21, 0x00 ; 0
5548 1e7a: 60 e0 ldi r22, 0x00 ; 0
5549 1e7c: 70 e0 ldi r23, 0x00 ; 0
5550 1e7e: 87 e7 ldi r24, 0x77 ; 119
5551 1e80: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5552 1e84: 82 30 cpi r24, 0x02 ; 2
5553 1e86: 58 f4 brcc .+22 ; 0x1e9e <disk_initialize+0x12e>
5554 1e88: 40 e0 ldi r20, 0x00 ; 0
5555 1e8a: 50 e0 ldi r21, 0x00 ; 0
5556 1e8c: 60 e0 ldi r22, 0x00 ; 0
5557 1e8e: 70 e0 ldi r23, 0x00 ; 0
5558 1e90: 89 e6 ldi r24, 0x69 ; 105
5559 1e92: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5560 1e96: 82 30 cpi r24, 0x02 ; 2
5561 1e98: 10 f4 brcc .+4 ; 0x1e9e <disk_initialize+0x12e>
5562 1e9a: 12 e0 ldi r17, 0x02 ; 2
5563 1e9c: 01 c0 rjmp .+2 ; 0x1ea0 <disk_initialize+0x130>
5564 1e9e: 11 e0 ldi r17, 0x01 ; 1
5565 do {
5566 if (ty == 2) {
5567 1ea0: 12 30 cpi r17, 0x02 ; 2
5568 1ea2: 79 f4 brne .+30 ; 0x1ec2 <disk_initialize+0x152>
5569 if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 0) == 0) break; /* ACMD41 */
5570 1ea4: 40 e0 ldi r20, 0x00 ; 0
5571 1ea6: 50 e0 ldi r21, 0x00 ; 0
5572 1ea8: 60 e0 ldi r22, 0x00 ; 0
5573 1eaa: 70 e0 ldi r23, 0x00 ; 0
5574 1eac: 87 e7 ldi r24, 0x77 ; 119
5575 1eae: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5576 1eb2: 82 30 cpi r24, 0x02 ; 2
5577 1eb4: 78 f4 brcc .+30 ; 0x1ed4 <disk_initialize+0x164>
5578 1eb6: 40 e0 ldi r20, 0x00 ; 0
5579 1eb8: 50 e0 ldi r21, 0x00 ; 0
5580 1eba: 60 e0 ldi r22, 0x00 ; 0
5581 1ebc: 70 e0 ldi r23, 0x00 ; 0
5582 1ebe: 89 e6 ldi r24, 0x69 ; 105
5583 1ec0: 05 c0 rjmp .+10 ; 0x1ecc <disk_initialize+0x15c>
5584 } else {
5585 if (send_cmd(CMD1, 0) == 0) break; /* CMD1 */
5586 1ec2: 40 e0 ldi r20, 0x00 ; 0
5587 1ec4: 50 e0 ldi r21, 0x00 ; 0
5588 1ec6: 60 e0 ldi r22, 0x00 ; 0
5589 1ec8: 70 e0 ldi r23, 0x00 ; 0
5590 1eca: 81 e4 ldi r24, 0x41 ; 65
5591 1ecc: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5592 1ed0: 88 23 and r24, r24
5593 1ed2: 21 f0 breq .+8 ; 0x1edc <disk_initialize+0x16c>
5594 }
5595 } while (Timer1);
5596 1ed4: 80 91 15 01 lds r24, 0x0115
5597 1ed8: 88 23 and r24, r24
5598 1eda: 11 f7 brne .-60 ; 0x1ea0 <disk_initialize+0x130>
5599 if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Select R/W block length */
5600 1edc: 80 91 15 01 lds r24, 0x0115
5601 1ee0: 88 23 and r24, r24
5602 1ee2: 41 f0 breq .+16 ; 0x1ef4 <disk_initialize+0x184>
5603 1ee4: 40 e0 ldi r20, 0x00 ; 0
5604 1ee6: 52 e0 ldi r21, 0x02 ; 2
5605 1ee8: 60 e0 ldi r22, 0x00 ; 0
5606 1eea: 70 e0 ldi r23, 0x00 ; 0
5607 1eec: 80 e5 ldi r24, 0x50 ; 80
5608 1eee: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5609 1ef2: 81 11 cpse r24, r1
5610 1ef4: 10 e0 ldi r17, 0x00 ; 0
5611 ty = 0;
5612 }
1234 kaklik 5613 }
1296 kaklik 5614 CardType = ty;
5615 1ef6: 10 93 17 01 sts 0x0117, r17
1234 kaklik 5616 DESELECT(); /* CS = H */
1296 kaklik 5617 1efa: 2a 9a sbi 0x05, 2 ; 5
1234 kaklik 5618 /*-----------------------------------------------------------------------*/
5619  
5620 static
5621 BYTE rcvr_spi (void)
5622 {
5623 SPDR = 0xFF;
1296 kaklik 5624 1efc: 8f ef ldi r24, 0xFF ; 255
5625 1efe: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5626 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5627 1f00: 0d b4 in r0, 0x2d ; 45
5628 1f02: 07 fe sbrs r0, 7
5629 1f04: fd cf rjmp .-6 ; 0x1f00 <disk_initialize+0x190>
1234 kaklik 5630 return SPDR;
1296 kaklik 5631 1f06: 8e b5 in r24, 0x2e ; 46
1234 kaklik 5632 }
1296 kaklik 5633 CardType = ty;
1234 kaklik 5634 DESELECT(); /* CS = H */
5635 rcvr_spi(); /* Idle (Release DO) */
5636  
1296 kaklik 5637 if (ty) { /* Initialization succeded */
5638 1f08: 11 23 and r17, r17
5639 1f0a: 21 f0 breq .+8 ; 0x1f14 <disk_initialize+0x1a4>
5640 Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */
5641 1f0c: 80 91 0b 01 lds r24, 0x010B
5642 1f10: 8e 7f andi r24, 0xFE ; 254
5643 1f12: 03 c0 rjmp .+6 ; 0x1f1a <disk_initialize+0x1aa>
5644 } else { /* Initialization failed */
5645 Stat |= STA_NOINIT; /* Set STA_NOINIT */
5646 1f14: 80 91 0b 01 lds r24, 0x010B
5647 1f18: 81 60 ori r24, 0x01 ; 1
5648 1f1a: 80 93 0b 01 sts 0x010B, r24
5649 }
5650  
5651 return Stat;
5652 1f1e: 80 91 0b 01 lds r24, 0x010B
1234 kaklik 5653 }
1296 kaklik 5654 1f22: 24 96 adiw r28, 0x04 ; 4
5655 1f24: e6 e0 ldi r30, 0x06 ; 6
5656 1f26: 0c 94 ef 14 jmp 0x29de ; 0x29de <__epilogue_restores__+0x18>
1234 kaklik 5657  
1296 kaklik 5658 00001f2a <disk_status>:
5659 /*-----------------------------------------------------------------------*/
5660  
5661 DSTATUS disk_status (
5662 BYTE drv /* Physical drive nmuber (0) */
5663 )
5664 {
5665 1f2a: 88 23 and r24, r24
5666 1f2c: 11 f0 breq .+4 ; 0x1f32 <disk_status+0x8>
5667 1f2e: 81 e0 ldi r24, 0x01 ; 1
5668 1f30: 08 95 ret
5669 if (drv) return STA_NOINIT; /* Supports only single drive */
5670 return Stat;
5671 1f32: 80 91 0b 01 lds r24, 0x010B
5672 }
5673 1f36: 08 95 ret
5674  
5675 00001f38 <disk_read>:
1234 kaklik 5676 BYTE drv, /* Physical drive nmuber (0) */
1296 kaklik 5677 BYTE *buff, /* Pointer to the data buffer to store read data */
1234 kaklik 5678 DWORD sector, /* Start sector number (LBA) */
5679 BYTE count /* Sector count (1..255) */
5680 )
5681 {
1296 kaklik 5682 1f38: 0f 93 push r16
5683 1f3a: cf 93 push r28
5684 1f3c: df 93 push r29
5685 1f3e: eb 01 movw r28, r22
1234 kaklik 5686 if (drv || !count) return RES_PARERR;
1296 kaklik 5687 1f40: 88 23 and r24, r24
5688 1f42: 09 f0 breq .+2 ; 0x1f46 <disk_read+0xe>
5689 1f44: 51 c0 rjmp .+162 ; 0x1fe8 <disk_read+0xb0>
5690 1f46: 00 23 and r16, r16
5691 1f48: 09 f4 brne .+2 ; 0x1f4c <disk_read+0x14>
5692 1f4a: 4e c0 rjmp .+156 ; 0x1fe8 <disk_read+0xb0>
1234 kaklik 5693 if (Stat & STA_NOINIT) return RES_NOTRDY;
1296 kaklik 5694 1f4c: 80 91 0b 01 lds r24, 0x010B
5695 1f50: 80 ff sbrs r24, 0
5696 1f52: 03 c0 rjmp .+6 ; 0x1f5a <disk_read+0x22>
5697 1f54: 23 e0 ldi r18, 0x03 ; 3
5698 1f56: 30 e0 ldi r19, 0x00 ; 0
5699 1f58: 49 c0 rjmp .+146 ; 0x1fec <disk_read+0xb4>
1234 kaklik 5700  
5701 if (!(CardType & 4)) sector *= 512; /* Convert to byte address if needed */
1296 kaklik 5702 1f5a: 80 91 17 01 lds r24, 0x0117
5703 1f5e: 82 fd sbrc r24, 2
5704 1f60: 07 c0 rjmp .+14 ; 0x1f70 <disk_read+0x38>
5705 1f62: 69 e0 ldi r22, 0x09 ; 9
5706 1f64: 22 0f add r18, r18
5707 1f66: 33 1f adc r19, r19
5708 1f68: 44 1f adc r20, r20
5709 1f6a: 55 1f adc r21, r21
5710 1f6c: 6a 95 dec r22
5711 1f6e: d1 f7 brne .-12 ; 0x1f64 <disk_read+0x2c>
1234 kaklik 5712  
5713 SELECT(); /* CS = L */
1296 kaklik 5714 1f70: 2a 98 cbi 0x05, 2 ; 5
1234 kaklik 5715  
1296 kaklik 5716 if (count == 1) { /* Single block read */
5717 1f72: 01 30 cpi r16, 0x01 ; 1
5718 1f74: 89 f4 brne .+34 ; 0x1f98 <disk_read+0x60>
5719 if ((send_cmd(CMD17, sector) == 0) /* READ_SINGLE_BLOCK */
5720 1f76: ba 01 movw r22, r20
5721 1f78: a9 01 movw r20, r18
5722 1f7a: 81 e5 ldi r24, 0x51 ; 81
5723 1f7c: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5724 1f80: 88 23 and r24, r24
5725 1f82: 21 f5 brne .+72 ; 0x1fcc <disk_read+0x94>
5726 1f84: 60 e0 ldi r22, 0x00 ; 0
5727 1f86: 72 e0 ldi r23, 0x02 ; 2
5728 1f88: ce 01 movw r24, r28
5729 1f8a: 0e 94 e3 0d call 0x1bc6 ; 0x1bc6 <rcvr_datablock>
5730 1f8e: 00 e0 ldi r16, 0x00 ; 0
5731 1f90: 88 23 and r24, r24
5732 1f92: e1 f4 brne .+56 ; 0x1fcc <disk_read+0x94>
5733 1f94: 01 e0 ldi r16, 0x01 ; 1
5734 1f96: 1a c0 rjmp .+52 ; 0x1fcc <disk_read+0x94>
5735 && rcvr_datablock(buff, 512))
1234 kaklik 5736 count = 0;
5737 }
1296 kaklik 5738 else { /* Multiple block read */
5739 if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
5740 1f98: ba 01 movw r22, r20
5741 1f9a: a9 01 movw r20, r18
5742 1f9c: 82 e5 ldi r24, 0x52 ; 82
5743 1f9e: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5744 1fa2: 88 23 and r24, r24
5745 1fa4: 99 f4 brne .+38 ; 0x1fcc <disk_read+0x94>
1234 kaklik 5746 do {
1296 kaklik 5747 if (!rcvr_datablock(buff, 512)) break;
5748 1fa6: 60 e0 ldi r22, 0x00 ; 0
5749 1fa8: 72 e0 ldi r23, 0x02 ; 2
5750 1faa: ce 01 movw r24, r28
5751 1fac: 0e 94 e3 0d call 0x1bc6 ; 0x1bc6 <rcvr_datablock>
5752 1fb0: 88 23 and r24, r24
5753 1fb2: 29 f0 breq .+10 ; 0x1fbe <disk_read+0x86>
1234 kaklik 5754 buff += 512;
5755 } while (--count);
1296 kaklik 5756 1fb4: 01 50 subi r16, 0x01 ; 1
5757 1fb6: 19 f0 breq .+6 ; 0x1fbe <disk_read+0x86>
5758 }
5759 else { /* Multiple block read */
5760 if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
1234 kaklik 5761 do {
1296 kaklik 5762 if (!rcvr_datablock(buff, 512)) break;
1234 kaklik 5763 buff += 512;
1296 kaklik 5764 1fb8: c0 50 subi r28, 0x00 ; 0
5765 1fba: de 4f sbci r29, 0xFE ; 254
5766 1fbc: f4 cf rjmp .-24 ; 0x1fa6 <disk_read+0x6e>
1234 kaklik 5767 } while (--count);
1296 kaklik 5768 send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
5769 1fbe: 40 e0 ldi r20, 0x00 ; 0
5770 1fc0: 50 e0 ldi r21, 0x00 ; 0
5771 1fc2: 60 e0 ldi r22, 0x00 ; 0
5772 1fc4: 70 e0 ldi r23, 0x00 ; 0
5773 1fc6: 8c e4 ldi r24, 0x4C ; 76
5774 1fc8: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
1234 kaklik 5775 }
5776 }
5777  
5778 DESELECT(); /* CS = H */
1296 kaklik 5779 1fcc: 2a 9a sbi 0x05, 2 ; 5
1234 kaklik 5780 /*-----------------------------------------------------------------------*/
5781  
5782 static
5783 BYTE rcvr_spi (void)
5784 {
5785 SPDR = 0xFF;
1296 kaklik 5786 1fce: 8f ef ldi r24, 0xFF ; 255
5787 1fd0: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5788 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5789 1fd2: 0d b4 in r0, 0x2d ; 45
5790 1fd4: 07 fe sbrs r0, 7
5791 1fd6: fd cf rjmp .-6 ; 0x1fd2 <disk_read+0x9a>
1234 kaklik 5792 return SPDR;
1296 kaklik 5793 1fd8: 8e b5 in r24, 0x2e ; 46
1234 kaklik 5794 }
5795  
5796 DESELECT(); /* CS = H */
5797 rcvr_spi(); /* Idle (Release DO) */
5798  
5799 return count ? RES_ERROR : RES_OK;
1296 kaklik 5800 1fda: 20 e0 ldi r18, 0x00 ; 0
5801 1fdc: 30 e0 ldi r19, 0x00 ; 0
5802 1fde: 00 23 and r16, r16
5803 1fe0: 29 f0 breq .+10 ; 0x1fec <disk_read+0xb4>
5804 1fe2: 21 e0 ldi r18, 0x01 ; 1
5805 1fe4: 30 e0 ldi r19, 0x00 ; 0
5806 1fe6: 02 c0 rjmp .+4 ; 0x1fec <disk_read+0xb4>
5807 1fe8: 24 e0 ldi r18, 0x04 ; 4
5808 1fea: 30 e0 ldi r19, 0x00 ; 0
5809 }
5810 1fec: c9 01 movw r24, r18
5811 1fee: df 91 pop r29
5812 1ff0: cf 91 pop r28
5813 1ff2: 0f 91 pop r16
5814 1ff4: 08 95 ret
1234 kaklik 5815  
1296 kaklik 5816 00001ff6 <disk_write>:
1234 kaklik 5817 BYTE drv, /* Physical drive nmuber (0) */
1296 kaklik 5818 const BYTE *buff, /* Pointer to the data to be written */
1234 kaklik 5819 DWORD sector, /* Start sector number (LBA) */
5820 BYTE count /* Sector count (1..255) */
5821 )
5822 {
1296 kaklik 5823 1ff6: cf 92 push r12
5824 1ff8: df 92 push r13
5825 1ffa: ef 92 push r14
5826 1ffc: ff 92 push r15
5827 1ffe: 0f 93 push r16
5828 2000: cf 93 push r28
5829 2002: df 93 push r29
5830 2004: eb 01 movw r28, r22
5831 2006: 69 01 movw r12, r18
5832 2008: 7a 01 movw r14, r20
1234 kaklik 5833 if (drv || !count) return RES_PARERR;
1296 kaklik 5834 200a: 88 23 and r24, r24
5835 200c: 09 f0 breq .+2 ; 0x2010 <disk_write+0x1a>
5836 200e: 64 c0 rjmp .+200 ; 0x20d8 <disk_write+0xe2>
5837 2010: 00 23 and r16, r16
5838 2012: 09 f4 brne .+2 ; 0x2016 <disk_write+0x20>
5839 2014: 61 c0 rjmp .+194 ; 0x20d8 <disk_write+0xe2>
1234 kaklik 5840 if (Stat & STA_NOINIT) return RES_NOTRDY;
1296 kaklik 5841 2016: 80 91 0b 01 lds r24, 0x010B
5842 201a: 80 ff sbrs r24, 0
5843 201c: 03 c0 rjmp .+6 ; 0x2024 <disk_write+0x2e>
5844 201e: 23 e0 ldi r18, 0x03 ; 3
5845 2020: 30 e0 ldi r19, 0x00 ; 0
5846 2022: 5c c0 rjmp .+184 ; 0x20dc <disk_write+0xe6>
5847 if (Stat & STA_PROTECT) return RES_WRPRT;
5848 2024: 80 91 0b 01 lds r24, 0x010B
5849 2028: 82 ff sbrs r24, 2
5850 202a: 03 c0 rjmp .+6 ; 0x2032 <disk_write+0x3c>
5851 202c: 22 e0 ldi r18, 0x02 ; 2
5852 202e: 30 e0 ldi r19, 0x00 ; 0
5853 2030: 55 c0 rjmp .+170 ; 0x20dc <disk_write+0xe6>
1234 kaklik 5854  
5855 if (!(CardType & 4)) sector *= 512; /* Convert to byte address if needed */
1296 kaklik 5856 2032: 80 91 17 01 lds r24, 0x0117
5857 2036: 82 fd sbrc r24, 2
5858 2038: 07 c0 rjmp .+14 ; 0x2048 <disk_write+0x52>
5859 203a: 79 e0 ldi r23, 0x09 ; 9
5860 203c: cc 0c add r12, r12
5861 203e: dd 1c adc r13, r13
5862 2040: ee 1c adc r14, r14
5863 2042: ff 1c adc r15, r15
5864 2044: 7a 95 dec r23
5865 2046: d1 f7 brne .-12 ; 0x203c <disk_write+0x46>
1234 kaklik 5866  
5867 SELECT(); /* CS = L */
1296 kaklik 5868 2048: 2a 98 cbi 0x05, 2 ; 5
1234 kaklik 5869  
1296 kaklik 5870 if (count == 1) { /* Single block write */
5871 204a: 01 30 cpi r16, 0x01 ; 1
5872 204c: 69 f4 brne .+26 ; 0x2068 <disk_write+0x72>
5873 if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */
5874 204e: b7 01 movw r22, r14
5875 2050: a6 01 movw r20, r12
5876 2052: 88 e5 ldi r24, 0x58 ; 88
5877 2054: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5878 2058: 88 23 and r24, r24
5879 205a: 81 f5 brne .+96 ; 0x20bc <disk_write+0xc6>
5880 205c: 6e ef ldi r22, 0xFE ; 254
5881 205e: ce 01 movw r24, r28
5882 2060: 0e 94 18 0e call 0x1c30 ; 0x1c30 <xmit_datablock>
5883 2064: 00 e0 ldi r16, 0x00 ; 0
5884 2066: 27 c0 rjmp .+78 ; 0x20b6 <disk_write+0xc0>
5885 && xmit_datablock(buff, 0xFE))
1234 kaklik 5886 count = 0;
5887 }
1296 kaklik 5888 else { /* Multiple block write */
5889 if (CardType & 2) {
5890 2068: 81 ff sbrs r24, 1
5891 206a: 0e c0 rjmp .+28 ; 0x2088 <disk_write+0x92>
5892 send_cmd(CMD55, 0); send_cmd(CMD23, count); /* ACMD23 */
5893 206c: 40 e0 ldi r20, 0x00 ; 0
5894 206e: 50 e0 ldi r21, 0x00 ; 0
5895 2070: 60 e0 ldi r22, 0x00 ; 0
5896 2072: 70 e0 ldi r23, 0x00 ; 0
5897 2074: 87 e7 ldi r24, 0x77 ; 119
5898 2076: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5899 207a: 40 2f mov r20, r16
5900 207c: 50 e0 ldi r21, 0x00 ; 0
5901 207e: 60 e0 ldi r22, 0x00 ; 0
5902 2080: 70 e0 ldi r23, 0x00 ; 0
5903 2082: 87 e5 ldi r24, 0x57 ; 87
5904 2084: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5905 }
5906 if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
5907 2088: b7 01 movw r22, r14
5908 208a: a6 01 movw r20, r12
5909 208c: 89 e5 ldi r24, 0x59 ; 89
5910 208e: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
5911 2092: 88 23 and r24, r24
5912 2094: 99 f4 brne .+38 ; 0x20bc <disk_write+0xc6>
1234 kaklik 5913 do {
1296 kaklik 5914 if (!xmit_datablock(buff, 0xFC)) break;
5915 2096: 6c ef ldi r22, 0xFC ; 252
5916 2098: ce 01 movw r24, r28
5917 209a: 0e 94 18 0e call 0x1c30 ; 0x1c30 <xmit_datablock>
5918 209e: 88 23 and r24, r24
5919 20a0: 29 f0 breq .+10 ; 0x20ac <disk_write+0xb6>
1234 kaklik 5920 buff += 512;
5921 } while (--count);
1296 kaklik 5922 20a2: 01 50 subi r16, 0x01 ; 1
5923 20a4: 19 f0 breq .+6 ; 0x20ac <disk_write+0xb6>
5924 send_cmd(CMD55, 0); send_cmd(CMD23, count); /* ACMD23 */
5925 }
5926 if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
1234 kaklik 5927 do {
1296 kaklik 5928 if (!xmit_datablock(buff, 0xFC)) break;
1234 kaklik 5929 buff += 512;
1296 kaklik 5930 20a6: c0 50 subi r28, 0x00 ; 0
5931 20a8: de 4f sbci r29, 0xFE ; 254
5932 20aa: f5 cf rjmp .-22 ; 0x2096 <disk_write+0xa0>
1234 kaklik 5933 } while (--count);
1296 kaklik 5934 if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */
5935 20ac: 6d ef ldi r22, 0xFD ; 253
5936 20ae: 80 e0 ldi r24, 0x00 ; 0
5937 20b0: 90 e0 ldi r25, 0x00 ; 0
5938 20b2: 0e 94 18 0e call 0x1c30 ; 0x1c30 <xmit_datablock>
5939 20b6: 88 23 and r24, r24
5940 20b8: 09 f4 brne .+2 ; 0x20bc <disk_write+0xc6>
5941 20ba: 01 e0 ldi r16, 0x01 ; 1
5942 count = 1;
1234 kaklik 5943 }
5944 }
5945  
5946 DESELECT(); /* CS = H */
1296 kaklik 5947 20bc: 2a 9a sbi 0x05, 2 ; 5
1234 kaklik 5948 /*-----------------------------------------------------------------------*/
5949  
5950 static
5951 BYTE rcvr_spi (void)
5952 {
5953 SPDR = 0xFF;
1296 kaklik 5954 20be: 8f ef ldi r24, 0xFF ; 255
5955 20c0: 8e bd out 0x2e, r24 ; 46
1234 kaklik 5956 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 5957 20c2: 0d b4 in r0, 0x2d ; 45
5958 20c4: 07 fe sbrs r0, 7
5959 20c6: fd cf rjmp .-6 ; 0x20c2 <disk_write+0xcc>
1234 kaklik 5960 return SPDR;
1296 kaklik 5961 20c8: 8e b5 in r24, 0x2e ; 46
1234 kaklik 5962 }
5963  
5964 DESELECT(); /* CS = H */
5965 rcvr_spi(); /* Idle (Release DO) */
5966  
5967 return count ? RES_ERROR : RES_OK;
1296 kaklik 5968 20ca: 20 e0 ldi r18, 0x00 ; 0
5969 20cc: 30 e0 ldi r19, 0x00 ; 0
5970 20ce: 00 23 and r16, r16
5971 20d0: 29 f0 breq .+10 ; 0x20dc <disk_write+0xe6>
5972 20d2: 21 e0 ldi r18, 0x01 ; 1
5973 20d4: 30 e0 ldi r19, 0x00 ; 0
5974 20d6: 02 c0 rjmp .+4 ; 0x20dc <disk_write+0xe6>
5975 20d8: 24 e0 ldi r18, 0x04 ; 4
5976 20da: 30 e0 ldi r19, 0x00 ; 0
5977 }
5978 20dc: c9 01 movw r24, r18
5979 20de: df 91 pop r29
5980 20e0: cf 91 pop r28
5981 20e2: 0f 91 pop r16
5982 20e4: ff 90 pop r15
5983 20e6: ef 90 pop r14
5984 20e8: df 90 pop r13
5985 20ea: cf 90 pop r12
5986 20ec: 08 95 ret
1234 kaklik 5987  
1296 kaklik 5988 000020ee <disk_ioctl>:
5989 DRESULT disk_ioctl (
5990 BYTE drv, /* Physical drive nmuber (0) */
5991 BYTE ctrl, /* Control code */
5992 void *buff /* Buffer to send/receive data block */
1234 kaklik 5993 )
5994 {
1296 kaklik 5995 20ee: a0 e1 ldi r26, 0x10 ; 16
5996 20f0: b0 e0 ldi r27, 0x00 ; 0
5997 20f2: ed e7 ldi r30, 0x7D ; 125
5998 20f4: f0 e1 ldi r31, 0x10 ; 16
5999 20f6: 0c 94 d5 14 jmp 0x29aa ; 0x29aa <__prologue_saves__+0x1c>
6000 20fa: 8a 01 movw r16, r20
6001 DRESULT res;
6002 BYTE n, csd[16], *ptr = buff;
6003 WORD csize;
1234 kaklik 6004  
6005  
1296 kaklik 6006 if (drv) return RES_PARERR;
6007 20fc: 88 23 and r24, r24
6008 20fe: 19 f0 breq .+6 ; 0x2106 <disk_ioctl+0x18>
6009 2100: 24 e0 ldi r18, 0x04 ; 4
6010 2102: 30 e0 ldi r19, 0x00 ; 0
6011 2104: e7 c0 rjmp .+462 ; 0x22d4 <disk_ioctl+0x1e6>
6012  
6013 SELECT(); /* CS = L */
6014 2106: 2a 98 cbi 0x05, 2 ; 5
6015  
6016 res = RES_ERROR;
6017 switch (ctrl) {
6018 2108: 63 30 cpi r22, 0x03 ; 3
6019 210a: 09 f4 brne .+2 ; 0x210e <disk_ioctl+0x20>
6020 210c: 7f c0 rjmp .+254 ; 0x220c <disk_ioctl+0x11e>
6021 210e: 64 30 cpi r22, 0x04 ; 4
6022 2110: 28 f4 brcc .+10 ; 0x211c <disk_ioctl+0x2e>
6023 2112: 61 30 cpi r22, 0x01 ; 1
6024 2114: 79 f0 breq .+30 ; 0x2134 <disk_ioctl+0x46>
6025 2116: 62 30 cpi r22, 0x02 ; 2
6026 2118: 51 f4 brne .+20 ; 0x212e <disk_ioctl+0x40>
6027 211a: 72 c0 rjmp .+228 ; 0x2200 <disk_ioctl+0x112>
6028 211c: 6b 30 cpi r22, 0x0B ; 11
6029 211e: 09 f4 brne .+2 ; 0x2122 <disk_ioctl+0x34>
6030 2120: 96 c0 rjmp .+300 ; 0x224e <disk_ioctl+0x160>
6031 2122: 6c 30 cpi r22, 0x0C ; 12
6032 2124: 09 f4 brne .+2 ; 0x2128 <disk_ioctl+0x3a>
6033 2126: aa c0 rjmp .+340 ; 0x227c <disk_ioctl+0x18e>
6034 2128: 6a 30 cpi r22, 0x0A ; 10
6035 212a: 09 f4 brne .+2 ; 0x212e <disk_ioctl+0x40>
6036 212c: 86 c0 rjmp .+268 ; 0x223a <disk_ioctl+0x14c>
6037 212e: 24 e0 ldi r18, 0x04 ; 4
6038 2130: 30 e0 ldi r19, 0x00 ; 0
6039 2132: c6 c0 rjmp .+396 ; 0x22c0 <disk_ioctl+0x1d2>
6040 case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
6041 if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
6042 2134: 40 e0 ldi r20, 0x00 ; 0
6043 2136: 50 e0 ldi r21, 0x00 ; 0
6044 2138: 60 e0 ldi r22, 0x00 ; 0
6045 213a: 70 e0 ldi r23, 0x00 ; 0
6046 213c: 89 e4 ldi r24, 0x49 ; 73
6047 213e: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
6048 2142: 88 23 and r24, r24
6049 2144: 09 f0 breq .+2 ; 0x2148 <disk_ioctl+0x5a>
6050 2146: b7 c0 rjmp .+366 ; 0x22b6 <disk_ioctl+0x1c8>
6051 2148: 60 e1 ldi r22, 0x10 ; 16
6052 214a: 70 e0 ldi r23, 0x00 ; 0
6053 214c: ce 01 movw r24, r28
6054 214e: 01 96 adiw r24, 0x01 ; 1
6055 2150: 0e 94 e3 0d call 0x1bc6 ; 0x1bc6 <rcvr_datablock>
6056 2154: 88 23 and r24, r24
6057 2156: 09 f4 brne .+2 ; 0x215a <disk_ioctl+0x6c>
6058 2158: ae c0 rjmp .+348 ; 0x22b6 <disk_ioctl+0x1c8>
6059 if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
6060 215a: 89 81 ldd r24, Y+1 ; 0x01
6061 215c: 82 95 swap r24
6062 215e: 86 95 lsr r24
6063 2160: 86 95 lsr r24
6064 2162: 83 70 andi r24, 0x03 ; 3
6065 2164: 7a 85 ldd r23, Y+10 ; 0x0a
6066 2166: 49 85 ldd r20, Y+9 ; 0x09
6067 2168: 81 30 cpi r24, 0x01 ; 1
6068 216a: b1 f4 brne .+44 ; 0x2198 <disk_ioctl+0xaa>
6069 csize = csd[9] + ((WORD)csd[8] << 8) + 1;
6070 *(DWORD*)buff = (DWORD)csize << 10;
6071 216c: 87 2f mov r24, r23
6072 216e: 90 e0 ldi r25, 0x00 ; 0
6073 2170: 01 96 adiw r24, 0x01 ; 1
6074 2172: 34 2f mov r19, r20
6075 2174: 20 e0 ldi r18, 0x00 ; 0
6076 2176: 82 0f add r24, r18
6077 2178: 93 1f adc r25, r19
6078 217a: a0 e0 ldi r26, 0x00 ; 0
6079 217c: b0 e0 ldi r27, 0x00 ; 0
6080 217e: 2a e0 ldi r18, 0x0A ; 10
6081 2180: 88 0f add r24, r24
6082 2182: 99 1f adc r25, r25
6083 2184: aa 1f adc r26, r26
6084 2186: bb 1f adc r27, r27
6085 2188: 2a 95 dec r18
6086 218a: d1 f7 brne .-12 ; 0x2180 <disk_ioctl+0x92>
6087 218c: f8 01 movw r30, r16
6088 218e: 80 83 st Z, r24
6089 2190: 91 83 std Z+1, r25 ; 0x01
6090 2192: a2 83 std Z+2, r26 ; 0x02
6091 2194: b3 83 std Z+3, r27 ; 0x03
6092 2196: 92 c0 rjmp .+292 ; 0x22bc <disk_ioctl+0x1ce>
6093 } else { /* MMC or SDC ver 1.XX */
6094 n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
6095 csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
6096 *(DWORD*)buff = (DWORD)csize << (n - 9);
6097 2198: 42 95 swap r20
6098 219a: 46 95 lsr r20
6099 219c: 46 95 lsr r20
6100 219e: 43 70 andi r20, 0x03 ; 3
6101 21a0: 28 85 ldd r18, Y+8 ; 0x08
6102 21a2: 30 e0 ldi r19, 0x00 ; 0
6103 21a4: 22 0f add r18, r18
6104 21a6: 33 1f adc r19, r19
6105 21a8: 22 0f add r18, r18
6106 21aa: 33 1f adc r19, r19
6107 21ac: 24 0f add r18, r20
6108 21ae: 31 1d adc r19, r1
6109 21b0: 2f 5f subi r18, 0xFF ; 255
6110 21b2: 3f 4f sbci r19, 0xFF ; 255
6111 21b4: 8f 81 ldd r24, Y+7 ; 0x07
6112 21b6: 90 e0 ldi r25, 0x00 ; 0
6113 21b8: 83 70 andi r24, 0x03 ; 3
6114 21ba: 90 70 andi r25, 0x00 ; 0
6115 21bc: 98 2f mov r25, r24
6116 21be: 88 27 eor r24, r24
6117 21c0: 99 0f add r25, r25
6118 21c2: 99 0f add r25, r25
6119 21c4: 28 0f add r18, r24
6120 21c6: 39 1f adc r19, r25
6121 21c8: 40 e0 ldi r20, 0x00 ; 0
6122 21ca: 50 e0 ldi r21, 0x00 ; 0
6123 21cc: 8e 81 ldd r24, Y+6 ; 0x06
6124 21ce: 8f 70 andi r24, 0x0F ; 15
6125 21d0: 6b 85 ldd r22, Y+11 ; 0x0b
6126 21d2: 66 1f adc r22, r22
6127 21d4: 66 27 eor r22, r22
6128 21d6: 66 1f adc r22, r22
6129 21d8: 86 0f add r24, r22
6130 21da: 8e 5f subi r24, 0xFE ; 254
6131 21dc: 73 70 andi r23, 0x03 ; 3
6132 21de: 77 0f add r23, r23
6133 21e0: 87 0f add r24, r23
6134 21e2: 90 e0 ldi r25, 0x00 ; 0
6135 21e4: 09 97 sbiw r24, 0x09 ; 9
6136 21e6: 04 c0 rjmp .+8 ; 0x21f0 <disk_ioctl+0x102>
6137 21e8: 22 0f add r18, r18
6138 21ea: 33 1f adc r19, r19
6139 21ec: 44 1f adc r20, r20
6140 21ee: 55 1f adc r21, r21
6141 21f0: 8a 95 dec r24
6142 21f2: d2 f7 brpl .-12 ; 0x21e8 <disk_ioctl+0xfa>
6143 21f4: f8 01 movw r30, r16
6144 21f6: 20 83 st Z, r18
6145 21f8: 31 83 std Z+1, r19 ; 0x01
6146 21fa: 42 83 std Z+2, r20 ; 0x02
6147 21fc: 53 83 std Z+3, r21 ; 0x03
6148 21fe: 5e c0 rjmp .+188 ; 0x22bc <disk_ioctl+0x1ce>
6149 res = RES_OK;
6150 }
6151 break;
6152  
6153 case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
6154 *(WORD*)buff = 512;
6155 2200: 80 e0 ldi r24, 0x00 ; 0
6156 2202: 92 e0 ldi r25, 0x02 ; 2
6157 2204: fa 01 movw r30, r20
6158 2206: 91 83 std Z+1, r25 ; 0x01
6159 2208: 80 83 st Z, r24
6160 220a: 58 c0 rjmp .+176 ; 0x22bc <disk_ioctl+0x1ce>
6161 BYTE wait_ready (void)
6162 {
6163 BYTE res;
6164  
6165  
6166 Timer2 = 50; /* Wait for ready in timeout of 500ms */
6167 220c: 82 e3 ldi r24, 0x32 ; 50
6168 220e: 80 93 16 01 sts 0x0116, r24
1234 kaklik 6169 /*-----------------------------------------------------------------------*/
6170  
6171 static
6172 BYTE rcvr_spi (void)
6173 {
6174 SPDR = 0xFF;
1296 kaklik 6175 2212: 8f ef ldi r24, 0xFF ; 255
6176 2214: 8e bd out 0x2e, r24 ; 46
1234 kaklik 6177 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 6178 2216: 0d b4 in r0, 0x2d ; 45
6179 2218: 07 fe sbrs r0, 7
6180 221a: fd cf rjmp .-6 ; 0x2216 <disk_ioctl+0x128>
1234 kaklik 6181 return SPDR;
1296 kaklik 6182 221c: 8e b5 in r24, 0x2e ; 46
6183 /*-----------------------------------------------------------------------*/
1234 kaklik 6184  
1296 kaklik 6185 static
6186 BYTE rcvr_spi (void)
6187 {
6188 SPDR = 0xFF;
6189 221e: 9f ef ldi r25, 0xFF ; 255
6190 2220: 9e bd out 0x2e, r25 ; 46
6191 loop_until_bit_is_set(SPSR, SPIF);
6192 2222: 0d b4 in r0, 0x2d ; 45
6193 2224: 07 fe sbrs r0, 7
6194 2226: fd cf rjmp .-6 ; 0x2222 <disk_ioctl+0x134>
6195 return SPDR;
6196 2228: 8e b5 in r24, 0x2e ; 46
1234 kaklik 6197  
1296 kaklik 6198 Timer2 = 50; /* Wait for ready in timeout of 500ms */
6199 rcvr_spi();
6200 do
6201 res = rcvr_spi();
6202 while ((res != 0xFF) && Timer2);
6203 222a: 8f 3f cpi r24, 0xFF ; 255
6204 222c: 09 f4 brne .+2 ; 0x2230 <disk_ioctl+0x142>
6205 222e: 46 c0 rjmp .+140 ; 0x22bc <disk_ioctl+0x1ce>
6206 2230: 80 91 16 01 lds r24, 0x0116
6207 2234: 88 23 and r24, r24
6208 2236: a1 f7 brne .-24 ; 0x2220 <disk_ioctl+0x132>
6209 2238: 3e c0 rjmp .+124 ; 0x22b6 <disk_ioctl+0x1c8>
6210 if (wait_ready() == 0xFF)
6211 res = RES_OK;
6212 break;
1234 kaklik 6213  
1296 kaklik 6214 case MMC_GET_CSD : /* Receive CSD as a data block (16 bytes) */
6215 if (Stat & STA_NOINIT) return RES_NOTRDY;
6216 223a: 80 91 0b 01 lds r24, 0x010B
6217 223e: 80 fd sbrc r24, 0
6218 2240: 47 c0 rjmp .+142 ; 0x22d0 <disk_ioctl+0x1e2>
6219 if ((send_cmd(CMD9, 0) == 0) /* READ_CSD */
6220 2242: 40 e0 ldi r20, 0x00 ; 0
6221 2244: 50 e0 ldi r21, 0x00 ; 0
6222 2246: 60 e0 ldi r22, 0x00 ; 0
6223 2248: 70 e0 ldi r23, 0x00 ; 0
6224 224a: 89 e4 ldi r24, 0x49 ; 73
6225 224c: 09 c0 rjmp .+18 ; 0x2260 <disk_ioctl+0x172>
6226 && rcvr_datablock(ptr, 16))
6227 res = RES_OK;
6228 break;
1234 kaklik 6229  
1296 kaklik 6230 case MMC_GET_CID : /* Receive CID as a data block (16 bytes) */
6231 if (Stat & STA_NOINIT) return RES_NOTRDY;
6232 224e: 80 91 0b 01 lds r24, 0x010B
6233 2252: 80 fd sbrc r24, 0
6234 2254: 3d c0 rjmp .+122 ; 0x22d0 <disk_ioctl+0x1e2>
6235 if ((send_cmd(CMD10, 0) == 0) /* READ_CID */
6236 2256: 40 e0 ldi r20, 0x00 ; 0
6237 2258: 50 e0 ldi r21, 0x00 ; 0
6238 225a: 60 e0 ldi r22, 0x00 ; 0
6239 225c: 70 e0 ldi r23, 0x00 ; 0
6240 225e: 8a e4 ldi r24, 0x4A ; 74
6241 2260: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
6242 2264: 88 23 and r24, r24
6243 2266: 39 f5 brne .+78 ; 0x22b6 <disk_ioctl+0x1c8>
6244 2268: 60 e1 ldi r22, 0x10 ; 16
6245 226a: 70 e0 ldi r23, 0x00 ; 0
6246 226c: c8 01 movw r24, r16
6247 226e: 0e 94 e3 0d call 0x1bc6 ; 0x1bc6 <rcvr_datablock>
6248 2272: 20 e0 ldi r18, 0x00 ; 0
6249 2274: 30 e0 ldi r19, 0x00 ; 0
6250 2276: 88 23 and r24, r24
6251 2278: 19 f5 brne .+70 ; 0x22c0 <disk_ioctl+0x1d2>
6252 227a: 1d c0 rjmp .+58 ; 0x22b6 <disk_ioctl+0x1c8>
6253 && rcvr_datablock(ptr, 16))
6254 res = RES_OK;
6255 break;
6256  
6257 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
6258 if (Stat & STA_NOINIT) return RES_NOTRDY;
6259 227c: 80 91 0b 01 lds r24, 0x010B
6260 2280: 80 fd sbrc r24, 0
6261 2282: 26 c0 rjmp .+76 ; 0x22d0 <disk_ioctl+0x1e2>
6262 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
6263 2284: 40 e0 ldi r20, 0x00 ; 0
6264 2286: 50 e0 ldi r21, 0x00 ; 0
6265 2288: 60 e0 ldi r22, 0x00 ; 0
6266 228a: 70 e0 ldi r23, 0x00 ; 0
6267 228c: 8a e7 ldi r24, 0x7A ; 122
6268 228e: 0e 94 60 0e call 0x1cc0 ; 0x1cc0 <send_cmd>
6269 2292: 88 23 and r24, r24
6270 2294: 81 f4 brne .+32 ; 0x22b6 <disk_ioctl+0x1c8>
6271 2296: f8 01 movw r30, r16
1234 kaklik 6272 /*-----------------------------------------------------------------------*/
6273  
6274 static
6275 BYTE rcvr_spi (void)
6276 {
6277 SPDR = 0xFF;
1296 kaklik 6278 2298: 9f ef ldi r25, 0xFF ; 255
6279 break;
6280  
6281 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
6282 if (Stat & STA_NOINIT) return RES_NOTRDY;
6283 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
6284 for (n = 0; n < 4; n++)
6285 229a: 98 01 movw r18, r16
6286 229c: 2d 5f subi r18, 0xFD ; 253
6287 229e: 3f 4f sbci r19, 0xFF ; 255
1234 kaklik 6288 /*-----------------------------------------------------------------------*/
6289  
6290 static
6291 BYTE rcvr_spi (void)
6292 {
6293 SPDR = 0xFF;
1296 kaklik 6294 22a0: 9e bd out 0x2e, r25 ; 46
1234 kaklik 6295 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 6296 22a2: 0d b4 in r0, 0x2d ; 45
6297 22a4: 07 fe sbrs r0, 7
6298 22a6: fd cf rjmp .-6 ; 0x22a2 <disk_ioctl+0x1b4>
1234 kaklik 6299 return SPDR;
1296 kaklik 6300 22a8: 8e b5 in r24, 0x2e ; 46
6301  
6302 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
6303 if (Stat & STA_NOINIT) return RES_NOTRDY;
6304 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
6305 for (n = 0; n < 4; n++)
6306 *ptr++ = rcvr_spi();
6307 22aa: 80 83 st Z, r24
6308 break;
6309  
6310 case MMC_GET_OCR : /* Receive OCR as an R3 resp (4 bytes) */
6311 if (Stat & STA_NOINIT) return RES_NOTRDY;
6312 if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
6313 for (n = 0; n < 4; n++)
6314 22ac: e2 17 cp r30, r18
6315 22ae: f3 07 cpc r31, r19
6316 22b0: 29 f0 breq .+10 ; 0x22bc <disk_ioctl+0x1ce>
6317 *ptr++ = rcvr_spi();
6318 22b2: 31 96 adiw r30, 0x01 ; 1
6319 22b4: f5 cf rjmp .-22 ; 0x22a0 <disk_ioctl+0x1b2>
6320 22b6: 21 e0 ldi r18, 0x01 ; 1
6321 22b8: 30 e0 ldi r19, 0x00 ; 0
6322 22ba: 02 c0 rjmp .+4 ; 0x22c0 <disk_ioctl+0x1d2>
6323 22bc: 20 e0 ldi r18, 0x00 ; 0
6324 22be: 30 e0 ldi r19, 0x00 ; 0
6325  
6326 default:
6327 res = RES_PARERR;
1234 kaklik 6328 }
1296 kaklik 6329  
1234 kaklik 6330 DESELECT(); /* CS = H */
1296 kaklik 6331 22c0: 2a 9a sbi 0x05, 2 ; 5
1234 kaklik 6332 /*-----------------------------------------------------------------------*/
6333  
6334 static
6335 BYTE rcvr_spi (void)
6336 {
6337 SPDR = 0xFF;
1296 kaklik 6338 22c2: 8f ef ldi r24, 0xFF ; 255
6339 22c4: 8e bd out 0x2e, r24 ; 46
1234 kaklik 6340 loop_until_bit_is_set(SPSR, SPIF);
1296 kaklik 6341 22c6: 0d b4 in r0, 0x2d ; 45
6342 22c8: 07 fe sbrs r0, 7
6343 22ca: fd cf rjmp .-6 ; 0x22c6 <disk_ioctl+0x1d8>
1234 kaklik 6344 return SPDR;
1296 kaklik 6345 22cc: 8e b5 in r24, 0x2e ; 46
6346 22ce: 02 c0 rjmp .+4 ; 0x22d4 <disk_ioctl+0x1e6>
1234 kaklik 6347 }
1296 kaklik 6348  
1234 kaklik 6349 DESELECT(); /* CS = H */
6350 rcvr_spi(); /* Idle (Release DO) */
6351  
1296 kaklik 6352 return res;
6353 22d0: 23 e0 ldi r18, 0x03 ; 3
6354 22d2: 30 e0 ldi r19, 0x00 ; 0
6355 }
6356 22d4: c9 01 movw r24, r18
6357 22d6: 60 96 adiw r28, 0x10 ; 16
6358 22d8: e4 e0 ldi r30, 0x04 ; 4
6359 22da: 0c 94 f1 14 jmp 0x29e2 ; 0x29e2 <__epilogue_restores__+0x1c>
1234 kaklik 6360  
1296 kaklik 6361 000022de <disk_timerproc>:
6362 /* Device timer interrupt procedure */
6363 /* This must be called in period of 10ms */
6364 /* (Platform dependent) */
1234 kaklik 6365  
1296 kaklik 6366 void disk_timerproc (void)
6367 {
6368 22de: 80 91 15 01 lds r24, 0x0115
6369 static BYTE pv;
6370 BYTE n, s;
1234 kaklik 6371  
6372  
1296 kaklik 6373 n = Timer1; /* 100Hz decrement timer */
6374 if (n) Timer1 = --n;
6375 22e2: 88 23 and r24, r24
6376 22e4: 19 f0 breq .+6 ; 0x22ec <disk_timerproc+0xe>
6377 22e6: 81 50 subi r24, 0x01 ; 1
6378 22e8: 80 93 15 01 sts 0x0115, r24
6379 n = Timer2;
6380 22ec: 80 91 16 01 lds r24, 0x0116
6381 if (n) Timer2 = --n;
6382 22f0: 88 23 and r24, r24
6383 22f2: 19 f0 breq .+6 ; 0x22fa <disk_timerproc+0x1c>
6384 22f4: 81 50 subi r24, 0x01 ; 1
6385 22f6: 80 93 16 01 sts 0x0116, r24
1234 kaklik 6386  
1296 kaklik 6387 n = pv;
6388 22fa: 90 91 14 01 lds r25, 0x0114
6389 pv = SOCKPORT & (SOCKINS); /* Sample socket switch */
6390 22fe: 83 b1 in r24, 0x03 ; 3
6391 2300: 81 70 andi r24, 0x01 ; 1
6392 2302: 80 93 14 01 sts 0x0114, r24
1234 kaklik 6393  
1296 kaklik 6394 if (n == pv) { /* Have contacts stabled? */
6395 2306: 98 17 cp r25, r24
6396 2308: 49 f4 brne .+18 ; 0x231c <disk_timerproc+0x3e>
6397 s = Stat;
6398 230a: 80 91 0b 01 lds r24, 0x010B
6399 if (pv & SOCKINS) /* INS = H (Socket empty) */
6400 230e: 90 ff sbrs r25, 0
6401 2310: 02 c0 rjmp .+4 ; 0x2316 <disk_timerproc+0x38>
6402 s |= (STA_NODISK | STA_NOINIT);
6403 2312: 83 60 ori r24, 0x03 ; 3
6404 2314: 01 c0 rjmp .+2 ; 0x2318 <disk_timerproc+0x3a>
6405 else /* INS = L (Card inserted) */
6406 s &= ~STA_NODISK;
6407 2316: 8d 7f andi r24, 0xFD ; 253
1234 kaklik 6408  
1296 kaklik 6409 Stat = s;
6410 2318: 80 93 0b 01 sts 0x010B, r24
6411 231c: 08 95 ret
1234 kaklik 6412  
1296 kaklik 6413 0000231e <strcpy_P>:
6414 231e: fb 01 movw r30, r22
6415 2320: dc 01 movw r26, r24
6416 2322: 05 90 lpm r0, Z+
6417 2324: 0d 92 st X+, r0
6418 2326: 00 20 and r0, r0
6419 2328: e1 f7 brne .-8 ; 0x2322 <strcpy_P+0x4>
6420 232a: 08 95 ret
1234 kaklik 6421  
1296 kaklik 6422 0000232c <memcmp>:
6423 232c: fb 01 movw r30, r22
6424 232e: dc 01 movw r26, r24
6425 2330: 04 c0 rjmp .+8 ; 0x233a <memcmp+0xe>
6426 2332: 8d 91 ld r24, X+
6427 2334: 01 90 ld r0, Z+
6428 2336: 80 19 sub r24, r0
6429 2338: 21 f4 brne .+8 ; 0x2342 <memcmp+0x16>
6430 233a: 41 50 subi r20, 0x01 ; 1
6431 233c: 50 40 sbci r21, 0x00 ; 0
6432 233e: c8 f7 brcc .-14 ; 0x2332 <memcmp+0x6>
6433 2340: 88 1b sub r24, r24
6434 2342: 99 0b sbc r25, r25
6435 2344: 08 95 ret
1234 kaklik 6436  
1296 kaklik 6437 00002346 <memcpy>:
6438 2346: fb 01 movw r30, r22
6439 2348: dc 01 movw r26, r24
6440 234a: 02 c0 rjmp .+4 ; 0x2350 <memcpy+0xa>
6441 234c: 01 90 ld r0, Z+
6442 234e: 0d 92 st X+, r0
6443 2350: 41 50 subi r20, 0x01 ; 1
6444 2352: 50 40 sbci r21, 0x00 ; 0
6445 2354: d8 f7 brcc .-10 ; 0x234c <memcpy+0x6>
6446 2356: 08 95 ret
1234 kaklik 6447  
1296 kaklik 6448 00002358 <memset>:
6449 2358: dc 01 movw r26, r24
6450 235a: 01 c0 rjmp .+2 ; 0x235e <memset+0x6>
6451 235c: 6d 93 st X+, r22
6452 235e: 41 50 subi r20, 0x01 ; 1
6453 2360: 50 40 sbci r21, 0x00 ; 0
6454 2362: e0 f7 brcc .-8 ; 0x235c <memset+0x4>
6455 2364: 08 95 ret
1234 kaklik 6456  
1296 kaklik 6457 00002366 <itoa>:
6458 2366: fb 01 movw r30, r22
6459 2368: 9f 01 movw r18, r30
6460 236a: e8 94 clt
6461 236c: 42 30 cpi r20, 0x02 ; 2
6462 236e: c4 f0 brlt .+48 ; 0x23a0 <itoa+0x3a>
6463 2370: 45 32 cpi r20, 0x25 ; 37
6464 2372: b4 f4 brge .+44 ; 0x23a0 <itoa+0x3a>
6465 2374: 4a 30 cpi r20, 0x0A ; 10
6466 2376: 29 f4 brne .+10 ; 0x2382 <itoa+0x1c>
6467 2378: 97 fb bst r25, 7
6468 237a: 1e f4 brtc .+6 ; 0x2382 <itoa+0x1c>
6469 237c: 90 95 com r25
6470 237e: 81 95 neg r24
6471 2380: 9f 4f sbci r25, 0xFF ; 255
6472 2382: 64 2f mov r22, r20
6473 2384: 77 27 eor r23, r23
6474 2386: 0e 94 fe 14 call 0x29fc ; 0x29fc <__udivmodhi4>
6475 238a: 80 5d subi r24, 0xD0 ; 208
6476 238c: 8a 33 cpi r24, 0x3A ; 58
6477 238e: 0c f0 brlt .+2 ; 0x2392 <itoa+0x2c>
6478 2390: 89 5d subi r24, 0xD9 ; 217
6479 2392: 81 93 st Z+, r24
6480 2394: cb 01 movw r24, r22
6481 2396: 00 97 sbiw r24, 0x00 ; 0
6482 2398: a1 f7 brne .-24 ; 0x2382 <itoa+0x1c>
6483 239a: 16 f4 brtc .+4 ; 0x23a0 <itoa+0x3a>
6484 239c: 5d e2 ldi r21, 0x2D ; 45
6485 239e: 51 93 st Z+, r21
6486 23a0: 10 82 st Z, r1
6487 23a2: c9 01 movw r24, r18
6488 23a4: 0c 94 ec 13 jmp 0x27d8 ; 0x27d8 <strrev>
1234 kaklik 6489  
1296 kaklik 6490 000023a8 <sprintf>:
6491 23a8: ae e0 ldi r26, 0x0E ; 14
6492 23aa: b0 e0 ldi r27, 0x00 ; 0
6493 23ac: ea ed ldi r30, 0xDA ; 218
6494 23ae: f1 e1 ldi r31, 0x11 ; 17
6495 23b0: 0c 94 d5 14 jmp 0x29aa ; 0x29aa <__prologue_saves__+0x1c>
6496 23b4: 0d 89 ldd r16, Y+21 ; 0x15
6497 23b6: 1e 89 ldd r17, Y+22 ; 0x16
6498 23b8: 86 e0 ldi r24, 0x06 ; 6
6499 23ba: 8c 83 std Y+4, r24 ; 0x04
6500 23bc: 1a 83 std Y+2, r17 ; 0x02
6501 23be: 09 83 std Y+1, r16 ; 0x01
6502 23c0: 8f ef ldi r24, 0xFF ; 255
6503 23c2: 9f e7 ldi r25, 0x7F ; 127
6504 23c4: 9e 83 std Y+6, r25 ; 0x06
6505 23c6: 8d 83 std Y+5, r24 ; 0x05
6506 23c8: ce 01 movw r24, r28
6507 23ca: 49 96 adiw r24, 0x19 ; 25
6508 23cc: ac 01 movw r20, r24
6509 23ce: 6f 89 ldd r22, Y+23 ; 0x17
6510 23d0: 78 8d ldd r23, Y+24 ; 0x18
6511 23d2: ce 01 movw r24, r28
6512 23d4: 01 96 adiw r24, 0x01 ; 1
6513 23d6: 0e 94 f7 11 call 0x23ee ; 0x23ee <vfprintf>
6514 23da: 2f 81 ldd r18, Y+7 ; 0x07
6515 23dc: 38 85 ldd r19, Y+8 ; 0x08
6516 23de: 02 0f add r16, r18
6517 23e0: 13 1f adc r17, r19
6518 23e2: f8 01 movw r30, r16
6519 23e4: 10 82 st Z, r1
6520 23e6: 2e 96 adiw r28, 0x0e ; 14
6521 23e8: e4 e0 ldi r30, 0x04 ; 4
6522 23ea: 0c 94 f1 14 jmp 0x29e2 ; 0x29e2 <__epilogue_restores__+0x1c>
1234 kaklik 6523  
1296 kaklik 6524 000023ee <vfprintf>:
6525 23ee: ab e0 ldi r26, 0x0B ; 11
6526 23f0: b0 e0 ldi r27, 0x00 ; 0
6527 23f2: ed ef ldi r30, 0xFD ; 253
6528 23f4: f1 e1 ldi r31, 0x11 ; 17
6529 23f6: 0c 94 c7 14 jmp 0x298e ; 0x298e <__prologue_saves__>
6530 23fa: 3c 01 movw r6, r24
6531 23fc: 2b 01 movw r4, r22
6532 23fe: 5a 01 movw r10, r20
6533 2400: fc 01 movw r30, r24
6534 2402: 17 82 std Z+7, r1 ; 0x07
6535 2404: 16 82 std Z+6, r1 ; 0x06
6536 2406: 83 81 ldd r24, Z+3 ; 0x03
6537 2408: 81 fd sbrc r24, 1
6538 240a: 03 c0 rjmp .+6 ; 0x2412 <vfprintf+0x24>
6539 240c: 6f ef ldi r22, 0xFF ; 255
6540 240e: 7f ef ldi r23, 0xFF ; 255
6541 2410: c8 c1 rjmp .+912 ; 0x27a2 <vfprintf+0x3b4>
6542 2412: 9a e0 ldi r25, 0x0A ; 10
6543 2414: 89 2e mov r8, r25
6544 2416: 1e 01 movw r2, r28
6545 2418: 08 94 sec
6546 241a: 21 1c adc r2, r1
6547 241c: 31 1c adc r3, r1
6548 241e: f3 01 movw r30, r6
6549 2420: 23 81 ldd r18, Z+3 ; 0x03
6550 2422: f2 01 movw r30, r4
6551 2424: 23 fd sbrc r18, 3
6552 2426: 85 91 lpm r24, Z+
6553 2428: 23 ff sbrs r18, 3
6554 242a: 81 91 ld r24, Z+
6555 242c: 2f 01 movw r4, r30
6556 242e: 88 23 and r24, r24
6557 2430: 09 f4 brne .+2 ; 0x2434 <vfprintf+0x46>
6558 2432: b4 c1 rjmp .+872 ; 0x279c <vfprintf+0x3ae>
6559 2434: 85 32 cpi r24, 0x25 ; 37
6560 2436: 39 f4 brne .+14 ; 0x2446 <vfprintf+0x58>
6561 2438: 23 fd sbrc r18, 3
6562 243a: 85 91 lpm r24, Z+
6563 243c: 23 ff sbrs r18, 3
6564 243e: 81 91 ld r24, Z+
6565 2440: 2f 01 movw r4, r30
6566 2442: 85 32 cpi r24, 0x25 ; 37
6567 2444: 29 f4 brne .+10 ; 0x2450 <vfprintf+0x62>
6568 2446: b3 01 movw r22, r6
6569 2448: 90 e0 ldi r25, 0x00 ; 0
6570 244a: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6571 244e: e7 cf rjmp .-50 ; 0x241e <vfprintf+0x30>
6572 2450: 98 2f mov r25, r24
6573 2452: dd 24 eor r13, r13
6574 2454: cc 24 eor r12, r12
6575 2456: 99 24 eor r9, r9
6576 2458: ff e1 ldi r31, 0x1F ; 31
6577 245a: fd 15 cp r31, r13
6578 245c: d0 f0 brcs .+52 ; 0x2492 <vfprintf+0xa4>
6579 245e: 9b 32 cpi r25, 0x2B ; 43
6580 2460: 69 f0 breq .+26 ; 0x247c <vfprintf+0x8e>
6581 2462: 9c 32 cpi r25, 0x2C ; 44
6582 2464: 28 f4 brcc .+10 ; 0x2470 <vfprintf+0x82>
6583 2466: 90 32 cpi r25, 0x20 ; 32
6584 2468: 59 f0 breq .+22 ; 0x2480 <vfprintf+0x92>
6585 246a: 93 32 cpi r25, 0x23 ; 35
6586 246c: 91 f4 brne .+36 ; 0x2492 <vfprintf+0xa4>
6587 246e: 0e c0 rjmp .+28 ; 0x248c <vfprintf+0x9e>
6588 2470: 9d 32 cpi r25, 0x2D ; 45
6589 2472: 49 f0 breq .+18 ; 0x2486 <vfprintf+0x98>
6590 2474: 90 33 cpi r25, 0x30 ; 48
6591 2476: 69 f4 brne .+26 ; 0x2492 <vfprintf+0xa4>
6592 2478: 41 e0 ldi r20, 0x01 ; 1
6593 247a: 24 c0 rjmp .+72 ; 0x24c4 <vfprintf+0xd6>
6594 247c: 52 e0 ldi r21, 0x02 ; 2
6595 247e: d5 2a or r13, r21
6596 2480: 84 e0 ldi r24, 0x04 ; 4
6597 2482: d8 2a or r13, r24
6598 2484: 28 c0 rjmp .+80 ; 0x24d6 <vfprintf+0xe8>
6599 2486: 98 e0 ldi r25, 0x08 ; 8
6600 2488: d9 2a or r13, r25
6601 248a: 25 c0 rjmp .+74 ; 0x24d6 <vfprintf+0xe8>
6602 248c: e0 e1 ldi r30, 0x10 ; 16
6603 248e: de 2a or r13, r30
6604 2490: 22 c0 rjmp .+68 ; 0x24d6 <vfprintf+0xe8>
6605 2492: d7 fc sbrc r13, 7
6606 2494: 29 c0 rjmp .+82 ; 0x24e8 <vfprintf+0xfa>
6607 2496: 89 2f mov r24, r25
6608 2498: 80 53 subi r24, 0x30 ; 48
6609 249a: 8a 30 cpi r24, 0x0A ; 10
6610 249c: 70 f4 brcc .+28 ; 0x24ba <vfprintf+0xcc>
6611 249e: d6 fe sbrs r13, 6
6612 24a0: 05 c0 rjmp .+10 ; 0x24ac <vfprintf+0xbe>
6613 24a2: 98 9c mul r9, r8
6614 24a4: 90 2c mov r9, r0
6615 24a6: 11 24 eor r1, r1
6616 24a8: 98 0e add r9, r24
6617 24aa: 15 c0 rjmp .+42 ; 0x24d6 <vfprintf+0xe8>
6618 24ac: c8 9c mul r12, r8
6619 24ae: c0 2c mov r12, r0
6620 24b0: 11 24 eor r1, r1
6621 24b2: c8 0e add r12, r24
6622 24b4: f0 e2 ldi r31, 0x20 ; 32
6623 24b6: df 2a or r13, r31
6624 24b8: 0e c0 rjmp .+28 ; 0x24d6 <vfprintf+0xe8>
6625 24ba: 9e 32 cpi r25, 0x2E ; 46
6626 24bc: 29 f4 brne .+10 ; 0x24c8 <vfprintf+0xda>
6627 24be: d6 fc sbrc r13, 6
6628 24c0: 6d c1 rjmp .+730 ; 0x279c <vfprintf+0x3ae>
6629 24c2: 40 e4 ldi r20, 0x40 ; 64
6630 24c4: d4 2a or r13, r20
6631 24c6: 07 c0 rjmp .+14 ; 0x24d6 <vfprintf+0xe8>
6632 24c8: 9c 36 cpi r25, 0x6C ; 108
6633 24ca: 19 f4 brne .+6 ; 0x24d2 <vfprintf+0xe4>
6634 24cc: 50 e8 ldi r21, 0x80 ; 128
6635 24ce: d5 2a or r13, r21
6636 24d0: 02 c0 rjmp .+4 ; 0x24d6 <vfprintf+0xe8>
6637 24d2: 98 36 cpi r25, 0x68 ; 104
6638 24d4: 49 f4 brne .+18 ; 0x24e8 <vfprintf+0xfa>
6639 24d6: f2 01 movw r30, r4
6640 24d8: 23 fd sbrc r18, 3
6641 24da: 95 91 lpm r25, Z+
6642 24dc: 23 ff sbrs r18, 3
6643 24de: 91 91 ld r25, Z+
6644 24e0: 2f 01 movw r4, r30
6645 24e2: 99 23 and r25, r25
6646 24e4: 09 f0 breq .+2 ; 0x24e8 <vfprintf+0xfa>
6647 24e6: b8 cf rjmp .-144 ; 0x2458 <vfprintf+0x6a>
6648 24e8: 89 2f mov r24, r25
6649 24ea: 85 54 subi r24, 0x45 ; 69
6650 24ec: 83 30 cpi r24, 0x03 ; 3
6651 24ee: 18 f0 brcs .+6 ; 0x24f6 <vfprintf+0x108>
6652 24f0: 80 52 subi r24, 0x20 ; 32
6653 24f2: 83 30 cpi r24, 0x03 ; 3
6654 24f4: 38 f4 brcc .+14 ; 0x2504 <vfprintf+0x116>
6655 24f6: 44 e0 ldi r20, 0x04 ; 4
6656 24f8: 50 e0 ldi r21, 0x00 ; 0
6657 24fa: a4 0e add r10, r20
6658 24fc: b5 1e adc r11, r21
6659 24fe: 5f e3 ldi r21, 0x3F ; 63
6660 2500: 59 83 std Y+1, r21 ; 0x01
6661 2502: 0f c0 rjmp .+30 ; 0x2522 <vfprintf+0x134>
6662 2504: 93 36 cpi r25, 0x63 ; 99
6663 2506: 31 f0 breq .+12 ; 0x2514 <vfprintf+0x126>
6664 2508: 93 37 cpi r25, 0x73 ; 115
6665 250a: 79 f0 breq .+30 ; 0x252a <vfprintf+0x13c>
6666 250c: 93 35 cpi r25, 0x53 ; 83
6667 250e: 09 f0 breq .+2 ; 0x2512 <vfprintf+0x124>
6668 2510: 56 c0 rjmp .+172 ; 0x25be <vfprintf+0x1d0>
6669 2512: 20 c0 rjmp .+64 ; 0x2554 <vfprintf+0x166>
6670 2514: f5 01 movw r30, r10
6671 2516: 80 81 ld r24, Z
6672 2518: 89 83 std Y+1, r24 ; 0x01
6673 251a: 42 e0 ldi r20, 0x02 ; 2
6674 251c: 50 e0 ldi r21, 0x00 ; 0
6675 251e: a4 0e add r10, r20
6676 2520: b5 1e adc r11, r21
6677 2522: 71 01 movw r14, r2
6678 2524: 01 e0 ldi r16, 0x01 ; 1
6679 2526: 10 e0 ldi r17, 0x00 ; 0
6680 2528: 12 c0 rjmp .+36 ; 0x254e <vfprintf+0x160>
6681 252a: f5 01 movw r30, r10
6682 252c: e0 80 ld r14, Z
6683 252e: f1 80 ldd r15, Z+1 ; 0x01
6684 2530: d6 fc sbrc r13, 6
6685 2532: 03 c0 rjmp .+6 ; 0x253a <vfprintf+0x14c>
6686 2534: 6f ef ldi r22, 0xFF ; 255
6687 2536: 7f ef ldi r23, 0xFF ; 255
6688 2538: 02 c0 rjmp .+4 ; 0x253e <vfprintf+0x150>
6689 253a: 69 2d mov r22, r9
6690 253c: 70 e0 ldi r23, 0x00 ; 0
6691 253e: 42 e0 ldi r20, 0x02 ; 2
6692 2540: 50 e0 ldi r21, 0x00 ; 0
6693 2542: a4 0e add r10, r20
6694 2544: b5 1e adc r11, r21
6695 2546: c7 01 movw r24, r14
6696 2548: 0e 94 e1 13 call 0x27c2 ; 0x27c2 <strnlen>
6697 254c: 8c 01 movw r16, r24
6698 254e: 5f e7 ldi r21, 0x7F ; 127
6699 2550: d5 22 and r13, r21
6700 2552: 14 c0 rjmp .+40 ; 0x257c <vfprintf+0x18e>
6701 2554: f5 01 movw r30, r10
6702 2556: e0 80 ld r14, Z
6703 2558: f1 80 ldd r15, Z+1 ; 0x01
6704 255a: d6 fc sbrc r13, 6
6705 255c: 03 c0 rjmp .+6 ; 0x2564 <vfprintf+0x176>
6706 255e: 6f ef ldi r22, 0xFF ; 255
6707 2560: 7f ef ldi r23, 0xFF ; 255
6708 2562: 02 c0 rjmp .+4 ; 0x2568 <vfprintf+0x17a>
6709 2564: 69 2d mov r22, r9
6710 2566: 70 e0 ldi r23, 0x00 ; 0
6711 2568: 42 e0 ldi r20, 0x02 ; 2
6712 256a: 50 e0 ldi r21, 0x00 ; 0
6713 256c: a4 0e add r10, r20
6714 256e: b5 1e adc r11, r21
6715 2570: c7 01 movw r24, r14
6716 2572: 0e 94 d6 13 call 0x27ac ; 0x27ac <strnlen_P>
6717 2576: 8c 01 movw r16, r24
6718 2578: 50 e8 ldi r21, 0x80 ; 128
6719 257a: d5 2a or r13, r21
6720 257c: d3 fe sbrs r13, 3
6721 257e: 07 c0 rjmp .+14 ; 0x258e <vfprintf+0x1a0>
6722 2580: 1a c0 rjmp .+52 ; 0x25b6 <vfprintf+0x1c8>
6723 2582: b3 01 movw r22, r6
6724 2584: 80 e2 ldi r24, 0x20 ; 32
6725 2586: 90 e0 ldi r25, 0x00 ; 0
6726 2588: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6727 258c: ca 94 dec r12
6728 258e: 8c 2d mov r24, r12
6729 2590: 90 e0 ldi r25, 0x00 ; 0
6730 2592: 08 17 cp r16, r24
6731 2594: 19 07 cpc r17, r25
6732 2596: a8 f3 brcs .-22 ; 0x2582 <vfprintf+0x194>
6733 2598: 0e c0 rjmp .+28 ; 0x25b6 <vfprintf+0x1c8>
6734 259a: f7 01 movw r30, r14
6735 259c: d7 fc sbrc r13, 7
6736 259e: 85 91 lpm r24, Z+
6737 25a0: d7 fe sbrs r13, 7
6738 25a2: 81 91 ld r24, Z+
6739 25a4: 7f 01 movw r14, r30
6740 25a6: b3 01 movw r22, r6
6741 25a8: 90 e0 ldi r25, 0x00 ; 0
6742 25aa: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6743 25ae: c1 10 cpse r12, r1
6744 25b0: ca 94 dec r12
6745 25b2: 01 50 subi r16, 0x01 ; 1
6746 25b4: 10 40 sbci r17, 0x00 ; 0
6747 25b6: 01 15 cp r16, r1
6748 25b8: 11 05 cpc r17, r1
6749 25ba: 79 f7 brne .-34 ; 0x259a <vfprintf+0x1ac>
6750 25bc: ec c0 rjmp .+472 ; 0x2796 <vfprintf+0x3a8>
6751 25be: 94 36 cpi r25, 0x64 ; 100
6752 25c0: 11 f0 breq .+4 ; 0x25c6 <vfprintf+0x1d8>
6753 25c2: 99 36 cpi r25, 0x69 ; 105
6754 25c4: 71 f5 brne .+92 ; 0x2622 <vfprintf+0x234>
6755 25c6: d7 fe sbrs r13, 7
6756 25c8: 08 c0 rjmp .+16 ; 0x25da <vfprintf+0x1ec>
6757 25ca: f5 01 movw r30, r10
6758 25cc: e0 80 ld r14, Z
6759 25ce: f1 80 ldd r15, Z+1 ; 0x01
6760 25d0: 02 81 ldd r16, Z+2 ; 0x02
6761 25d2: 13 81 ldd r17, Z+3 ; 0x03
6762 25d4: 44 e0 ldi r20, 0x04 ; 4
6763 25d6: 50 e0 ldi r21, 0x00 ; 0
6764 25d8: 0a c0 rjmp .+20 ; 0x25ee <vfprintf+0x200>
6765 25da: f5 01 movw r30, r10
6766 25dc: 80 81 ld r24, Z
6767 25de: 91 81 ldd r25, Z+1 ; 0x01
6768 25e0: 7c 01 movw r14, r24
6769 25e2: 00 27 eor r16, r16
6770 25e4: f7 fc sbrc r15, 7
6771 25e6: 00 95 com r16
6772 25e8: 10 2f mov r17, r16
6773 25ea: 42 e0 ldi r20, 0x02 ; 2
6774 25ec: 50 e0 ldi r21, 0x00 ; 0
6775 25ee: a4 0e add r10, r20
6776 25f0: b5 1e adc r11, r21
6777 25f2: 5f e6 ldi r21, 0x6F ; 111
6778 25f4: d5 22 and r13, r21
6779 25f6: 17 ff sbrs r17, 7
6780 25f8: 0a c0 rjmp .+20 ; 0x260e <vfprintf+0x220>
6781 25fa: 10 95 com r17
6782 25fc: 00 95 com r16
6783 25fe: f0 94 com r15
6784 2600: e0 94 com r14
6785 2602: e1 1c adc r14, r1
6786 2604: f1 1c adc r15, r1
6787 2606: 01 1d adc r16, r1
6788 2608: 11 1d adc r17, r1
6789 260a: 80 e8 ldi r24, 0x80 ; 128
6790 260c: d8 2a or r13, r24
6791 260e: 2a e0 ldi r18, 0x0A ; 10
6792 2610: 30 e0 ldi r19, 0x00 ; 0
6793 2612: a1 01 movw r20, r2
6794 2614: c8 01 movw r24, r16
6795 2616: b7 01 movw r22, r14
6796 2618: 0e 94 28 14 call 0x2850 ; 0x2850 <__ultoa_invert>
6797 261c: f8 2e mov r15, r24
6798 261e: f2 18 sub r15, r2
6799 2620: 40 c0 rjmp .+128 ; 0x26a2 <vfprintf+0x2b4>
6800 2622: 95 37 cpi r25, 0x75 ; 117
6801 2624: 29 f4 brne .+10 ; 0x2630 <vfprintf+0x242>
6802 2626: 1d 2d mov r17, r13
6803 2628: 1f 7e andi r17, 0xEF ; 239
6804 262a: 2a e0 ldi r18, 0x0A ; 10
6805 262c: 30 e0 ldi r19, 0x00 ; 0
6806 262e: 1d c0 rjmp .+58 ; 0x266a <vfprintf+0x27c>
6807 2630: 1d 2d mov r17, r13
6808 2632: 19 7f andi r17, 0xF9 ; 249
6809 2634: 9f 36 cpi r25, 0x6F ; 111
6810 2636: 61 f0 breq .+24 ; 0x2650 <vfprintf+0x262>
6811 2638: 90 37 cpi r25, 0x70 ; 112
6812 263a: 20 f4 brcc .+8 ; 0x2644 <vfprintf+0x256>
6813 263c: 98 35 cpi r25, 0x58 ; 88
6814 263e: 09 f0 breq .+2 ; 0x2642 <vfprintf+0x254>
6815 2640: ad c0 rjmp .+346 ; 0x279c <vfprintf+0x3ae>
6816 2642: 0f c0 rjmp .+30 ; 0x2662 <vfprintf+0x274>
6817 2644: 90 37 cpi r25, 0x70 ; 112
6818 2646: 39 f0 breq .+14 ; 0x2656 <vfprintf+0x268>
6819 2648: 98 37 cpi r25, 0x78 ; 120
6820 264a: 09 f0 breq .+2 ; 0x264e <vfprintf+0x260>
6821 264c: a7 c0 rjmp .+334 ; 0x279c <vfprintf+0x3ae>
6822 264e: 04 c0 rjmp .+8 ; 0x2658 <vfprintf+0x26a>
6823 2650: 28 e0 ldi r18, 0x08 ; 8
6824 2652: 30 e0 ldi r19, 0x00 ; 0
6825 2654: 0a c0 rjmp .+20 ; 0x266a <vfprintf+0x27c>
6826 2656: 10 61 ori r17, 0x10 ; 16
6827 2658: 14 fd sbrc r17, 4
6828 265a: 14 60 ori r17, 0x04 ; 4
6829 265c: 20 e1 ldi r18, 0x10 ; 16
6830 265e: 30 e0 ldi r19, 0x00 ; 0
6831 2660: 04 c0 rjmp .+8 ; 0x266a <vfprintf+0x27c>
6832 2662: 14 fd sbrc r17, 4
6833 2664: 16 60 ori r17, 0x06 ; 6
6834 2666: 20 e1 ldi r18, 0x10 ; 16
6835 2668: 32 e0 ldi r19, 0x02 ; 2
6836 266a: 17 ff sbrs r17, 7
6837 266c: 08 c0 rjmp .+16 ; 0x267e <vfprintf+0x290>
6838 266e: f5 01 movw r30, r10
6839 2670: 60 81 ld r22, Z
6840 2672: 71 81 ldd r23, Z+1 ; 0x01
6841 2674: 82 81 ldd r24, Z+2 ; 0x02
6842 2676: 93 81 ldd r25, Z+3 ; 0x03
6843 2678: 44 e0 ldi r20, 0x04 ; 4
6844 267a: 50 e0 ldi r21, 0x00 ; 0
6845 267c: 08 c0 rjmp .+16 ; 0x268e <vfprintf+0x2a0>
6846 267e: f5 01 movw r30, r10
6847 2680: 80 81 ld r24, Z
6848 2682: 91 81 ldd r25, Z+1 ; 0x01
6849 2684: bc 01 movw r22, r24
6850 2686: 80 e0 ldi r24, 0x00 ; 0
6851 2688: 90 e0 ldi r25, 0x00 ; 0
6852 268a: 42 e0 ldi r20, 0x02 ; 2
6853 268c: 50 e0 ldi r21, 0x00 ; 0
6854 268e: a4 0e add r10, r20
6855 2690: b5 1e adc r11, r21
6856 2692: a1 01 movw r20, r2
6857 2694: 0e 94 28 14 call 0x2850 ; 0x2850 <__ultoa_invert>
6858 2698: f8 2e mov r15, r24
6859 269a: f2 18 sub r15, r2
6860 269c: 8f e7 ldi r24, 0x7F ; 127
6861 269e: d8 2e mov r13, r24
6862 26a0: d1 22 and r13, r17
6863 26a2: d6 fe sbrs r13, 6
6864 26a4: 0b c0 rjmp .+22 ; 0x26bc <vfprintf+0x2ce>
6865 26a6: 5e ef ldi r21, 0xFE ; 254
6866 26a8: d5 22 and r13, r21
6867 26aa: f9 14 cp r15, r9
6868 26ac: 38 f4 brcc .+14 ; 0x26bc <vfprintf+0x2ce>
6869 26ae: d4 fe sbrs r13, 4
6870 26b0: 07 c0 rjmp .+14 ; 0x26c0 <vfprintf+0x2d2>
6871 26b2: d2 fc sbrc r13, 2
6872 26b4: 05 c0 rjmp .+10 ; 0x26c0 <vfprintf+0x2d2>
6873 26b6: 8f ee ldi r24, 0xEF ; 239
6874 26b8: d8 22 and r13, r24
6875 26ba: 02 c0 rjmp .+4 ; 0x26c0 <vfprintf+0x2d2>
6876 26bc: 1f 2d mov r17, r15
6877 26be: 01 c0 rjmp .+2 ; 0x26c2 <vfprintf+0x2d4>
6878 26c0: 19 2d mov r17, r9
6879 26c2: d4 fe sbrs r13, 4
6880 26c4: 0d c0 rjmp .+26 ; 0x26e0 <vfprintf+0x2f2>
6881 26c6: fe 01 movw r30, r28
6882 26c8: ef 0d add r30, r15
6883 26ca: f1 1d adc r31, r1
6884 26cc: 80 81 ld r24, Z
6885 26ce: 80 33 cpi r24, 0x30 ; 48
6886 26d0: 19 f4 brne .+6 ; 0x26d8 <vfprintf+0x2ea>
6887 26d2: 99 ee ldi r25, 0xE9 ; 233
6888 26d4: d9 22 and r13, r25
6889 26d6: 08 c0 rjmp .+16 ; 0x26e8 <vfprintf+0x2fa>
6890 26d8: 1f 5f subi r17, 0xFF ; 255
6891 26da: d2 fe sbrs r13, 2
6892 26dc: 05 c0 rjmp .+10 ; 0x26e8 <vfprintf+0x2fa>
6893 26de: 03 c0 rjmp .+6 ; 0x26e6 <vfprintf+0x2f8>
6894 26e0: 8d 2d mov r24, r13
6895 26e2: 86 78 andi r24, 0x86 ; 134
6896 26e4: 09 f0 breq .+2 ; 0x26e8 <vfprintf+0x2fa>
6897 26e6: 1f 5f subi r17, 0xFF ; 255
6898 26e8: 0d 2d mov r16, r13
6899 26ea: d3 fc sbrc r13, 3
6900 26ec: 14 c0 rjmp .+40 ; 0x2716 <vfprintf+0x328>
6901 26ee: d0 fe sbrs r13, 0
6902 26f0: 0f c0 rjmp .+30 ; 0x2710 <vfprintf+0x322>
6903 26f2: 1c 15 cp r17, r12
6904 26f4: 10 f0 brcs .+4 ; 0x26fa <vfprintf+0x30c>
6905 26f6: 9f 2c mov r9, r15
6906 26f8: 0b c0 rjmp .+22 ; 0x2710 <vfprintf+0x322>
6907 26fa: 9f 2c mov r9, r15
6908 26fc: 9c 0c add r9, r12
6909 26fe: 91 1a sub r9, r17
6910 2700: 1c 2d mov r17, r12
6911 2702: 06 c0 rjmp .+12 ; 0x2710 <vfprintf+0x322>
6912 2704: b3 01 movw r22, r6
6913 2706: 80 e2 ldi r24, 0x20 ; 32
6914 2708: 90 e0 ldi r25, 0x00 ; 0
6915 270a: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6916 270e: 1f 5f subi r17, 0xFF ; 255
6917 2710: 1c 15 cp r17, r12
6918 2712: c0 f3 brcs .-16 ; 0x2704 <vfprintf+0x316>
6919 2714: 04 c0 rjmp .+8 ; 0x271e <vfprintf+0x330>
6920 2716: 1c 15 cp r17, r12
6921 2718: 10 f4 brcc .+4 ; 0x271e <vfprintf+0x330>
6922 271a: c1 1a sub r12, r17
6923 271c: 01 c0 rjmp .+2 ; 0x2720 <vfprintf+0x332>
6924 271e: cc 24 eor r12, r12
6925 2720: 04 ff sbrs r16, 4
6926 2722: 10 c0 rjmp .+32 ; 0x2744 <vfprintf+0x356>
6927 2724: b3 01 movw r22, r6
6928 2726: 80 e3 ldi r24, 0x30 ; 48
6929 2728: 90 e0 ldi r25, 0x00 ; 0
6930 272a: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6931 272e: 02 ff sbrs r16, 2
6932 2730: 1e c0 rjmp .+60 ; 0x276e <vfprintf+0x380>
6933 2732: 01 fd sbrc r16, 1
6934 2734: 03 c0 rjmp .+6 ; 0x273c <vfprintf+0x34e>
6935 2736: 88 e7 ldi r24, 0x78 ; 120
6936 2738: 90 e0 ldi r25, 0x00 ; 0
6937 273a: 02 c0 rjmp .+4 ; 0x2740 <vfprintf+0x352>
6938 273c: 88 e5 ldi r24, 0x58 ; 88
6939 273e: 90 e0 ldi r25, 0x00 ; 0
6940 2740: b3 01 movw r22, r6
6941 2742: 0c c0 rjmp .+24 ; 0x275c <vfprintf+0x36e>
6942 2744: 80 2f mov r24, r16
6943 2746: 86 78 andi r24, 0x86 ; 134
6944 2748: 91 f0 breq .+36 ; 0x276e <vfprintf+0x380>
6945 274a: 01 ff sbrs r16, 1
6946 274c: 02 c0 rjmp .+4 ; 0x2752 <vfprintf+0x364>
6947 274e: 8b e2 ldi r24, 0x2B ; 43
6948 2750: 01 c0 rjmp .+2 ; 0x2754 <vfprintf+0x366>
6949 2752: 80 e2 ldi r24, 0x20 ; 32
6950 2754: d7 fc sbrc r13, 7
6951 2756: 8d e2 ldi r24, 0x2D ; 45
6952 2758: b3 01 movw r22, r6
6953 275a: 90 e0 ldi r25, 0x00 ; 0
6954 275c: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6955 2760: 06 c0 rjmp .+12 ; 0x276e <vfprintf+0x380>
6956 2762: b3 01 movw r22, r6
6957 2764: 80 e3 ldi r24, 0x30 ; 48
6958 2766: 90 e0 ldi r25, 0x00 ; 0
6959 2768: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6960 276c: 9a 94 dec r9
6961 276e: f9 14 cp r15, r9
6962 2770: c0 f3 brcs .-16 ; 0x2762 <vfprintf+0x374>
6963 2772: fa 94 dec r15
6964 2774: f1 01 movw r30, r2
6965 2776: ef 0d add r30, r15
6966 2778: f1 1d adc r31, r1
6967 277a: b3 01 movw r22, r6
6968 277c: 80 81 ld r24, Z
6969 277e: 90 e0 ldi r25, 0x00 ; 0
6970 2780: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6971 2784: ff 20 and r15, r15
6972 2786: a9 f7 brne .-22 ; 0x2772 <vfprintf+0x384>
6973 2788: 06 c0 rjmp .+12 ; 0x2796 <vfprintf+0x3a8>
6974 278a: b3 01 movw r22, r6
6975 278c: 80 e2 ldi r24, 0x20 ; 32
6976 278e: 90 e0 ldi r25, 0x00 ; 0
6977 2790: 0e 94 fc 13 call 0x27f8 ; 0x27f8 <fputc>
6978 2794: ca 94 dec r12
6979 2796: cc 20 and r12, r12
6980 2798: c1 f7 brne .-16 ; 0x278a <vfprintf+0x39c>
6981 279a: 41 ce rjmp .-894 ; 0x241e <vfprintf+0x30>
6982 279c: f3 01 movw r30, r6
6983 279e: 66 81 ldd r22, Z+6 ; 0x06
6984 27a0: 77 81 ldd r23, Z+7 ; 0x07
6985 27a2: cb 01 movw r24, r22
6986 27a4: 2b 96 adiw r28, 0x0b ; 11
6987 27a6: e2 e1 ldi r30, 0x12 ; 18
6988 27a8: 0c 94 e3 14 jmp 0x29c6 ; 0x29c6 <__epilogue_restores__>
1234 kaklik 6989  
1296 kaklik 6990 000027ac <strnlen_P>:
6991 27ac: fc 01 movw r30, r24
6992 27ae: 05 90 lpm r0, Z+
6993 27b0: 61 50 subi r22, 0x01 ; 1
6994 27b2: 70 40 sbci r23, 0x00 ; 0
6995 27b4: 01 10 cpse r0, r1
6996 27b6: d8 f7 brcc .-10 ; 0x27ae <strnlen_P+0x2>
6997 27b8: 80 95 com r24
6998 27ba: 90 95 com r25
6999 27bc: 8e 0f add r24, r30
7000 27be: 9f 1f adc r25, r31
7001 27c0: 08 95 ret
1234 kaklik 7002  
1296 kaklik 7003 000027c2 <strnlen>:
7004 27c2: fc 01 movw r30, r24
7005 27c4: 61 50 subi r22, 0x01 ; 1
7006 27c6: 70 40 sbci r23, 0x00 ; 0
7007 27c8: 01 90 ld r0, Z+
7008 27ca: 01 10 cpse r0, r1
7009 27cc: d8 f7 brcc .-10 ; 0x27c4 <strnlen+0x2>
7010 27ce: 80 95 com r24
7011 27d0: 90 95 com r25
7012 27d2: 8e 0f add r24, r30
7013 27d4: 9f 1f adc r25, r31
7014 27d6: 08 95 ret
1234 kaklik 7015  
1296 kaklik 7016 000027d8 <strrev>:
7017 27d8: dc 01 movw r26, r24
7018 27da: fc 01 movw r30, r24
7019 27dc: 67 2f mov r22, r23
7020 27de: 71 91 ld r23, Z+
7021 27e0: 77 23 and r23, r23
7022 27e2: e1 f7 brne .-8 ; 0x27dc <strrev+0x4>
7023 27e4: 32 97 sbiw r30, 0x02 ; 2
7024 27e6: 04 c0 rjmp .+8 ; 0x27f0 <strrev+0x18>
7025 27e8: 7c 91 ld r23, X
7026 27ea: 6d 93 st X+, r22
7027 27ec: 70 83 st Z, r23
7028 27ee: 62 91 ld r22, -Z
7029 27f0: ae 17 cp r26, r30
7030 27f2: bf 07 cpc r27, r31
7031 27f4: c8 f3 brcs .-14 ; 0x27e8 <strrev+0x10>
7032 27f6: 08 95 ret
1234 kaklik 7033  
1296 kaklik 7034 000027f8 <fputc>:
7035 27f8: 0f 93 push r16
7036 27fa: 1f 93 push r17
7037 27fc: cf 93 push r28
7038 27fe: df 93 push r29
7039 2800: 8c 01 movw r16, r24
7040 2802: eb 01 movw r28, r22
7041 2804: 8b 81 ldd r24, Y+3 ; 0x03
7042 2806: 81 ff sbrs r24, 1
7043 2808: 1b c0 rjmp .+54 ; 0x2840 <fputc+0x48>
7044 280a: 82 ff sbrs r24, 2
7045 280c: 0d c0 rjmp .+26 ; 0x2828 <fputc+0x30>
7046 280e: 2e 81 ldd r18, Y+6 ; 0x06
7047 2810: 3f 81 ldd r19, Y+7 ; 0x07
7048 2812: 8c 81 ldd r24, Y+4 ; 0x04
7049 2814: 9d 81 ldd r25, Y+5 ; 0x05
7050 2816: 28 17 cp r18, r24
7051 2818: 39 07 cpc r19, r25
7052 281a: 64 f4 brge .+24 ; 0x2834 <fputc+0x3c>
7053 281c: e8 81 ld r30, Y
7054 281e: f9 81 ldd r31, Y+1 ; 0x01
7055 2820: 01 93 st Z+, r16
7056 2822: f9 83 std Y+1, r31 ; 0x01
7057 2824: e8 83 st Y, r30
7058 2826: 06 c0 rjmp .+12 ; 0x2834 <fputc+0x3c>
7059 2828: e8 85 ldd r30, Y+8 ; 0x08
7060 282a: f9 85 ldd r31, Y+9 ; 0x09
7061 282c: 80 2f mov r24, r16
7062 282e: 09 95 icall
7063 2830: 89 2b or r24, r25
7064 2832: 31 f4 brne .+12 ; 0x2840 <fputc+0x48>
7065 2834: 8e 81 ldd r24, Y+6 ; 0x06
7066 2836: 9f 81 ldd r25, Y+7 ; 0x07
7067 2838: 01 96 adiw r24, 0x01 ; 1
7068 283a: 9f 83 std Y+7, r25 ; 0x07
7069 283c: 8e 83 std Y+6, r24 ; 0x06
7070 283e: 02 c0 rjmp .+4 ; 0x2844 <fputc+0x4c>
7071 2840: 0f ef ldi r16, 0xFF ; 255
7072 2842: 1f ef ldi r17, 0xFF ; 255
7073 2844: c8 01 movw r24, r16
7074 2846: df 91 pop r29
7075 2848: cf 91 pop r28
7076 284a: 1f 91 pop r17
7077 284c: 0f 91 pop r16
7078 284e: 08 95 ret
7079  
7080 00002850 <__ultoa_invert>:
7081 2850: fa 01 movw r30, r20
7082 2852: aa 27 eor r26, r26
7083 2854: 28 30 cpi r18, 0x08 ; 8
7084 2856: 51 f1 breq .+84 ; 0x28ac <__ultoa_invert+0x5c>
7085 2858: 20 31 cpi r18, 0x10 ; 16
7086 285a: 81 f1 breq .+96 ; 0x28bc <__ultoa_invert+0x6c>
7087 285c: e8 94 clt
7088 285e: 6f 93 push r22
7089 2860: 6e 7f andi r22, 0xFE ; 254
7090 2862: 6e 5f subi r22, 0xFE ; 254
7091 2864: 7f 4f sbci r23, 0xFF ; 255
7092 2866: 8f 4f sbci r24, 0xFF ; 255
7093 2868: 9f 4f sbci r25, 0xFF ; 255
7094 286a: af 4f sbci r26, 0xFF ; 255
7095 286c: b1 e0 ldi r27, 0x01 ; 1
7096 286e: 3e d0 rcall .+124 ; 0x28ec <__ultoa_invert+0x9c>
7097 2870: b4 e0 ldi r27, 0x04 ; 4
7098 2872: 3c d0 rcall .+120 ; 0x28ec <__ultoa_invert+0x9c>
7099 2874: 67 0f add r22, r23
7100 2876: 78 1f adc r23, r24
7101 2878: 89 1f adc r24, r25
7102 287a: 9a 1f adc r25, r26
7103 287c: a1 1d adc r26, r1
7104 287e: 68 0f add r22, r24
7105 2880: 79 1f adc r23, r25
7106 2882: 8a 1f adc r24, r26
7107 2884: 91 1d adc r25, r1
7108 2886: a1 1d adc r26, r1
7109 2888: 6a 0f add r22, r26
7110 288a: 71 1d adc r23, r1
7111 288c: 81 1d adc r24, r1
7112 288e: 91 1d adc r25, r1
7113 2890: a1 1d adc r26, r1
7114 2892: 20 d0 rcall .+64 ; 0x28d4 <__ultoa_invert+0x84>
7115 2894: 09 f4 brne .+2 ; 0x2898 <__ultoa_invert+0x48>
7116 2896: 68 94 set
7117 2898: 3f 91 pop r19
7118 289a: 2a e0 ldi r18, 0x0A ; 10
7119 289c: 26 9f mul r18, r22
7120 289e: 11 24 eor r1, r1
7121 28a0: 30 19 sub r19, r0
7122 28a2: 30 5d subi r19, 0xD0 ; 208
7123 28a4: 31 93 st Z+, r19
7124 28a6: de f6 brtc .-74 ; 0x285e <__ultoa_invert+0xe>
7125 28a8: cf 01 movw r24, r30
7126 28aa: 08 95 ret
7127 28ac: 46 2f mov r20, r22
7128 28ae: 47 70 andi r20, 0x07 ; 7
7129 28b0: 40 5d subi r20, 0xD0 ; 208
7130 28b2: 41 93 st Z+, r20
7131 28b4: b3 e0 ldi r27, 0x03 ; 3
7132 28b6: 0f d0 rcall .+30 ; 0x28d6 <__ultoa_invert+0x86>
7133 28b8: c9 f7 brne .-14 ; 0x28ac <__ultoa_invert+0x5c>
7134 28ba: f6 cf rjmp .-20 ; 0x28a8 <__ultoa_invert+0x58>
7135 28bc: 46 2f mov r20, r22
7136 28be: 4f 70 andi r20, 0x0F ; 15
7137 28c0: 40 5d subi r20, 0xD0 ; 208
7138 28c2: 4a 33 cpi r20, 0x3A ; 58
7139 28c4: 18 f0 brcs .+6 ; 0x28cc <__ultoa_invert+0x7c>
7140 28c6: 49 5d subi r20, 0xD9 ; 217
7141 28c8: 31 fd sbrc r19, 1
7142 28ca: 40 52 subi r20, 0x20 ; 32
7143 28cc: 41 93 st Z+, r20
7144 28ce: 02 d0 rcall .+4 ; 0x28d4 <__ultoa_invert+0x84>
7145 28d0: a9 f7 brne .-22 ; 0x28bc <__ultoa_invert+0x6c>
7146 28d2: ea cf rjmp .-44 ; 0x28a8 <__ultoa_invert+0x58>
7147 28d4: b4 e0 ldi r27, 0x04 ; 4
7148 28d6: a6 95 lsr r26
7149 28d8: 97 95 ror r25
7150 28da: 87 95 ror r24
7151 28dc: 77 95 ror r23
7152 28de: 67 95 ror r22
7153 28e0: ba 95 dec r27
7154 28e2: c9 f7 brne .-14 ; 0x28d6 <__ultoa_invert+0x86>
7155 28e4: 00 97 sbiw r24, 0x00 ; 0
7156 28e6: 61 05 cpc r22, r1
7157 28e8: 71 05 cpc r23, r1
7158 28ea: 08 95 ret
7159 28ec: 9b 01 movw r18, r22
7160 28ee: ac 01 movw r20, r24
7161 28f0: 0a 2e mov r0, r26
7162 28f2: 06 94 lsr r0
7163 28f4: 57 95 ror r21
7164 28f6: 47 95 ror r20
7165 28f8: 37 95 ror r19
7166 28fa: 27 95 ror r18
7167 28fc: ba 95 dec r27
7168 28fe: c9 f7 brne .-14 ; 0x28f2 <__ultoa_invert+0xa2>
7169 2900: 62 0f add r22, r18
7170 2902: 73 1f adc r23, r19
7171 2904: 84 1f adc r24, r20
7172 2906: 95 1f adc r25, r21
7173 2908: a0 1d adc r26, r0
7174 290a: 08 95 ret
7175  
7176 0000290c <__mulsi3>:
7177 290c: 62 9f mul r22, r18
7178 290e: d0 01 movw r26, r0
7179 2910: 73 9f mul r23, r19
7180 2912: f0 01 movw r30, r0
7181 2914: 82 9f mul r24, r18
7182 2916: e0 0d add r30, r0
7183 2918: f1 1d adc r31, r1
7184 291a: 64 9f mul r22, r20
7185 291c: e0 0d add r30, r0
7186 291e: f1 1d adc r31, r1
7187 2920: 92 9f mul r25, r18
7188 2922: f0 0d add r31, r0
7189 2924: 83 9f mul r24, r19
7190 2926: f0 0d add r31, r0
7191 2928: 74 9f mul r23, r20
7192 292a: f0 0d add r31, r0
7193 292c: 65 9f mul r22, r21
7194 292e: f0 0d add r31, r0
7195 2930: 99 27 eor r25, r25
7196 2932: 72 9f mul r23, r18
7197 2934: b0 0d add r27, r0
7198 2936: e1 1d adc r30, r1
7199 2938: f9 1f adc r31, r25
7200 293a: 63 9f mul r22, r19
7201 293c: b0 0d add r27, r0
7202 293e: e1 1d adc r30, r1
7203 2940: f9 1f adc r31, r25
7204 2942: bd 01 movw r22, r26
7205 2944: cf 01 movw r24, r30
7206 2946: 11 24 eor r1, r1
7207 2948: 08 95 ret
7208  
7209 0000294a <__udivmodsi4>:
7210 294a: a1 e2 ldi r26, 0x21 ; 33
7211 294c: 1a 2e mov r1, r26
7212 294e: aa 1b sub r26, r26
7213 2950: bb 1b sub r27, r27
7214 2952: fd 01 movw r30, r26
7215 2954: 0d c0 rjmp .+26 ; 0x2970 <__udivmodsi4_ep>
7216  
7217 00002956 <__udivmodsi4_loop>:
7218 2956: aa 1f adc r26, r26
7219 2958: bb 1f adc r27, r27
7220 295a: ee 1f adc r30, r30
7221 295c: ff 1f adc r31, r31
7222 295e: a2 17 cp r26, r18
7223 2960: b3 07 cpc r27, r19
7224 2962: e4 07 cpc r30, r20
7225 2964: f5 07 cpc r31, r21
7226 2966: 20 f0 brcs .+8 ; 0x2970 <__udivmodsi4_ep>
7227 2968: a2 1b sub r26, r18
7228 296a: b3 0b sbc r27, r19
7229 296c: e4 0b sbc r30, r20
7230 296e: f5 0b sbc r31, r21
7231  
7232 00002970 <__udivmodsi4_ep>:
7233 2970: 66 1f adc r22, r22
7234 2972: 77 1f adc r23, r23
7235 2974: 88 1f adc r24, r24
7236 2976: 99 1f adc r25, r25
7237 2978: 1a 94 dec r1
7238 297a: 69 f7 brne .-38 ; 0x2956 <__udivmodsi4_loop>
7239 297c: 60 95 com r22
7240 297e: 70 95 com r23
7241 2980: 80 95 com r24
7242 2982: 90 95 com r25
7243 2984: 9b 01 movw r18, r22
7244 2986: ac 01 movw r20, r24
7245 2988: bd 01 movw r22, r26
7246 298a: cf 01 movw r24, r30
7247 298c: 08 95 ret
7248  
7249 0000298e <__prologue_saves__>:
7250 298e: 2f 92 push r2
7251 2990: 3f 92 push r3
7252 2992: 4f 92 push r4
7253 2994: 5f 92 push r5
7254 2996: 6f 92 push r6
7255 2998: 7f 92 push r7
7256 299a: 8f 92 push r8
7257 299c: 9f 92 push r9
7258 299e: af 92 push r10
7259 29a0: bf 92 push r11
7260 29a2: cf 92 push r12
7261 29a4: df 92 push r13
7262 29a6: ef 92 push r14
7263 29a8: ff 92 push r15
7264 29aa: 0f 93 push r16
7265 29ac: 1f 93 push r17
7266 29ae: cf 93 push r28
7267 29b0: df 93 push r29
7268 29b2: cd b7 in r28, 0x3d ; 61
7269 29b4: de b7 in r29, 0x3e ; 62
7270 29b6: ca 1b sub r28, r26
7271 29b8: db 0b sbc r29, r27
7272 29ba: 0f b6 in r0, 0x3f ; 63
7273 29bc: f8 94 cli
7274 29be: de bf out 0x3e, r29 ; 62
7275 29c0: 0f be out 0x3f, r0 ; 63
7276 29c2: cd bf out 0x3d, r28 ; 61
7277 29c4: 09 94 ijmp
7278  
7279 000029c6 <__epilogue_restores__>:
7280 29c6: 2a 88 ldd r2, Y+18 ; 0x12
7281 29c8: 39 88 ldd r3, Y+17 ; 0x11
7282 29ca: 48 88 ldd r4, Y+16 ; 0x10
7283 29cc: 5f 84 ldd r5, Y+15 ; 0x0f
7284 29ce: 6e 84 ldd r6, Y+14 ; 0x0e
7285 29d0: 7d 84 ldd r7, Y+13 ; 0x0d
7286 29d2: 8c 84 ldd r8, Y+12 ; 0x0c
7287 29d4: 9b 84 ldd r9, Y+11 ; 0x0b
7288 29d6: aa 84 ldd r10, Y+10 ; 0x0a
7289 29d8: b9 84 ldd r11, Y+9 ; 0x09
7290 29da: c8 84 ldd r12, Y+8 ; 0x08
7291 29dc: df 80 ldd r13, Y+7 ; 0x07
7292 29de: ee 80 ldd r14, Y+6 ; 0x06
7293 29e0: fd 80 ldd r15, Y+5 ; 0x05
7294 29e2: 0c 81 ldd r16, Y+4 ; 0x04
7295 29e4: 1b 81 ldd r17, Y+3 ; 0x03
7296 29e6: aa 81 ldd r26, Y+2 ; 0x02
7297 29e8: b9 81 ldd r27, Y+1 ; 0x01
7298 29ea: ce 0f add r28, r30
7299 29ec: d1 1d adc r29, r1
7300 29ee: 0f b6 in r0, 0x3f ; 63
7301 29f0: f8 94 cli
7302 29f2: de bf out 0x3e, r29 ; 62
7303 29f4: 0f be out 0x3f, r0 ; 63
7304 29f6: cd bf out 0x3d, r28 ; 61
7305 29f8: ed 01 movw r28, r26
7306 29fa: 08 95 ret
7307  
7308 000029fc <__udivmodhi4>:
7309 29fc: aa 1b sub r26, r26
7310 29fe: bb 1b sub r27, r27
7311 2a00: 51 e1 ldi r21, 0x11 ; 17
7312 2a02: 07 c0 rjmp .+14 ; 0x2a12 <__udivmodhi4_ep>
7313  
7314 00002a04 <__udivmodhi4_loop>:
7315 2a04: aa 1f adc r26, r26
7316 2a06: bb 1f adc r27, r27
7317 2a08: a6 17 cp r26, r22
7318 2a0a: b7 07 cpc r27, r23
7319 2a0c: 10 f0 brcs .+4 ; 0x2a12 <__udivmodhi4_ep>
7320 2a0e: a6 1b sub r26, r22
7321 2a10: b7 0b sbc r27, r23
7322  
7323 00002a12 <__udivmodhi4_ep>:
7324 2a12: 88 1f adc r24, r24
7325 2a14: 99 1f adc r25, r25
7326 2a16: 5a 95 dec r21
7327 2a18: a9 f7 brne .-22 ; 0x2a04 <__udivmodhi4_loop>
7328 2a1a: 80 95 com r24
7329 2a1c: 90 95 com r25
7330 2a1e: bc 01 movw r22, r24
7331 2a20: cd 01 movw r24, r26
7332 2a22: 08 95 ret
7333  
7334 00002a24 <_exit>:
7335 2a24: f8 94 cli
7336  
7337 00002a26 <__stop_program>:
7338 2a26: ff cf rjmp .-2 ; 0x2a26 <__stop_program>