glg.elf:     file format elf32-avr

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .data         00000006  00800100  000022ec  00002360  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  1 .text         000022ec  00000000  00000000  00000074  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .bss          00000341  00800106  000022f2  00002366  2**0
                  ALLOC
  3 .stab         0000087c  00000000  00000000  00002368  2**2
                  CONTENTS, READONLY, DEBUGGING
  4 .stabstr      0000019e  00000000  00000000  00002be4  2**0
                  CONTENTS, READONLY, DEBUGGING
  5 .debug_aranges 00000060  00000000  00000000  00002d82  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_pubnames 0000019e  00000000  00000000  00002de2  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_info   00001cfd  00000000  00000000  00002f80  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_abbrev 000007a6  00000000  00000000  00004c7d  2**0
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_line   000019a4  00000000  00000000  00005423  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_frame  00000260  00000000  00000000  00006dc8  2**2
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_str    000005e8  00000000  00000000  00007028  2**0
                  CONTENTS, READONLY, DEBUGGING
 12 .debug_loc    000020ca  00000000  00000000  00007610  2**0
                  CONTENTS, READONLY, DEBUGGING
 13 .debug_ranges 00000178  00000000  00000000  000096da  2**0
                  CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:

00000000 <__vectors>:
       0:       0c 94 4c 00     jmp     0x98    ; 0x98 <__ctors_end>
       4:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
       8:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
       c:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      10:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      14:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      18:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      1c:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      20:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      24:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      28:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      2c:       0c 94 7a 01     jmp     0x2f4   ; 0x2f4 <__vector_11>
      30:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      34:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      38:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      3c:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      40:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      44:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      48:       0c 94 d6 00     jmp     0x1ac   ; 0x1ac <__vector_18>
      4c:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      50:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      54:       0c 94 6b 00     jmp     0xd6    ; 0xd6 <__vector_21>
      58:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      5c:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      60:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>
      64:       0c 94 69 00     jmp     0xd2    ; 0xd2 <__bad_interrupt>

00000068 <__c.2081>:
      68:       0d 0a 00                                            ...

0000006b <__c.2079>:
      6b:       2c 00                                               ,.

0000006d <__c.2075>:
      6d:       24 47 50 52 4d 43 00                                $GPRMC.

00000074 <__c.2073>:
      74:       24 47 50 47 47 41 00                                $GPGGA.

0000007b <__c.2071>:
      7b:       2e 6c 6f 67 00                                      .log.

00000080 <__c.2065>:
      80:       24 47 50 52 4d 43 00                                $GPRMC.

00000087 <__c.2014>:
      87:       24 50 53 52 46 31 30 36 2c 32 31 2a 30 46 0d 0a     $PSRF106,21*0F..
        ...

00000098 <__ctors_end>:
      98:       11 24           eor     r1, r1
      9a:       1f be           out     0x3f, r1        ; 63
      9c:       cf ef           ldi     r28, 0xFF       ; 255
      9e:       d4 e0           ldi     r29, 0x04       ; 4
      a0:       de bf           out     0x3e, r29       ; 62
      a2:       cd bf           out     0x3d, r28       ; 61

000000a4 <__do_copy_data>:
      a4:       11 e0           ldi     r17, 0x01       ; 1
      a6:       a0 e0           ldi     r26, 0x00       ; 0
      a8:       b1 e0           ldi     r27, 0x01       ; 1
      aa:       ec ee           ldi     r30, 0xEC       ; 236
      ac:       f2 e2           ldi     r31, 0x22       ; 34
      ae:       02 c0           rjmp    .+4             ; 0xb4 <.do_copy_data_start>

000000b0 <.do_copy_data_loop>:
      b0:       05 90           lpm     r0, Z+
      b2:       0d 92           st      X+, r0

000000b4 <.do_copy_data_start>:
      b4:       a6 30           cpi     r26, 0x06       ; 6
      b6:       b1 07           cpc     r27, r17
      b8:       d9 f7           brne    .-10            ; 0xb0 <.do_copy_data_loop>

000000ba <__do_clear_bss>:
      ba:       14 e0           ldi     r17, 0x04       ; 4
      bc:       a6 e0           ldi     r26, 0x06       ; 6
      be:       b1 e0           ldi     r27, 0x01       ; 1
      c0:       01 c0           rjmp    .+2             ; 0xc4 <.do_clear_bss_start>

000000c2 <.do_clear_bss_loop>:
      c2:       1d 92           st      X+, r1

000000c4 <.do_clear_bss_start>:
      c4:       a7 34           cpi     r26, 0x47       ; 71
      c6:       b1 07           cpc     r27, r17
      c8:       e1 f7           brne    .-8             ; 0xc2 <.do_clear_bss_loop>
      ca:       0e 94 ba 01     call    0x374   ; 0x374 <main>
      ce:       0c 94 75 11     jmp     0x22ea  ; 0x22ea <_exit>

000000d2 <__bad_interrupt>:
      d2:       0c 94 00 00     jmp     0        ; 0x0 <__heap_end>

000000d6 <__vector_21>:
/*---------------------------------------------------------*/
/* ADC interrupt                                           */
/*---------------------------------------------------------*/

ISR(ADC_vect)
{
      d6:       1f 92           push    r1
      d8:       0f 92           push    r0
      da:       0f b6           in      r0, 0x3f        ; 63
      dc:       0f 92           push    r0
      de:       11 24           eor     r1, r1
      e0:       2f 93           push    r18
      e2:       3f 93           push    r19
      e4:       8f 93           push    r24
WORD n;
static BYTE l, h;

    n = ADC;
      e6:       20 91 78 00     lds     r18, 0x0078
      ea:       30 91 79 00     lds     r19, 0x0079

    if(ADMUX == POWER_check)
      ee:       80 91 7c 00     lds     r24, 0x007C
    {
        if (n < VTH_LOW) {
      f2:       20 3d           cpi     r18, 0xD0       ; 208
      f4:       31 05           cpc     r19, r1
      f6:       70 f4           brcc    .+28            ; 0x114 <__vector_21+0x3e>
                if (l >= 15) {
      f8:       80 91 09 01     lds     r24, 0x0109
      fc:       8f 30           cpi     r24, 0x0F       ; 15
      fe:       30 f0           brcs    .+12            ; 0x10c <__vector_21+0x36>
                        Stat |= 0x01;
     100:       80 91 69 01     lds     r24, 0x0169
     104:       81 60           ori     r24, 0x01       ; 1
     106:       80 93 69 01     sts     0x0169, r24
     10a:       06 c0           rjmp    .+12            ; 0x118 <__vector_21+0x42>
                } 
                else {l++;}
     10c:       8f 5f           subi    r24, 0xFF       ; 255
     10e:       80 93 09 01     sts     0x0109, r24
     112:       02 c0           rjmp    .+4             ; 0x118 <__vector_21+0x42>
        } 
        else {l = 0;}
     114:       10 92 09 01     sts     0x0109, r1

        if (n > VTH_HIGH) {
     118:       81 e0           ldi     r24, 0x01       ; 1
     11a:       2c 32           cpi     r18, 0x2C       ; 44
     11c:       38 07           cpc     r19, r24
     11e:       70 f0           brcs    .+28            ; 0x13c <__vector_21+0x66>
                if (h >= 15) {
     120:       80 91 08 01     lds     r24, 0x0108
     124:       8f 30           cpi     r24, 0x0F       ; 15
     126:       30 f0           brcs    .+12            ; 0x134 <__vector_21+0x5e>
                        Stat &= 0xFE;
     128:       80 91 69 01     lds     r24, 0x0169
     12c:       8e 7f           andi    r24, 0xFE       ; 254
     12e:       80 93 69 01     sts     0x0169, r24
     132:       06 c0           rjmp    .+12            ; 0x140 <__vector_21+0x6a>
                } 
                else {h++;}
     134:       8f 5f           subi    r24, 0xFF       ; 255
     136:       80 93 08 01     sts     0x0108, r24
     13a:       02 c0           rjmp    .+4             ; 0x140 <__vector_21+0x6a>
        } 
        else {h = 0;}
     13c:       10 92 08 01     sts     0x0108, r1

        battery = n;
     140:       30 93 6f 01     sts     0x016F, r19
     144:       20 93 6e 01     sts     0x016E, r18
        ADMUX = ANALOG_IN1;
     148:       82 e4           ldi     r24, 0x42       ; 66
     14a:       80 93 7c 00     sts     0x007C, r24
    }

    if(ADMUX == ANALOG_IN1)
     14e:       80 91 7c 00     lds     r24, 0x007C
    {
        intensity = n;
     152:       30 93 0a 02     sts     0x020A, r19
     156:       20 93 09 02     sts     0x0209, r18
        ADMUX = POWER_check;
     15a:       81 e4           ldi     r24, 0x41       ; 65
     15c:       80 93 7c 00     sts     0x007C, r24
    }

//!!!!
//Stat &= 0xFE;

        ADCSRA = _BV(ADEN)|_BV(ADSC)|_BV(ADIF)|_BV(ADIE)|0b111;
     160:       8f ed           ldi     r24, 0xDF       ; 223
     162:       80 93 7a 00     sts     0x007A, r24
     166:       8f 91           pop     r24
     168:       3f 91           pop     r19
     16a:       2f 91           pop     r18
     16c:       0f 90           pop     r0
     16e:       0f be           out     0x3f, r0        ; 63
     170:       0f 90           pop     r0
     172:       1f 90           pop     r1
     174:       18 95           reti

00000176 <get_fattime>:
/* FatFs module. Any valid time must be returned even if   */
/* the system does not support a real time clock.          */


DWORD get_fattime ()
{
     176:       60 e0           ldi     r22, 0x00       ; 0
     178:       70 e0           ldi     r23, 0x00       ; 0
     17a:       81 ea           ldi     r24, 0xA1       ; 161
     17c:       96 e3           ldi     r25, 0x36       ; 54
     17e:       08 95           ret

00000180 <uart_init>:
/* UART control */


static
void uart_init (void)
{
     180:       f8 94           cli
        cli();
        UCSR0B = 0;
     182:       e1 ec           ldi     r30, 0xC1       ; 193
     184:       f0 e0           ldi     r31, 0x00       ; 0
     186:       10 82           st      Z, r1
        rxfifo.idx_r = 0;
     188:       10 92 71 01     sts     0x0171, r1
        rxfifo.idx_w = 0;
     18c:       10 92 70 01     sts     0x0170, r1
        rxfifo.count = 0;
     190:       10 92 72 01     sts     0x0172, r1
        UBRR0L = SYSCLK/16/9600;        // Enable USRAT0 in N81,4800bps
     194:       81 e4           ldi     r24, 0x41       ; 65
     196:       80 93 c4 00     sts     0x00C4, r24
        UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0);
     19a:       88 e9           ldi     r24, 0x98       ; 152
     19c:       80 83           st      Z, r24
        Stat &= 0xFD;   // Clear overflow flag
     19e:       80 91 69 01     lds     r24, 0x0169
     1a2:       8d 7f           andi    r24, 0xFD       ; 253
     1a4:       80 93 69 01     sts     0x0169, r24
        sei();
     1a8:       78 94           sei
     1aa:       08 95           ret

000001ac <__vector_18>:
}


/* USART0 RXC interrupt */
ISR(USART_RX_vect)
{
     1ac:       1f 92           push    r1
     1ae:       0f 92           push    r0
     1b0:       0f b6           in      r0, 0x3f        ; 63
     1b2:       0f 92           push    r0
     1b4:       11 24           eor     r1, r1
     1b6:       8f 93           push    r24
     1b8:       9f 93           push    r25
     1ba:       ef 93           push    r30
     1bc:       ff 93           push    r31
        uint8_t d, n, i;


        d = UDR0;
     1be:       90 91 c6 00     lds     r25, 0x00C6
        n = rxfifo.count;
     1c2:       80 91 72 01     lds     r24, 0x0172
        if(n < sizeof(rxfifo.buff)) {
     1c6:       86 39           cpi     r24, 0x96       ; 150
     1c8:       88 f4           brcc    .+34            ; 0x1ec <__vector_18+0x40>
                rxfifo.count = ++n;
     1ca:       8f 5f           subi    r24, 0xFF       ; 255
     1cc:       80 93 72 01     sts     0x0172, r24
                i = rxfifo.idx_w;
     1d0:       80 91 70 01     lds     r24, 0x0170
                rxfifo.buff[i++] = d;
     1d4:       e8 2f           mov     r30, r24
     1d6:       ff 27           eor     r31, r31
     1d8:       e0 59           subi    r30, 0x90       ; 144
     1da:       fe 4f           sbci    r31, 0xFE       ; 254
     1dc:       93 83           std     Z+3, r25        ; 0x03
     1de:       8f 5f           subi    r24, 0xFF       ; 255
                if(i >= sizeof(rxfifo.buff))
     1e0:       86 39           cpi     r24, 0x96       ; 150
     1e2:       08 f0           brcs    .+2             ; 0x1e6 <__vector_18+0x3a>
     1e4:       80 e0           ldi     r24, 0x00       ; 0
                        i = 0;
                rxfifo.idx_w = i;
     1e6:       80 93 70 01     sts     0x0170, r24
     1ea:       05 c0           rjmp    .+10            ; 0x1f6 <__vector_18+0x4a>
        } else {
                Stat |= 2;
     1ec:       80 91 69 01     lds     r24, 0x0169
     1f0:       82 60           ori     r24, 0x02       ; 2
     1f2:       80 93 69 01     sts     0x0169, r24
     1f6:       ff 91           pop     r31
     1f8:       ef 91           pop     r30
     1fa:       9f 91           pop     r25
     1fc:       8f 91           pop     r24
     1fe:       0f 90           pop     r0
     200:       0f be           out     0x3f, r0        ; 63
     202:       0f 90           pop     r0
     204:       1f 90           pop     r1
     206:       18 95           reti

00000208 <get_line>:
/*  Get a line received from GPS module               */
/*----------------------------------------------------*/

static
BYTE get_line (void)    // 0: Power fail occured, >0: Number of bytes received.
{
     208:       90 e0           ldi     r25, 0x00       ; 0
        BYTE c, i = 0;


        for (;;) {
                if (Stat & 1) return 0; // When power fail is detected, return with zero.
     20a:       80 91 69 01     lds     r24, 0x0169
     20e:       80 ff           sbrs    r24, 0
     210:       03 c0           rjmp    .+6             ; 0x218 <get_line+0x10>
     212:       80 e0           ldi     r24, 0x00       ; 0
     214:       90 e0           ldi     r25, 0x00       ; 0
     216:       08 95           ret
uint8_t uart_get ()
{
        uint8_t d, i;


        i = rxfifo.idx_r;
     218:       20 91 71 01     lds     r18, 0x0171
        if (rxfifo.count == 0) return 0;
     21c:       80 91 72 01     lds     r24, 0x0172
     220:       88 23           and     r24, r24
     222:       19 f4           brne    .+6             ; 0x22a <get_line+0x22>
     224:       20 e0           ldi     r18, 0x00       ; 0
     226:       30 e0           ldi     r19, 0x00       ; 0
     228:       15 c0           rjmp    .+42            ; 0x254 <get_line+0x4c>
        d = rxfifo.buff[i++];
     22a:       e2 2f           mov     r30, r18
     22c:       ff 27           eor     r31, r31
     22e:       e0 59           subi    r30, 0x90       ; 144
     230:       fe 4f           sbci    r31, 0xFE       ; 254
     232:       33 81           ldd     r19, Z+3        ; 0x03
     234:       e2 2f           mov     r30, r18
     236:       ef 5f           subi    r30, 0xFF       ; 255
        cli();
     238:       f8 94           cli
        rxfifo.count--;
     23a:       80 91 72 01     lds     r24, 0x0172
     23e:       81 50           subi    r24, 0x01       ; 1
     240:       80 93 72 01     sts     0x0172, r24
        sei();
     244:       78 94           sei
        if(i >= sizeof(rxfifo.buff))
     246:       e6 39           cpi     r30, 0x96       ; 150
     248:       08 f0           brcs    .+2             ; 0x24c <get_line+0x44>
     24a:       e0 e0           ldi     r30, 0x00       ; 0
                i = 0;
        rxfifo.idx_r = i;
     24c:       e0 93 71 01     sts     0x0171, r30

        return d;
     250:       23 2f           mov     r18, r19
     252:       33 27           eor     r19, r19


        for (;;) {
                if (Stat & 1) return 0; // When power fail is detected, return with zero.
                c = uart_get();
                if (Stat & 2) {                 // When buffer overflow has occured, restert to receive line.
     254:       80 91 69 01     lds     r24, 0x0169
     258:       81 ff           sbrs    r24, 1
     25a:       03 c0           rjmp    .+6             ; 0x262 <get_line+0x5a>
                        uart_init();
     25c:       0e 94 c0 00     call    0x180   ; 0x180 <uart_init>
     260:       d3 cf           rjmp    .-90            ; 0x208 <get_line>
        BYTE c, i = 0;


        for (;;) {
                if (Stat & 1) return 0; // When power fail is detected, return with zero.
                c = uart_get();
     262:       82 2f           mov     r24, r18
                if (Stat & 2) {                 // When buffer overflow has occured, restert to receive line.
                        uart_init();
                        i = 0; c = 0;
                }
                if (!c || (i == 0 && c != '$')) continue;
     264:       22 23           and     r18, r18
     266:       89 f2           breq    .-94            ; 0x20a <get_line+0x2>
     268:       99 23           and     r25, r25
     26a:       11 f4           brne    .+4             ; 0x270 <get_line+0x68>
     26c:       24 32           cpi     r18, 0x24       ; 36
     26e:       69 f6           brne    .-102           ; 0x20a <get_line+0x2>
                Buff[i++] = c;
     270:       e9 2f           mov     r30, r25
     272:       ff 27           eor     r31, r31
     274:       e9 5e           subi    r30, 0xE9       ; 233
     276:       fe 4f           sbci    r31, 0xFE       ; 254
     278:       20 83           st      Z, r18
     27a:       9f 5f           subi    r25, 0xFF       ; 255
                if (c == '\n') break;
     27c:       8a 30           cpi     r24, 0x0A       ; 10
     27e:       21 f0           breq    .+8             ; 0x288 <get_line+0x80>
                if (i >= sizeof(Buff)) i = 0;
     280:       92 35           cpi     r25, 0x52       ; 82
     282:       08 f0           brcs    .+2             ; 0x286 <get_line+0x7e>
     284:       c1 cf           rjmp    .-126           ; 0x208 <get_line>
     286:       c1 cf           rjmp    .-126           ; 0x20a <get_line+0x2>
        }
        return i;
     288:       89 2f           mov     r24, r25
     28a:       99 27           eor     r25, r25
}
     28c:       08 95           ret

0000028e <beep>:
/*--------------------------------------------------------------------------*/
/* Controls                                                                 */

static
void beep (BYTE len, BYTE cnt)
{
     28e:       98 2f           mov     r25, r24
     290:       0f c0           rjmp    .+30            ; 0x2b0 <beep+0x22>
        while (cnt--) {
                BEEP_ON();
     292:       83 e0           ldi     r24, 0x03       ; 3
     294:       85 bd           out     0x25, r24       ; 37
                DELAY(len);
     296:       90 93 16 01     sts     0x0116, r25
     29a:       80 91 16 01     lds     r24, 0x0116
     29e:       88 23           and     r24, r24
     2a0:       e1 f7           brne    .-8             ; 0x29a <beep+0xc>
                BEEP_OFF();
     2a2:       15 bc           out     0x25, r1        ; 37
                DELAY(len);
     2a4:       90 93 16 01     sts     0x0116, r25
     2a8:       80 91 16 01     lds     r24, 0x0116
     2ac:       88 23           and     r24, r24
     2ae:       e1 f7           brne    .-8             ; 0x2a8 <beep+0x1a>
/* Controls                                                                 */

static
void beep (BYTE len, BYTE cnt)
{
        while (cnt--) {
     2b0:       61 50           subi    r22, 0x01       ; 1
     2b2:       78 f7           brcc    .-34            ; 0x292 <beep+0x4>
     2b4:       08 95           ret

000002b6 <gp_comp>:


/* Compare sentence header string */
static
BYTE gp_comp (BYTE *str1, const prog_uint8_t *str2)
{
     2b6:       dc 01           movw    r26, r24
     2b8:       fb 01           movw    r30, r22
        BYTE c;

        do {
                c = pgm_read_byte(str2++);
     2ba:       6f 5f           subi    r22, 0xFF       ; 255
     2bc:       7f 4f           sbci    r23, 0xFF       ; 255
     2be:       94 91           lpm     r25, Z
        } while (c && c == *str1++);
     2c0:       99 23           and     r25, r25
     2c2:       29 f0           breq    .+10            ; 0x2ce <gp_comp+0x18>
     2c4:       8c 91           ld      r24, X
     2c6:       98 17           cp      r25, r24
     2c8:       11 f4           brne    .+4             ; 0x2ce <gp_comp+0x18>
     2ca:       11 96           adiw    r26, 0x01       ; 1
     2cc:       f5 cf           rjmp    .-22            ; 0x2b8 <gp_comp+0x2>
        return c;
}
     2ce:       89 2f           mov     r24, r25
     2d0:       99 27           eor     r25, r25
     2d2:       08 95           ret

000002d4 <gp_col>:
/* Get a column item */
static
BYTE* gp_col (                  /* Returns pointer to the item (returns a NULL when not found) */
        const BYTE* buf,        /* Pointer to the sentence */
        BYTE col                        /* Column number (0 is the 1st item) */
) {
     2d4:       fc 01           movw    r30, r24
     2d6:       0a c0           rjmp    .+20            ; 0x2ec <gp_col+0x18>
        BYTE c;


        while (col) {
                do {
                        c = *buf++;
     2d8:       80 81           ld      r24, Z
                        if (c <= ' ') return NULL;
     2da:       81 32           cpi     r24, 0x21       ; 33
     2dc:       18 f4           brcc    .+6             ; 0x2e4 <gp_col+0x10>
     2de:       80 e0           ldi     r24, 0x00       ; 0
     2e0:       90 e0           ldi     r25, 0x00       ; 0
     2e2:       08 95           ret
        BYTE c;


        while (col) {
                do {
                        c = *buf++;
     2e4:       31 96           adiw    r30, 0x01       ; 1
                        if (c <= ' ') return NULL;
                } while (c != ',');
     2e6:       8c 32           cpi     r24, 0x2C       ; 44
     2e8:       b9 f7           brne    .-18            ; 0x2d8 <gp_col+0x4>
                col--;
     2ea:       61 50           subi    r22, 0x01       ; 1
        BYTE col                        /* Column number (0 is the 1st item) */
) {
        BYTE c;


        while (col) {
     2ec:       66 23           and     r22, r22
     2ee:       a1 f7           brne    .-24            ; 0x2d8 <gp_col+0x4>
                        c = *buf++;
                        if (c <= ' ') return NULL;
                } while (c != ',');
                col--;
        }
        return (BYTE*)buf;
     2f0:       cf 01           movw    r24, r30
}
     2f2:       08 95           ret

000002f4 <__vector_11>:
/* 100Hz timer interrupt generated by OC1A                 */
/*---------------------------------------------------------*/


ISR(TIMER1_COMPA_vect)
{
     2f4:       1f 92           push    r1
     2f6:       0f 92           push    r0
     2f8:       0f b6           in      r0, 0x3f        ; 63
     2fa:       0f 92           push    r0
     2fc:       11 24           eor     r1, r1
     2fe:       2f 93           push    r18
     300:       3f 93           push    r19
     302:       4f 93           push    r20
     304:       5f 93           push    r21
     306:       6f 93           push    r22
     308:       7f 93           push    r23
     30a:       8f 93           push    r24
     30c:       9f 93           push    r25
     30e:       af 93           push    r26
     310:       bf 93           push    r27
     312:       ef 93           push    r30
     314:       ff 93           push    r31
        BYTE n;
        static WORD ivt_sync;


        n = Timer;
     316:       80 91 16 01     lds     r24, 0x0116
        if (n) Timer = n - 1;
     31a:       88 23           and     r24, r24
     31c:       19 f0           breq    .+6             ; 0x324 <__vector_11+0x30>
     31e:       81 50           subi    r24, 0x01       ; 1
     320:       80 93 16 01     sts     0x0116, r24

        if (++ivt_sync >= 180 * 100) {
     324:       80 91 06 01     lds     r24, 0x0106
     328:       90 91 07 01     lds     r25, 0x0107
     32c:       01 96           adiw    r24, 0x01       ; 1
     32e:       90 93 07 01     sts     0x0107, r25
     332:       80 93 06 01     sts     0x0106, r24
     336:       80 55           subi    r24, 0x50       ; 80
     338:       96 44           sbci    r25, 0x46       ; 70
     33a:       48 f0           brcs    .+18            ; 0x34e <__vector_11+0x5a>
                ivt_sync = 0;
     33c:       10 92 07 01     sts     0x0107, r1
     340:       10 92 06 01     sts     0x0106, r1
                Stat |= 4;
     344:       80 91 69 01     lds     r24, 0x0169
     348:       84 60           ori     r24, 0x04       ; 4
     34a:       80 93 69 01     sts     0x0169, r24
        }

        disk_timerproc();       /* Drive timer procedure of low level disk I/O module */
     34e:       0e 94 c8 0d     call    0x1b90  ; 0x1b90 <disk_timerproc>
     352:       ff 91           pop     r31
     354:       ef 91           pop     r30
     356:       bf 91           pop     r27
     358:       af 91           pop     r26
     35a:       9f 91           pop     r25
     35c:       8f 91           pop     r24
     35e:       7f 91           pop     r23
     360:       6f 91           pop     r22
     362:       5f 91           pop     r21
     364:       4f 91           pop     r20
     366:       3f 91           pop     r19
     368:       2f 91           pop     r18
     36a:       0f 90           pop     r0
     36c:       0f be           out     0x3f, r0        ; 63
     36e:       0f 90           pop     r0
     370:       1f 90           pop     r1
     372:       18 95           reti

00000374 <main>:
/*-----------------------------------------------------------------------*/
/* Main                                                                  */


int main ()
{
     374:       cd ef           ldi     r28, 0xFD       ; 253
     376:       d4 e0           ldi     r29, 0x04       ; 4
     378:       de bf           out     0x3e, r29       ; 62
     37a:       cd bf           out     0x3d, r28       ; 61


static
void ioinit (void)
{
        PORTB = 0b00001101;             // Port B
     37c:       8d e0           ldi     r24, 0x0D       ; 13
     37e:       85 b9           out     0x05, r24       ; 5
        DDRB  = 0b00101110;
     380:       8e e2           ldi     r24, 0x2E       ; 46
     382:       84 b9           out     0x04, r24       ; 4
        PORTC = 0b00111111;             // Port C
     384:       8f e3           ldi     r24, 0x3F       ; 63
     386:       88 b9           out     0x08, r24       ; 8
        DDRC  = 0b00000000;
     388:       17 b8           out     0x07, r1        ; 7
        PORTD = 0b10101110;             // Port D
     38a:       8e ea           ldi     r24, 0xAE       ; 174
     38c:       8b b9           out     0x0b, r24       ; 11
        DDRD  = 0b01010010;
     38e:       82 e5           ldi     r24, 0x52       ; 82
     390:       8a b9           out     0x0a, r24       ; 10

        SPCR = 0b01010000;                      /* Initialize SPI port (Mode 0) */
     392:       80 e5           ldi     r24, 0x50       ; 80
     394:       8c bd           out     0x2c, r24       ; 44
        SPSR = 0b00000001;
     396:       81 e0           ldi     r24, 0x01       ; 1
     398:       8d bd           out     0x2d, r24       ; 45

        OCR1A = SYSCLK/8/100-1;         // Timer1: 100Hz interval (OC1A)
     39a:       83 ed           ldi     r24, 0xD3       ; 211
     39c:       90 e3           ldi     r25, 0x30       ; 48
     39e:       90 93 89 00     sts     0x0089, r25
     3a2:       80 93 88 00     sts     0x0088, r24
        TCCR1B = 0b00001010;
     3a6:       8a e0           ldi     r24, 0x0A       ; 10
     3a8:       80 93 81 00     sts     0x0081, r24
        TIMSK1 = _BV(OCIE1A);           // Enable TC1.oca interrupt
     3ac:       82 e0           ldi     r24, 0x02       ; 2
     3ae:       80 93 6f 00     sts     0x006F, r24

        OCR0A = SYSCLK/64/4000/2-1;     // Timer0: 4kHz sound (OC0A)
     3b2:       82 e1           ldi     r24, 0x12       ; 18
     3b4:       87 bd           out     0x27, r24       ; 39
        TCCR0A = 0b01000010;
     3b6:       82 e4           ldi     r24, 0x42       ; 66
     3b8:       84 bd           out     0x24, r24       ; 36

        ADMUX = POWER_check;            // Select ADC input
     3ba:       81 e4           ldi     r24, 0x41       ; 65
     3bc:       80 93 7c 00     sts     0x007C, r24
        ADCSRA = _BV(ADEN)|_BV(ADSC)|_BV(ADIF)|_BV(ADIE)|0b111;
     3c0:       8f ed           ldi     r24, 0xDF       ; 223
     3c2:       80 93 7a 00     sts     0x007A, r24

        sei();
     3c6:       78 94           sei
        BYTE b, err, *p = NULL;
        WORD s;


        ioinit();
        f_mount(0, &fatfs);                                     /* Enable file I/O layer */
     3c8:       67 e2           ldi     r22, 0x27       ; 39
     3ca:       72 e0           ldi     r23, 0x02       ; 2
     3cc:       80 e0           ldi     r24, 0x00       ; 0
     3ce:       0e 94 ef 08     call    0x11de  ; 0x11de <f_mount>
     3d2:       cc 24           eor     r12, r12
     3d4:       dd 24           eor     r13, r13
     3d6:       47 e1           ldi     r20, 0x17       ; 23
     3d8:       e4 2e           mov     r14, r20
     3da:       41 e0           ldi     r20, 0x01       ; 1
     3dc:       f4 2e           mov     r15, r20
     3de:       3b e0           ldi     r19, 0x0B       ; 11
     3e0:       a3 2e           mov     r10, r19
     3e2:       32 e0           ldi     r19, 0x02       ; 2
     3e4:       b3 2e           mov     r11, r19
                        //      || !gp_comp(Buff, PSTR("$GPGSV"))
                        //      || !gp_comp(Buff, PSTR("$GPZDA"))
                        //      || !gp_comp(Buff, PSTR("$GPVTG"))
                        ) 
                        {
                                if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
     3e6:       2e 01           movw    r4, r28
     3e8:       08 94           sec
     3ea:       41 1c           adc     r4, r1
     3ec:       51 1c           adc     r5, r1
     3ee:       22 e1           ldi     r18, 0x12       ; 18
     3f0:       62 2e           mov     r6, r18
     3f2:       21 e0           ldi     r18, 0x01       ; 1
     3f4:       72 2e           mov     r7, r18
     3f6:       9a e6           ldi     r25, 0x6A       ; 106
     3f8:       89 2e           mov     r8, r25
     3fa:       91 e0           ldi     r25, 0x01       ; 1
     3fc:       99 2e           mov     r9, r25
     3fe:       89 e0           ldi     r24, 0x09       ; 9
     400:       28 2e           mov     r2, r24
     402:       31 2c           mov     r3, r1
     404:       2e 0c           add     r2, r14
     406:       3f 1c           adc     r3, r15


static
void uart_stop (void)
{
        UCSR0B = 0;
     408:       10 92 c1 00     sts     0x00C1, r1
        ioinit();
        f_mount(0, &fatfs);                                     /* Enable file I/O layer */

        for (;;) {
                uart_stop();
                GPS_OFF();
     40c:       29 98           cbi     0x05, 1 ; 5
                Timer = 100;
     40e:       84 e6           ldi     r24, 0x64       ; 100
     410:       80 93 16 01     sts     0x0116, r24
                do {
                        if (Stat & 1) Timer = 100;
     414:       80 91 69 01     lds     r24, 0x0169
     418:       80 ff           sbrs    r24, 0
     41a:       03 c0           rjmp    .+6             ; 0x422 <main+0xae>
     41c:       84 e6           ldi     r24, 0x64       ; 100
     41e:       80 93 16 01     sts     0x0116, r24
                } while (Timer);
     422:       80 91 16 01     lds     r24, 0x0116
     426:       88 23           and     r24, r24
     428:       a9 f7           brne    .-22            ; 0x414 <main+0xa0>

                GPS_ON();
     42a:       29 9a           sbi     0x05, 1 ; 5
                Timer = 255;
     42c:       8f ef           ldi     r24, 0xFF       ; 255
     42e:       80 93 16 01     sts     0x0116, r24
                do {
                        if ((Stat & 1) || (disk_status(0) & STA_NODISK))  Timer = 255;
     432:       80 91 69 01     lds     r24, 0x0169
     436:       80 fd           sbrc    r24, 0
     438:       05 c0           rjmp    .+10            ; 0x444 <main+0xd0>
     43a:       80 e0           ldi     r24, 0x00       ; 0
     43c:       0e 94 bf 0d     call    0x1b7e  ; 0x1b7e <disk_status>
     440:       81 ff           sbrs    r24, 1
     442:       03 c0           rjmp    .+6             ; 0x44a <main+0xd6>
     444:       8f ef           ldi     r24, 0xFF       ; 255
     446:       80 93 16 01     sts     0x0116, r24
                } while (Timer);
     44a:       80 91 16 01     lds     r24, 0x0116
     44e:       88 23           and     r24, r24
     450:       81 f7           brne    .-32            ; 0x432 <main+0xbe>

                beep(5, 1);             // Single beep. Start to get current time.
     452:       61 e0           ldi     r22, 0x01       ; 1
     454:       85 e0           ldi     r24, 0x05       ; 5
     456:       0e 94 47 01     call    0x28e   ; 0x28e <beep>
                uart_init();
     45a:       0e 94 c0 00     call    0x180   ; 0x180 <uart_init>
/* Initialize GPS module (depends on each product) */
static
void gp_init (void)
{
        const prog_char *s =
                PSTR("$PSRF106,21*0F\r\n");     // Select datum of WGS84 (for EM-406A)
     45e:       27 e8           ldi     r18, 0x87       ; 135
     460:       30 e0           ldi     r19, 0x00       ; 0
     462:       06 c0           rjmp    .+12            ; 0x470 <main+0xfc>

/* Put a character to transmit */
static
void uart_put (uint8_t d)
{
        while (bit_is_clear(UCSR0A, UDRE0));
     464:       80 91 c0 00     lds     r24, 0x00C0
     468:       85 ff           sbrs    r24, 5
     46a:       fc cf           rjmp    .-8             ; 0x464 <main+0xf0>
        UDR0 = d;
     46c:       90 93 c6 00     sts     0x00C6, r25
     470:       f9 01           movw    r30, r18
{
        const prog_char *s =
                PSTR("$PSRF106,21*0F\r\n");     // Select datum of WGS84 (for EM-406A)
        char c;

        while ((c = pgm_read_byte(s++)) != 0) uart_put(c);
     472:       2f 5f           subi    r18, 0xFF       ; 255
     474:       3f 4f           sbci    r19, 0xFF       ; 255
     476:       94 91           lpm     r25, Z
     478:       99 23           and     r25, r25
     47a:       a1 f7           brne    .-24            ; 0x464 <main+0xf0>

                beep(5, 1);             // Single beep. Start to get current time.
                uart_init();
                gp_init();              // Initialize GPS module to let output data in NMEA-0183 format.
                do {                    // Wait for valid RMC sentence.
                        b = get_line();
     47c:       0e 94 04 01     call    0x208   ; 0x208 <get_line>
                        if (!b) break;
     480:       88 23           and     r24, r24
     482:       09 f4           brne    .+2             ; 0x486 <main+0x112>
     484:       c1 cf           rjmp    .-126           ; 0x408 <main+0x94>
                        if (gp_comp(Buff, PSTR("$GPRMC"))) continue;
     486:       60 e8           ldi     r22, 0x80       ; 128
     488:       70 e0           ldi     r23, 0x00       ; 0
     48a:       c7 01           movw    r24, r14
     48c:       0e 94 5b 01     call    0x2b6   ; 0x2b6 <gp_comp>
     490:       88 23           and     r24, r24
     492:       29 f4           brne    .+10            ; 0x49e <main+0x12a>
                        p = gp_col(Buff,2);
     494:       62 e0           ldi     r22, 0x02       ; 2
     496:       c7 01           movw    r24, r14
     498:       0e 94 6a 01     call    0x2d4   ; 0x2d4 <gp_col>
     49c:       6c 01           movw    r12, r24
                } while (!p || *p != 'A');
     49e:       c1 14           cp      r12, r1
     4a0:       d1 04           cpc     r13, r1
     4a2:       61 f3           breq    .-40            ; 0x47c <main+0x108>
     4a4:       f6 01           movw    r30, r12
     4a6:       80 81           ld      r24, Z
     4a8:       81 34           cpi     r24, 0x41       ; 65
     4aa:       41 f7           brne    .-48            ; 0x47c <main+0x108>
                if (!b) continue;
                p = gp_col(Buff,9);             // Open log file with the name of current date (YYMMDD.log in UTC).
     4ac:       69 e0           ldi     r22, 0x09       ; 9
     4ae:       c7 01           movw    r24, r14
     4b0:       0e 94 6a 01     call    0x2d4   ; 0x2d4 <gp_col>
     4b4:       6c 01           movw    r12, r24
                
                if (!p) {err = 3; break;}
     4b6:       00 97           sbiw    r24, 0x00       ; 0
     4b8:       11 f4           brne    .+4             ; 0x4be <main+0x14a>
     4ba:       63 e0           ldi     r22, 0x03       ; 3
     4bc:       a8 c0           rjmp    .+336           ; 0x60e <__stack+0x10f>

                memcpy(&Buff[0], p+4, 2);
     4be:       fc 01           movw    r30, r24
     4c0:       84 81           ldd     r24, Z+4        ; 0x04
     4c2:       95 81           ldd     r25, Z+5        ; 0x05
     4c4:       90 93 18 01     sts     0x0118, r25
     4c8:       80 93 17 01     sts     0x0117, r24
                memcpy(&Buff[2], p+2, 2);
     4cc:       82 81           ldd     r24, Z+2        ; 0x02
     4ce:       93 81           ldd     r25, Z+3        ; 0x03
     4d0:       90 93 1a 01     sts     0x011A, r25
     4d4:       80 93 19 01     sts     0x0119, r24
                memcpy(&Buff[4], p+0, 2);
     4d8:       80 81           ld      r24, Z
     4da:       91 81           ldd     r25, Z+1        ; 0x01
     4dc:       90 93 1c 01     sts     0x011C, r25
     4e0:       80 93 1b 01     sts     0x011B, r24
                strcpy_P(&Buff[6], PSTR(".log"));
     4e4:       6b e7           ldi     r22, 0x7B       ; 123
     4e6:       70 e0           ldi     r23, 0x00       ; 0
     4e8:       8d e1           ldi     r24, 0x1D       ; 29
     4ea:       91 e0           ldi     r25, 0x01       ; 1
     4ec:       0e 94 8d 10     call    0x211a  ; 0x211a <strcpy_P>
                if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }
     4f0:       42 e1           ldi     r20, 0x12       ; 18
     4f2:       b7 01           movw    r22, r14
     4f4:       c5 01           movw    r24, r10
     4f6:       0e 94 44 09     call    0x1288  ; 0x1288 <f_open>
     4fa:       89 2b           or      r24, r25
     4fc:       09 f0           breq    .+2             ; 0x500 <__stack+0x1>
     4fe:       86 c0           rjmp    .+268           ; 0x60c <__stack+0x10d>
     500:       40 91 15 02     lds     r20, 0x0215
     504:       50 91 16 02     lds     r21, 0x0216
     508:       60 91 17 02     lds     r22, 0x0217
     50c:       70 91 18 02     lds     r23, 0x0218
     510:       c5 01           movw    r24, r10
     512:       0e 94 8b 05     call    0xb16   ; 0xb16 <f_lseek>
     516:       89 2b           or      r24, r25
     518:       09 f0           breq    .+2             ; 0x51c <__stack+0x1d>
     51a:       78 c0           rjmp    .+240           ; 0x60c <__stack+0x10d>

                beep(5, 2);             // Two beeps. Start logging.
     51c:       62 e0           ldi     r22, 0x02       ; 2
     51e:       85 e0           ldi     r24, 0x05       ; 5
     520:       0e 94 47 01     call    0x28e   ; 0x28e <beep>
     524:       65 c0           rjmp    .+202           ; 0x5f0 <__stack+0xf1>
                err = 0;
                while ((b = get_line()) > 0) {
                        if (   !gp_comp(Buff, PSTR("$GPGGA"))   // Which sentence is logged?
     526:       64 e7           ldi     r22, 0x74       ; 116
     528:       70 e0           ldi     r23, 0x00       ; 0
     52a:       c7 01           movw    r24, r14
     52c:       0e 94 5b 01     call    0x2b6   ; 0x2b6 <gp_comp>
     530:       88 23           and     r24, r24
     532:       41 f0           breq    .+16            ; 0x544 <__stack+0x45>
     534:       6d e6           ldi     r22, 0x6D       ; 109
     536:       70 e0           ldi     r23, 0x00       ; 0
     538:       c7 01           movw    r24, r14
     53a:       0e 94 5b 01     call    0x2b6   ; 0x2b6 <gp_comp>
     53e:       88 23           and     r24, r24
     540:       09 f0           breq    .+2             ; 0x544 <__stack+0x45>
     542:       44 c0           rjmp    .+136           ; 0x5cc <__stack+0xcd>
                        //      || !gp_comp(Buff, PSTR("$GPGSV"))
                        //      || !gp_comp(Buff, PSTR("$GPZDA"))
                        //      || !gp_comp(Buff, PSTR("$GPVTG"))
                        ) 
                        {
                                if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
     544:       01 2f           mov     r16, r17
     546:       11 27           eor     r17, r17
     548:       92 01           movw    r18, r4
     54a:       a8 01           movw    r20, r16
     54c:       b7 01           movw    r22, r14
     54e:       c5 01           movw    r24, r10
     550:       0e 94 c0 06     call    0xd80   ; 0xd80 <f_write>
     554:       89 2b           or      r24, r25
     556:       09 f0           breq    .+2             ; 0x55a <__stack+0x5b>
     558:       52 c0           rjmp    .+164           ; 0x5fe <__stack+0xff>
     55a:       89 81           ldd     r24, Y+1        ; 0x01
     55c:       9a 81           ldd     r25, Y+2        ; 0x02
     55e:       08 17           cp      r16, r24
     560:       19 07           cpc     r17, r25
     562:       09 f0           breq    .+2             ; 0x566 <__stack+0x67>
     564:       4c c0           rjmp    .+152           ; 0x5fe <__stack+0xff>
                                itoa(battery,&Value1,10);
     566:       4a e0           ldi     r20, 0x0A       ; 10
     568:       50 e0           ldi     r21, 0x00       ; 0
     56a:       b3 01           movw    r22, r6
     56c:       80 91 6e 01     lds     r24, 0x016E
     570:       90 91 6f 01     lds     r25, 0x016F
     574:       0e 94 b8 10     call    0x2170  ; 0x2170 <itoa>
                                itoa(intensity,&Value2,10);
     578:       4a e0           ldi     r20, 0x0A       ; 10
     57a:       50 e0           ldi     r21, 0x00       ; 0
     57c:       b4 01           movw    r22, r8
     57e:       80 91 09 02     lds     r24, 0x0209
     582:       90 91 0a 02     lds     r25, 0x020A
     586:       0e 94 b8 10     call    0x2170  ; 0x2170 <itoa>
                                strcpy(&Buff[0], Value1);
     58a:       b3 01           movw    r22, r6
     58c:       c7 01           movw    r24, r14
     58e:       0e 94 b1 10     call    0x2162  ; 0x2162 <strcpy>
                                strcpy_P(&Buff[4], PSTR(","));
     592:       6b e6           ldi     r22, 0x6B       ; 107
     594:       70 e0           ldi     r23, 0x00       ; 0
     596:       8b e1           ldi     r24, 0x1B       ; 27
     598:       91 e0           ldi     r25, 0x01       ; 1
     59a:       0e 94 8d 10     call    0x211a  ; 0x211a <strcpy_P>
                                strcpy(&Buff[5], Value2);
     59e:       b4 01           movw    r22, r8
     5a0:       8c e1           ldi     r24, 0x1C       ; 28
     5a2:       91 e0           ldi     r25, 0x01       ; 1
     5a4:       0e 94 b1 10     call    0x2162  ; 0x2162 <strcpy>
                                strcpy_P(&Buff[9], PSTR("\r\n"));
     5a8:       68 e6           ldi     r22, 0x68       ; 104
     5aa:       70 e0           ldi     r23, 0x00       ; 0
     5ac:       c1 01           movw    r24, r2
     5ae:       0e 94 8d 10     call    0x211a  ; 0x211a <strcpy_P>
                                if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 5; break; };
     5b2:       92 01           movw    r18, r4
     5b4:       4b e0           ldi     r20, 0x0B       ; 11
     5b6:       50 e0           ldi     r21, 0x00       ; 0
     5b8:       b7 01           movw    r22, r14
     5ba:       c5 01           movw    r24, r10
     5bc:       0e 94 c0 06     call    0xd80   ; 0xd80 <f_write>
     5c0:       89 2b           or      r24, r25
     5c2:       e9 f4           brne    .+58            ; 0x5fe <__stack+0xff>
     5c4:       89 81           ldd     r24, Y+1        ; 0x01
     5c6:       9a 81           ldd     r25, Y+2        ; 0x02
     5c8:       0b 97           sbiw    r24, 0x0b       ; 11
     5ca:       c9 f4           brne    .+50            ; 0x5fe <__stack+0xff>
                        }
                        if ((Stat & 4) == 0) continue;
     5cc:       80 91 69 01     lds     r24, 0x0169
     5d0:       82 ff           sbrs    r24, 2
     5d2:       0e c0           rjmp    .+28            ; 0x5f0 <__stack+0xf1>
                        if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec.
     5d4:       c5 01           movw    r24, r10
     5d6:       0e 94 5d 06     call    0xcba   ; 0xcba <f_sync>
     5da:       89 2b           or      r24, r25
     5dc:       11 f0           breq    .+4             ; 0x5e2 <__stack+0xe3>
     5de:       66 e0           ldi     r22, 0x06       ; 6
     5e0:       16 c0           rjmp    .+44            ; 0x60e <__stack+0x10f>
                        cli(); Stat &= 0xFB; sei();                             // Clear sync request
     5e2:       f8 94           cli
     5e4:       80 91 69 01     lds     r24, 0x0169
     5e8:       8b 7f           andi    r24, 0xFB       ; 251
     5ea:       80 93 69 01     sts     0x0169, r24
     5ee:       78 94           sei
                strcpy_P(&Buff[6], PSTR(".log"));
                if (f_open(&file1, Buff, FA_OPEN_ALWAYS | FA_WRITE) || f_lseek(&file1, file1.fsize)) { err = 4; break; }

                beep(5, 2);             // Two beeps. Start logging.
                err = 0;
                while ((b = get_line()) > 0) {
     5f0:       0e 94 04 01     call    0x208   ; 0x208 <get_line>
     5f4:       18 2f           mov     r17, r24
     5f6:       88 23           and     r24, r24
     5f8:       09 f0           breq    .+2             ; 0x5fc <__stack+0xfd>
     5fa:       95 cf           rjmp    .-214           ; 0x526 <__stack+0x27>
     5fc:       0f c0           rjmp    .+30            ; 0x61c <__stack+0x11d>
     5fe:       65 e0           ldi     r22, 0x05       ; 5
     600:       06 c0           rjmp    .+12            ; 0x60e <__stack+0x10f>
                uart_stop();
                GPS_OFF();
                if (f_close(&file1)) { err = 7; break; };

                // When a long beep is sounded, the shutdoun process has been succeeded.
                beep(50, 1);
     602:       61 e0           ldi     r22, 0x01       ; 1
     604:       82 e3           ldi     r24, 0x32       ; 50
     606:       0e 94 47 01     call    0x28e   ; 0x28e <beep>
     60a:       fe ce           rjmp    .-516           ; 0x408 <main+0x94>
     60c:       64 e0           ldi     r22, 0x04       ; 4


static
void uart_stop (void)
{
        UCSR0B = 0;
     60e:       10 92 c1 00     sts     0x00C1, r1
                beep(50, 1);
        }

        // Unrecoverble error. Enter shutdown state.
        uart_stop();
        GPS_OFF();
     612:       29 98           cbi     0x05, 1 ; 5
        beep(25, err);
     614:       89 e1           ldi     r24, 0x19       ; 25
     616:       0e 94 47 01     call    0x28e   ; 0x28e <beep>
     61a:       ff cf           rjmp    .-2             ; 0x61a <__stack+0x11b>


static
void uart_stop (void)
{
        UCSR0B = 0;
     61c:       10 92 c1 00     sts     0x00C1, r1
                }
                if (err) break;

                // Turn-off GPS power and close the log file by power supply is discharged.
                uart_stop();
                GPS_OFF();
     620:       29 98           cbi     0x05, 1 ; 5
                if (f_close(&file1)) { err = 7; break; };
     622:       c5 01           movw    r24, r10
     624:       0e 94 b4 06     call    0xd68   ; 0xd68 <f_close>
     628:       89 2b           or      r24, r25
     62a:       59 f3           breq    .-42            ; 0x602 <__stack+0x103>
     62c:       67 e0           ldi     r22, 0x07       ; 7
     62e:       ef cf           rjmp    .-34            ; 0x60e <__stack+0x10f>

00000630 <clust2sect>:

static
DWORD clust2sect (      /* !=0: sector number, 0: failed - invalid cluster# */
        CLUST clust             /* Cluster# to be converted */
)
{
     630:       cf 93           push    r28
     632:       df 93           push    r29
        FATFS *fs = FatFs;
     634:       c0 91 0a 01     lds     r28, 0x010A
     638:       d0 91 0b 01     lds     r29, 0x010B


        clust -= 2;
     63c:       bc 01           movw    r22, r24
     63e:       62 50           subi    r22, 0x02       ; 2
     640:       70 40           sbci    r23, 0x00       ; 0
        if (clust >= (fs->max_clust - 2)) return 0;             /* Invalid cluster# */
     642:       8e 89           ldd     r24, Y+22       ; 0x16
     644:       9f 89           ldd     r25, Y+23       ; 0x17
     646:       02 97           sbiw    r24, 0x02       ; 2
     648:       68 17           cp      r22, r24
     64a:       79 07           cpc     r23, r25
     64c:       28 f0           brcs    .+10            ; 0x658 <clust2sect+0x28>
     64e:       20 e0           ldi     r18, 0x00       ; 0
     650:       30 e0           ldi     r19, 0x00       ; 0
     652:       40 e0           ldi     r20, 0x00       ; 0
     654:       50 e0           ldi     r21, 0x00       ; 0
     656:       12 c0           rjmp    .+36            ; 0x67c <clust2sect+0x4c>
        return (DWORD)clust * fs->sects_clust + fs->database;
     658:       88 27           eor     r24, r24
     65a:       99 27           eor     r25, r25
     65c:       2d 8d           ldd     r18, Y+29       ; 0x1d
     65e:       33 27           eor     r19, r19
     660:       44 27           eor     r20, r20
     662:       55 27           eor     r21, r21
     664:       0e 94 e9 10     call    0x21d2  ; 0x21d2 <__mulsi3>
     668:       9b 01           movw    r18, r22
     66a:       ac 01           movw    r20, r24
     66c:       88 89           ldd     r24, Y+16       ; 0x10
     66e:       99 89           ldd     r25, Y+17       ; 0x11
     670:       aa 89           ldd     r26, Y+18       ; 0x12
     672:       bb 89           ldd     r27, Y+19       ; 0x13
     674:       28 0f           add     r18, r24
     676:       39 1f           adc     r19, r25
     678:       4a 1f           adc     r20, r26
     67a:       5b 1f           adc     r21, r27
}
     67c:       ca 01           movw    r24, r20
     67e:       b9 01           movw    r22, r18
     680:       df 91           pop     r29
     682:       cf 91           pop     r28
     684:       08 95           ret

00000686 <validate>:
static
FRESULT validate (              /* FR_OK(0): The id is valid, !=0: Not valid */
        const FATFS *fs,        /* Pointer to the file system object */
        WORD id                         /* id member of the target object to be checked */
)
{
     686:       fc 01           movw    r30, r24
        if (!fs || fs->id != id)
     688:       89 2b           or      r24, r25
     68a:       61 f0           breq    .+24            ; 0x6a4 <validate+0x1e>
     68c:       80 81           ld      r24, Z
     68e:       91 81           ldd     r25, Z+1        ; 0x01
     690:       86 17           cp      r24, r22
     692:       97 07           cpc     r25, r23
     694:       39 f4           brne    .+14            ; 0x6a4 <validate+0x1e>
                return FR_INVALID_OBJECT;
        if (disk_status(0) & STA_NOINIT)
     696:       80 e0           ldi     r24, 0x00       ; 0
     698:       0e 94 bf 0d     call    0x1b7e  ; 0x1b7e <disk_status>
     69c:       99 27           eor     r25, r25
     69e:       81 70           andi    r24, 0x01       ; 1
     6a0:       90 70           andi    r25, 0x00       ; 0
     6a2:       08 95           ret
     6a4:       8c e0           ldi     r24, 0x0C       ; 12
     6a6:       90 e0           ldi     r25, 0x00       ; 0
                return FR_NOT_READY;

        return FR_OK;
}
     6a8:       08 95           ret

000006aa <move_window>:

static
BOOL move_window (              /* TRUE: successful, FALSE: failed */
        DWORD sector            /* Sector number to make apperance in the FatFs->win */
)                                               /* Move to zero only writes back dirty window */
{
     6aa:       a0 e0           ldi     r26, 0x00       ; 0
     6ac:       b0 e0           ldi     r27, 0x00       ; 0
     6ae:       eb e5           ldi     r30, 0x5B       ; 91
     6b0:       f3 e0           ldi     r31, 0x03       ; 3
     6b2:       0c 94 2e 11     jmp     0x225c  ; 0x225c <__prologue_saves__+0x8>
     6b6:       4b 01           movw    r8, r22
     6b8:       5c 01           movw    r10, r24
        DWORD wsect;
        FATFS *fs = FatFs;
     6ba:       c0 91 0a 01     lds     r28, 0x010A
     6be:       d0 91 0b 01     lds     r29, 0x010B


        wsect = fs->winsect;
     6c2:       cc 80           ldd     r12, Y+4        ; 0x04
     6c4:       dd 80           ldd     r13, Y+5        ; 0x05
     6c6:       ee 80           ldd     r14, Y+6        ; 0x06
     6c8:       ff 80           ldd     r15, Y+7        ; 0x07
        if (wsect != sector) {  /* Changed current window */
     6ca:       c6 16           cp      r12, r22
     6cc:       d7 06           cpc     r13, r23
     6ce:       e8 06           cpc     r14, r24
     6d0:       f9 06           cpc     r15, r25
     6d2:       09 f4           brne    .+2             ; 0x6d6 <move_window+0x2c>
     6d4:       4f c0           rjmp    .+158           ; 0x774 <move_window+0xca>
#if !_FS_READONLY
                BYTE n;
                if (fs->winflag) {      /* Write back dirty window if needed */
     6d6:       8f 8d           ldd     r24, Y+31       ; 0x1f
     6d8:       88 23           and     r24, r24
     6da:       a1 f1           breq    .+104           ; 0x744 <move_window+0x9a>
                        if (disk_write(0, fs->win, wsect, 1) != RES_OK)
     6dc:       80 e2           ldi     r24, 0x20       ; 32
     6de:       68 2e           mov     r6, r24
     6e0:       71 2c           mov     r7, r1
     6e2:       6c 0e           add     r6, r28
     6e4:       7d 1e           adc     r7, r29
     6e6:       01 e0           ldi     r16, 0x01       ; 1
     6e8:       a7 01           movw    r20, r14
     6ea:       96 01           movw    r18, r12
     6ec:       b3 01           movw    r22, r6
     6ee:       80 e0           ldi     r24, 0x00       ; 0
     6f0:       0e 94 d3 0e     call    0x1da6  ; 0x1da6 <disk_write>
     6f4:       89 2b           or      r24, r25
     6f6:       d9 f5           brne    .+118           ; 0x76e <move_window+0xc4>
                                return FALSE;
                        fs->winflag = 0;
     6f8:       1f 8e           std     Y+31, r1        ; 0x1f
                        if (wsect < (fs->fatbase + fs->sects_fat)) {    /* In FAT area */
     6fa:       8c 89           ldd     r24, Y+20       ; 0x14
     6fc:       9d 89           ldd     r25, Y+21       ; 0x15
     6fe:       aa 27           eor     r26, r26
     700:       bb 27           eor     r27, r27
     702:       28 85           ldd     r18, Y+8        ; 0x08
     704:       39 85           ldd     r19, Y+9        ; 0x09
     706:       4a 85           ldd     r20, Y+10       ; 0x0a
     708:       5b 85           ldd     r21, Y+11       ; 0x0b
     70a:       82 0f           add     r24, r18
     70c:       93 1f           adc     r25, r19
     70e:       a4 1f           adc     r26, r20
     710:       b5 1f           adc     r27, r21
     712:       c8 16           cp      r12, r24
     714:       d9 06           cpc     r13, r25
     716:       ea 06           cpc     r14, r26
     718:       fb 06           cpc     r15, r27
     71a:       a0 f4           brcc    .+40            ; 0x744 <move_window+0x9a>
                                for (n = fs->n_fats; n >= 2; n--) {     /* Refrect the change to all FAT copies */
     71c:       1e 8d           ldd     r17, Y+30       ; 0x1e
     71e:       10 c0           rjmp    .+32            ; 0x740 <move_window+0x96>
                                        wsect += fs->sects_fat;
     720:       8c 89           ldd     r24, Y+20       ; 0x14
     722:       9d 89           ldd     r25, Y+21       ; 0x15
     724:       aa 27           eor     r26, r26
     726:       bb 27           eor     r27, r27
     728:       c8 0e           add     r12, r24
     72a:       d9 1e           adc     r13, r25
     72c:       ea 1e           adc     r14, r26
     72e:       fb 1e           adc     r15, r27
                                        disk_write(0, fs->win, wsect, 1);
     730:       01 e0           ldi     r16, 0x01       ; 1
     732:       a7 01           movw    r20, r14
     734:       96 01           movw    r18, r12
     736:       b3 01           movw    r22, r6
     738:       80 e0           ldi     r24, 0x00       ; 0
     73a:       0e 94 d3 0e     call    0x1da6  ; 0x1da6 <disk_write>
                if (fs->winflag) {      /* Write back dirty window if needed */
                        if (disk_write(0, fs->win, wsect, 1) != RES_OK)
                                return FALSE;
                        fs->winflag = 0;
                        if (wsect < (fs->fatbase + fs->sects_fat)) {    /* In FAT area */
                                for (n = fs->n_fats; n >= 2; n--) {     /* Refrect the change to all FAT copies */
     73e:       11 50           subi    r17, 0x01       ; 1
     740:       12 30           cpi     r17, 0x02       ; 2
     742:       70 f7           brcc    .-36            ; 0x720 <move_window+0x76>
                                        disk_write(0, fs->win, wsect, 1);
                                }
                        }
                }
#endif
                if (sector) {
     744:       81 14           cp      r8, r1
     746:       91 04           cpc     r9, r1
     748:       a1 04           cpc     r10, r1
     74a:       b1 04           cpc     r11, r1
     74c:       99 f0           breq    .+38            ; 0x774 <move_window+0xca>
                        if (disk_read(0, fs->win, sector, 1) != RES_OK)
     74e:       be 01           movw    r22, r28
     750:       60 5e           subi    r22, 0xE0       ; 224
     752:       7f 4f           sbci    r23, 0xFF       ; 255
     754:       01 e0           ldi     r16, 0x01       ; 1
     756:       a5 01           movw    r20, r10
     758:       94 01           movw    r18, r8
     75a:       80 e0           ldi     r24, 0x00       ; 0
     75c:       0e 94 51 0f     call    0x1ea2  ; 0x1ea2 <disk_read>
     760:       89 2b           or      r24, r25
     762:       29 f4           brne    .+10            ; 0x76e <move_window+0xc4>
                                return FALSE;
                        fs->winsect = sector;
     764:       8c 82           std     Y+4, r8 ; 0x04
     766:       9d 82           std     Y+5, r9 ; 0x05
     768:       ae 82           std     Y+6, r10        ; 0x06
     76a:       bf 82           std     Y+7, r11        ; 0x07
     76c:       03 c0           rjmp    .+6             ; 0x774 <move_window+0xca>
     76e:       80 e0           ldi     r24, 0x00       ; 0
     770:       90 e0           ldi     r25, 0x00       ; 0
     772:       02 c0           rjmp    .+4             ; 0x778 <move_window+0xce>
     774:       81 e0           ldi     r24, 0x01       ; 1
     776:       90 e0           ldi     r25, 0x00       ; 0
     778:       ee e0           ldi     r30, 0x0E       ; 14
     77a:       cd b7           in      r28, 0x3d       ; 61
     77c:       de b7           in      r29, 0x3e       ; 62
     77e:       0c 94 4a 11     jmp     0x2294  ; 0x2294 <__epilogue_restores__+0x8>

00000782 <put_cluster>:
static
BOOL put_cluster (              /* TRUE: successful, FALSE: failed */
        CLUST clust,            /* Cluster# to change */
        CLUST val                       /* New value to mark the cluster */
)
{
     782:       a0 e0           ldi     r26, 0x00       ; 0
     784:       b0 e0           ldi     r27, 0x00       ; 0
     786:       e7 ec           ldi     r30, 0xC7       ; 199
     788:       f3 e0           ldi     r31, 0x03       ; 3
     78a:       0c 94 2d 11     jmp     0x225a  ; 0x225a <__prologue_saves__+0x6>
     78e:       ec 01           movw    r28, r24
     790:       5b 01           movw    r10, r22
        WORD bc;
        BYTE *p;
        DWORD fatsect;
        FATFS *fs = FatFs;
     792:       80 90 0a 01     lds     r8, 0x010A
     796:       90 90 0b 01     lds     r9, 0x010B


        fatsect = fs->fatbase;
     79a:       f4 01           movw    r30, r8
     79c:       c0 84           ldd     r12, Z+8        ; 0x08
     79e:       d1 84           ldd     r13, Z+9        ; 0x09
     7a0:       e2 84           ldd     r14, Z+10       ; 0x0a
     7a2:       f3 84           ldd     r15, Z+11       ; 0x0b
        switch (fs->fs_type) {
     7a4:       84 8d           ldd     r24, Z+28       ; 0x1c
     7a6:       81 30           cpi     r24, 0x01       ; 1
     7a8:       21 f0           breq    .+8             ; 0x7b2 <put_cluster+0x30>
     7aa:       82 30           cpi     r24, 0x02       ; 2
     7ac:       09 f0           breq    .+2             ; 0x7b0 <put_cluster+0x2e>
     7ae:       70 c0           rjmp    .+224           ; 0x890 <put_cluster+0x10e>
     7b0:       56 c0           rjmp    .+172           ; 0x85e <put_cluster+0xdc>
        case FS_FAT12 :
                bc = (WORD)clust * 3 / 2;
     7b2:       8e 01           movw    r16, r28
     7b4:       00 0f           add     r16, r16
     7b6:       11 1f           adc     r17, r17
     7b8:       0c 0f           add     r16, r28
     7ba:       1d 1f           adc     r17, r29
     7bc:       16 95           lsr     r17
     7be:       07 95           ror     r16
                if (!move_window(fatsect + bc / 512)) return FALSE;
     7c0:       b8 01           movw    r22, r16
     7c2:       67 2f           mov     r22, r23
     7c4:       77 27           eor     r23, r23
     7c6:       66 95           lsr     r22
     7c8:       88 27           eor     r24, r24
     7ca:       99 27           eor     r25, r25
     7cc:       6c 0d           add     r22, r12
     7ce:       7d 1d           adc     r23, r13
     7d0:       8e 1d           adc     r24, r14
     7d2:       9f 1d           adc     r25, r15
     7d4:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     7d8:       88 23           and     r24, r24
     7da:       09 f4           brne    .+2             ; 0x7de <put_cluster+0x5c>
     7dc:       59 c0           rjmp    .+178           ; 0x890 <put_cluster+0x10e>
                p = &fs->win[bc % 512];
     7de:       60 e2           ldi     r22, 0x20       ; 32
     7e0:       66 2e           mov     r6, r22
     7e2:       71 2c           mov     r7, r1
     7e4:       68 0c           add     r6, r8
     7e6:       79 1c           adc     r7, r9
     7e8:       f8 01           movw    r30, r16
     7ea:       f1 70           andi    r31, 0x01       ; 1
     7ec:       e6 0d           add     r30, r6
     7ee:       f7 1d           adc     r31, r7
                *p = (clust & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val;
     7f0:       ce 01           movw    r24, r28
     7f2:       81 70           andi    r24, 0x01       ; 1
     7f4:       90 70           andi    r25, 0x00       ; 0
     7f6:       58 2e           mov     r5, r24
     7f8:       88 23           and     r24, r24
     7fa:       39 f0           breq    .+14            ; 0x80a <put_cluster+0x88>
     7fc:       80 81           ld      r24, Z
     7fe:       8f 70           andi    r24, 0x0F       ; 15
     800:       9a 2d           mov     r25, r10
     802:       92 95           swap    r25
     804:       90 7f           andi    r25, 0xF0       ; 240
     806:       98 2b           or      r25, r24
     808:       01 c0           rjmp    .+2             ; 0x80c <put_cluster+0x8a>
     80a:       9a 2d           mov     r25, r10
     80c:       90 83           st      Z, r25
                bc++;
     80e:       e8 01           movw    r28, r16
     810:       21 96           adiw    r28, 0x01       ; 1
                fs->winflag = 1; 
     812:       81 e0           ldi     r24, 0x01       ; 1
     814:       f4 01           movw    r30, r8
     816:       87 8f           std     Z+31, r24       ; 0x1f
                if (!move_window(fatsect + bc / 512)) return FALSE;
     818:       be 01           movw    r22, r28
     81a:       67 2f           mov     r22, r23
     81c:       77 27           eor     r23, r23
     81e:       66 95           lsr     r22
     820:       88 27           eor     r24, r24
     822:       99 27           eor     r25, r25
     824:       6c 0d           add     r22, r12
     826:       7d 1d           adc     r23, r13
     828:       8e 1d           adc     r24, r14
     82a:       9f 1d           adc     r25, r15
     82c:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     830:       88 23           and     r24, r24
     832:       71 f1           breq    .+92            ; 0x890 <put_cluster+0x10e>
                p = &fs->win[bc % 512];
     834:       fe 01           movw    r30, r28
     836:       f1 70           andi    r31, 0x01       ; 1
     838:       e6 0d           add     r30, r6
     83a:       f7 1d           adc     r31, r7
                *p = (clust & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F));
     83c:       55 20           and     r5, r5
     83e:       39 f0           breq    .+14            ; 0x84e <put_cluster+0xcc>
     840:       44 e0           ldi     r20, 0x04       ; 4
     842:       b6 94           lsr     r11
     844:       a7 94           ror     r10
     846:       4a 95           dec     r20
     848:       e1 f7           brne    .-8             ; 0x842 <put_cluster+0xc0>
     84a:       2a 2d           mov     r18, r10
     84c:       06 c0           rjmp    .+12            ; 0x85a <put_cluster+0xd8>
     84e:       20 81           ld      r18, Z
     850:       20 7f           andi    r18, 0xF0       ; 240
     852:       8b 2d           mov     r24, r11
     854:       99 27           eor     r25, r25
     856:       8f 70           andi    r24, 0x0F       ; 15
     858:       28 2b           or      r18, r24
     85a:       20 83           st      Z, r18
     85c:       13 c0           rjmp    .+38            ; 0x884 <put_cluster+0x102>
                break;

        case FS_FAT16 :
                if (!move_window(fatsect + clust / 256)) return FALSE;
     85e:       6d 2f           mov     r22, r29
     860:       77 27           eor     r23, r23
     862:       88 27           eor     r24, r24
     864:       99 27           eor     r25, r25
     866:       6c 0d           add     r22, r12
     868:       7d 1d           adc     r23, r13
     86a:       8e 1d           adc     r24, r14
     86c:       9f 1d           adc     r25, r15
     86e:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     872:       88 23           and     r24, r24
     874:       69 f0           breq    .+26            ; 0x890 <put_cluster+0x10e>
                ST_WORD(&fs->win[((WORD)clust * 2) % 512], (WORD)val);
     876:       cc 0f           add     r28, r28
     878:       dd 1f           adc     r29, r29
     87a:       d1 70           andi    r29, 0x01       ; 1
     87c:       c8 0d           add     r28, r8
     87e:       d9 1d           adc     r29, r9
     880:       b9 a2           std     Y+33, r11       ; 0x21
     882:       a8 a2           std     Y+32, r10       ; 0x20
                break;
#endif
        default :
                return FALSE;
        }
        fs->winflag = 1;
     884:       81 e0           ldi     r24, 0x01       ; 1
     886:       f4 01           movw    r30, r8
     888:       87 8f           std     Z+31, r24       ; 0x1f
     88a:       81 e0           ldi     r24, 0x01       ; 1
     88c:       90 e0           ldi     r25, 0x00       ; 0
     88e:       02 c0           rjmp    .+4             ; 0x894 <put_cluster+0x112>
        return TRUE;
     890:       80 e0           ldi     r24, 0x00       ; 0
     892:       90 e0           ldi     r25, 0x00       ; 0
     894:       ef e0           ldi     r30, 0x0F       ; 15
     896:       cd b7           in      r28, 0x3d       ; 61
     898:       de b7           in      r29, 0x3e       ; 62
     89a:       0c 94 49 11     jmp     0x2292  ; 0x2292 <__epilogue_restores__+0x6>

0000089e <get_cluster>:

static
CLUST get_cluster (             /* 0,>=2: successful, 1: failed */
        CLUST clust                     /* Cluster# to get the link information */
)
{
     89e:       a0 e0           ldi     r26, 0x00       ; 0
     8a0:       b0 e0           ldi     r27, 0x00       ; 0
     8a2:       e5 e5           ldi     r30, 0x55       ; 85
     8a4:       f4 e0           ldi     r31, 0x04       ; 4
     8a6:       0c 94 31 11     jmp     0x2262  ; 0x2262 <__prologue_saves__+0xe>
     8aa:       8c 01           movw    r16, r24
        WORD wc, bc;
        DWORD fatsect;
        FATFS *fs = FatFs;
     8ac:       e0 90 0a 01     lds     r14, 0x010A
     8b0:       f0 90 0b 01     lds     r15, 0x010B


        if (clust >= 2 && clust < fs->max_clust) {              /* Valid cluster# */
     8b4:       02 97           sbiw    r24, 0x02       ; 2
     8b6:       08 f4           brcc    .+2             ; 0x8ba <get_cluster+0x1c>
     8b8:       67 c0           rjmp    .+206           ; 0x988 <get_cluster+0xea>
     8ba:       f7 01           movw    r30, r14
     8bc:       86 89           ldd     r24, Z+22       ; 0x16
     8be:       97 89           ldd     r25, Z+23       ; 0x17
     8c0:       08 17           cp      r16, r24
     8c2:       19 07           cpc     r17, r25
     8c4:       08 f0           brcs    .+2             ; 0x8c8 <get_cluster+0x2a>
     8c6:       60 c0           rjmp    .+192           ; 0x988 <get_cluster+0xea>
                fatsect = fs->fatbase;
     8c8:       a0 84           ldd     r10, Z+8        ; 0x08
     8ca:       b1 84           ldd     r11, Z+9        ; 0x09
     8cc:       c2 84           ldd     r12, Z+10       ; 0x0a
     8ce:       d3 84           ldd     r13, Z+11       ; 0x0b
                switch (fs->fs_type) {
     8d0:       84 8d           ldd     r24, Z+28       ; 0x1c
     8d2:       81 30           cpi     r24, 0x01       ; 1
     8d4:       21 f0           breq    .+8             ; 0x8de <get_cluster+0x40>
     8d6:       82 30           cpi     r24, 0x02       ; 2
     8d8:       09 f0           breq    .+2             ; 0x8dc <get_cluster+0x3e>
     8da:       56 c0           rjmp    .+172           ; 0x988 <get_cluster+0xea>
     8dc:       40 c0           rjmp    .+128           ; 0x95e <get_cluster+0xc0>
                case FS_FAT12 :
                        bc = (WORD)clust * 3 / 2;
     8de:       e8 01           movw    r28, r16
     8e0:       cc 0f           add     r28, r28
     8e2:       dd 1f           adc     r29, r29
     8e4:       c0 0f           add     r28, r16
     8e6:       d1 1f           adc     r29, r17
     8e8:       d6 95           lsr     r29
     8ea:       c7 95           ror     r28
                        if (!move_window(fatsect + bc / 512)) break;
     8ec:       be 01           movw    r22, r28
     8ee:       67 2f           mov     r22, r23
     8f0:       77 27           eor     r23, r23
     8f2:       66 95           lsr     r22
     8f4:       88 27           eor     r24, r24
     8f6:       99 27           eor     r25, r25
     8f8:       6a 0d           add     r22, r10
     8fa:       7b 1d           adc     r23, r11
     8fc:       8c 1d           adc     r24, r12
     8fe:       9d 1d           adc     r25, r13
     900:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     904:       88 23           and     r24, r24
     906:       09 f4           brne    .+2             ; 0x90a <get_cluster+0x6c>
     908:       3f c0           rjmp    .+126           ; 0x988 <get_cluster+0xea>
                        wc = fs->win[bc % 512]; bc++;
     90a:       fe 01           movw    r30, r28
     90c:       f1 70           andi    r31, 0x01       ; 1
     90e:       ee 0d           add     r30, r14
     910:       ff 1d           adc     r31, r15
     912:       90 a0           ldd     r9, Z+32        ; 0x20
     914:       21 96           adiw    r28, 0x01       ; 1
                        if (!move_window(fatsect + bc / 512)) break;
     916:       be 01           movw    r22, r28
     918:       67 2f           mov     r22, r23
     91a:       77 27           eor     r23, r23
     91c:       66 95           lsr     r22
     91e:       88 27           eor     r24, r24
     920:       99 27           eor     r25, r25
     922:       6a 0d           add     r22, r10
     924:       7b 1d           adc     r23, r11
     926:       8c 1d           adc     r24, r12
     928:       9d 1d           adc     r25, r13
     92a:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     92e:       88 23           and     r24, r24
     930:       59 f1           breq    .+86            ; 0x988 <get_cluster+0xea>
                fatsect = fs->fatbase;
                switch (fs->fs_type) {
                case FS_FAT12 :
                        bc = (WORD)clust * 3 / 2;
                        if (!move_window(fatsect + bc / 512)) break;
                        wc = fs->win[bc % 512]; bc++;
     932:       29 2d           mov     r18, r9
     934:       33 27           eor     r19, r19
                        if (!move_window(fatsect + bc / 512)) break;
                        wc |= (WORD)fs->win[bc % 512] << 8;
     936:       d1 70           andi    r29, 0x01       ; 1
     938:       ec 0e           add     r14, r28
     93a:       fd 1e           adc     r15, r29
     93c:       f7 01           movw    r30, r14
     93e:       80 a1           ldd     r24, Z+32       ; 0x20
     940:       99 27           eor     r25, r25
     942:       98 2f           mov     r25, r24
     944:       88 27           eor     r24, r24
     946:       82 2b           or      r24, r18
     948:       93 2b           or      r25, r19
                        return (clust & 1) ? (wc >> 4) : (wc & 0xFFF);
     94a:       00 ff           sbrs    r16, 0
     94c:       06 c0           rjmp    .+12            ; 0x95a <get_cluster+0xbc>
     94e:       24 e0           ldi     r18, 0x04       ; 4
     950:       96 95           lsr     r25
     952:       87 95           ror     r24
     954:       2a 95           dec     r18
     956:       e1 f7           brne    .-8             ; 0x950 <get_cluster+0xb2>
     958:       19 c0           rjmp    .+50            ; 0x98c <get_cluster+0xee>
     95a:       9f 70           andi    r25, 0x0F       ; 15
     95c:       17 c0           rjmp    .+46            ; 0x98c <get_cluster+0xee>

                case FS_FAT16 :
                        if (!move_window(fatsect + clust / 256)) break;
     95e:       61 2f           mov     r22, r17
     960:       77 27           eor     r23, r23
     962:       88 27           eor     r24, r24
     964:       99 27           eor     r25, r25
     966:       6a 0d           add     r22, r10
     968:       7b 1d           adc     r23, r11
     96a:       8c 1d           adc     r24, r12
     96c:       9d 1d           adc     r25, r13
     96e:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     972:       88 23           and     r24, r24
     974:       49 f0           breq    .+18            ; 0x988 <get_cluster+0xea>
                        return LD_WORD(&fs->win[((WORD)clust * 2) % 512]);
     976:       00 0f           add     r16, r16
     978:       11 1f           adc     r17, r17
     97a:       11 70           andi    r17, 0x01       ; 1
     97c:       e0 0e           add     r14, r16
     97e:       f1 1e           adc     r15, r17
     980:       f7 01           movw    r30, r14
     982:       80 a1           ldd     r24, Z+32       ; 0x20
     984:       91 a1           ldd     r25, Z+33       ; 0x21
     986:       02 c0           rjmp    .+4             ; 0x98c <get_cluster+0xee>
     988:       81 e0           ldi     r24, 0x01       ; 1
     98a:       90 e0           ldi     r25, 0x00       ; 0
     98c:       eb e0           ldi     r30, 0x0B       ; 11
     98e:       cd b7           in      r28, 0x3d       ; 61
     990:       de b7           in      r29, 0x3e       ; 62
     992:       0c 94 4d 11     jmp     0x229a  ; 0x229a <__epilogue_restores__+0xe>

00000996 <next_dir_entry>:

static
BOOL next_dir_entry (   /* TRUE: successful, FALSE: could not move next */
        DIR *dirobj                     /* Pointer to directory object */
)
{
     996:       ef 92           push    r14
     998:       ff 92           push    r15
     99a:       0f 93           push    r16
     99c:       1f 93           push    r17
     99e:       cf 93           push    r28
     9a0:       df 93           push    r29
     9a2:       ec 01           movw    r28, r24
        CLUST clust;
        WORD idx;
        FATFS *fs = FatFs;
     9a4:       e0 90 0a 01     lds     r14, 0x010A
     9a8:       f0 90 0b 01     lds     r15, 0x010B


        idx = dirobj->index + 1;
     9ac:       0a 81           ldd     r16, Y+2        ; 0x02
     9ae:       1b 81           ldd     r17, Y+3        ; 0x03
     9b0:       0f 5f           subi    r16, 0xFF       ; 255
     9b2:       1f 4f           sbci    r17, 0xFF       ; 255
        if ((idx & 15) == 0) {          /* Table sector changed? */
     9b4:       c8 01           movw    r24, r16
     9b6:       8f 70           andi    r24, 0x0F       ; 15
     9b8:       90 70           andi    r25, 0x00       ; 0
     9ba:       89 2b           or      r24, r25
     9bc:       d1 f5           brne    .+116           ; 0xa32 <next_dir_entry+0x9c>
                dirobj->sect++;                 /* Next sector */
     9be:       8a 85           ldd     r24, Y+10       ; 0x0a
     9c0:       9b 85           ldd     r25, Y+11       ; 0x0b
     9c2:       ac 85           ldd     r26, Y+12       ; 0x0c
     9c4:       bd 85           ldd     r27, Y+13       ; 0x0d
     9c6:       01 96           adiw    r24, 0x01       ; 1
     9c8:       a1 1d           adc     r26, r1
     9ca:       b1 1d           adc     r27, r1
     9cc:       8a 87           std     Y+10, r24       ; 0x0a
     9ce:       9b 87           std     Y+11, r25       ; 0x0b
     9d0:       ac 87           std     Y+12, r26       ; 0x0c
     9d2:       bd 87           std     Y+13, r27       ; 0x0d
                if (!dirobj->clust) {           /* In static table */
     9d4:       48 85           ldd     r20, Y+8        ; 0x08
     9d6:       59 85           ldd     r21, Y+9        ; 0x09
     9d8:       41 15           cp      r20, r1
     9da:       51 05           cpc     r21, r1
     9dc:       39 f4           brne    .+14            ; 0x9ec <next_dir_entry+0x56>
                        if (idx >= fs->n_rootdir) return FALSE; /* Reached to end of table */
     9de:       f7 01           movw    r30, r14
     9e0:       82 81           ldd     r24, Z+2        ; 0x02
     9e2:       93 81           ldd     r25, Z+3        ; 0x03
     9e4:       08 17           cp      r16, r24
     9e6:       19 07           cpc     r17, r25
     9e8:       20 f1           brcs    .+72            ; 0xa32 <next_dir_entry+0x9c>
     9ea:       28 c0           rjmp    .+80            ; 0xa3c <next_dir_entry+0xa6>
                } else {                                        /* In dynamic table */
                        if (((idx / 16) & (fs->sects_clust - 1)) == 0) {        /* Cluster changed? */
     9ec:       f7 01           movw    r30, r14
     9ee:       85 8d           ldd     r24, Z+29       ; 0x1d
     9f0:       99 27           eor     r25, r25
     9f2:       01 97           sbiw    r24, 0x01       ; 1
     9f4:       98 01           movw    r18, r16
     9f6:       b4 e0           ldi     r27, 0x04       ; 4
     9f8:       36 95           lsr     r19
     9fa:       27 95           ror     r18
     9fc:       ba 95           dec     r27
     9fe:       e1 f7           brne    .-8             ; 0x9f8 <next_dir_entry+0x62>
     a00:       82 23           and     r24, r18
     a02:       93 23           and     r25, r19
     a04:       89 2b           or      r24, r25
     a06:       a9 f4           brne    .+42            ; 0xa32 <next_dir_entry+0x9c>
                                clust = get_cluster(dirobj->clust);                     /* Get next cluster */
     a08:       ca 01           movw    r24, r20
     a0a:       0e 94 4f 04     call    0x89e   ; 0x89e <get_cluster>
     a0e:       9c 01           movw    r18, r24
                                if (clust < 2 || clust >= fs->max_clust)        /* Reached to end of table */
     a10:       02 97           sbiw    r24, 0x02       ; 2
     a12:       a0 f0           brcs    .+40            ; 0xa3c <next_dir_entry+0xa6>
     a14:       f7 01           movw    r30, r14
     a16:       86 89           ldd     r24, Z+22       ; 0x16
     a18:       97 89           ldd     r25, Z+23       ; 0x17
     a1a:       28 17           cp      r18, r24
     a1c:       39 07           cpc     r19, r25
     a1e:       70 f4           brcc    .+28            ; 0xa3c <next_dir_entry+0xa6>
                                        return FALSE;
                                dirobj->clust = clust;                          /* Initialize for new cluster */
     a20:       39 87           std     Y+9, r19        ; 0x09
     a22:       28 87           std     Y+8, r18        ; 0x08
                                dirobj->sect = clust2sect(clust);
     a24:       c9 01           movw    r24, r18
     a26:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
     a2a:       6a 87           std     Y+10, r22       ; 0x0a
     a2c:       7b 87           std     Y+11, r23       ; 0x0b
     a2e:       8c 87           std     Y+12, r24       ; 0x0c
     a30:       9d 87           std     Y+13, r25       ; 0x0d
                        }
                }
        }
        dirobj->index = idx;    /* Lower 4 bit of dirobj->index indicates offset in dirobj->sect */
     a32:       1b 83           std     Y+3, r17        ; 0x03
     a34:       0a 83           std     Y+2, r16        ; 0x02
     a36:       81 e0           ldi     r24, 0x01       ; 1
     a38:       90 e0           ldi     r25, 0x00       ; 0
     a3a:       02 c0           rjmp    .+4             ; 0xa40 <next_dir_entry+0xaa>
        return TRUE;
     a3c:       80 e0           ldi     r24, 0x00       ; 0
     a3e:       90 e0           ldi     r25, 0x00       ; 0
     a40:       e6 e0           ldi     r30, 0x06       ; 6
     a42:       cd b7           in      r28, 0x3d       ; 61
     a44:       de b7           in      r29, 0x3e       ; 62
     a46:       0c 94 52 11     jmp     0x22a4  ; 0x22a4 <__epilogue_restores__+0x18>

00000a4a <create_chain>:
#if !_FS_READONLY
static
CLUST create_chain (    /* 0: no free cluster, 1: error, >=2: new cluster number */
        CLUST clust                     /* Cluster# to stretch, 0 means create new */
)
{
     a4a:       a0 e0           ldi     r26, 0x00       ; 0
     a4c:       b0 e0           ldi     r27, 0x00       ; 0
     a4e:       eb e2           ldi     r30, 0x2B       ; 43
     a50:       f5 e0           ldi     r31, 0x05       ; 5
     a52:       0c 94 32 11     jmp     0x2264  ; 0x2264 <__prologue_saves__+0x10>
     a56:       7c 01           movw    r14, r24
        CLUST cstat, ncl, scl, mcl;
        FATFS *fs = FatFs;
     a58:       a0 90 0a 01     lds     r10, 0x010A
     a5c:       b0 90 0b 01     lds     r11, 0x010B


        mcl = fs->max_clust;
     a60:       f5 01           movw    r30, r10
     a62:       c6 88           ldd     r12, Z+22       ; 0x16
     a64:       d7 88           ldd     r13, Z+23       ; 0x17
        if (clust == 0) {               /* Create new chain */
     a66:       00 97           sbiw    r24, 0x00       ; 0
     a68:       49 f4           brne    .+18            ; 0xa7c <create_chain+0x32>
                scl = fs->last_clust;                   /* Get last allocated cluster */
     a6a:       00 8d           ldd     r16, Z+24       ; 0x18
     a6c:       11 8d           ldd     r17, Z+25       ; 0x19
                if (scl < 2 || scl >= mcl) scl = 1;
     a6e:       02 30           cpi     r16, 0x02       ; 2
     a70:       11 05           cpc     r17, r1
     a72:       80 f0           brcs    .+32            ; 0xa94 <create_chain+0x4a>
     a74:       0c 15           cp      r16, r12
     a76:       1d 05           cpc     r17, r13
     a78:       68 f4           brcc    .+26            ; 0xa94 <create_chain+0x4a>
     a7a:       0e c0           rjmp    .+28            ; 0xa98 <create_chain+0x4e>
        }
        else {                                  /* Stretch existing chain */
                cstat = get_cluster(clust);             /* Check the cluster status */
     a7c:       0e 94 4f 04     call    0x89e   ; 0x89e <get_cluster>
                if (cstat < 2) return 1;                /* It is an invalid cluster */
     a80:       82 30           cpi     r24, 0x02       ; 2
     a82:       91 05           cpc     r25, r1
     a84:       e8 f1           brcs    .+122           ; 0xb00 <create_chain+0xb6>
                if (cstat < mcl) return cstat;  /* It is already followed by next cluster */
     a86:       8c 15           cp      r24, r12
     a88:       9d 05           cpc     r25, r13
     a8a:       10 f4           brcc    .+4             ; 0xa90 <create_chain+0x46>
     a8c:       bc 01           movw    r22, r24
     a8e:       3d c0           rjmp    .+122           ; 0xb0a <create_chain+0xc0>
     a90:       87 01           movw    r16, r14
     a92:       02 c0           rjmp    .+4             ; 0xa98 <create_chain+0x4e>
     a94:       01 e0           ldi     r16, 0x01       ; 1
     a96:       10 e0           ldi     r17, 0x00       ; 0
     a98:       e8 01           movw    r28, r16
                scl = clust;
        }

        ncl = scl;                              /* Start cluster */
        for (;;) {
                ncl++;                                                  /* Next cluster */
     a9a:       21 96           adiw    r28, 0x01       ; 1
                if (ncl >= mcl) {                               /* Wrap around */
     a9c:       cc 15           cp      r28, r12
     a9e:       dd 05           cpc     r29, r13
     aa0:       28 f0           brcs    .+10            ; 0xaac <create_chain+0x62>
                        ncl = 2;
                        if (ncl > scl) return 0;        /* No free custer */
     aa2:       02 30           cpi     r16, 0x02       ; 2
     aa4:       11 05           cpc     r17, r1
     aa6:       78 f1           brcs    .+94            ; 0xb06 <create_chain+0xbc>
     aa8:       c2 e0           ldi     r28, 0x02       ; 2
     aaa:       d0 e0           ldi     r29, 0x00       ; 0
                }
                cstat = get_cluster(ncl);               /* Get the cluster status */
     aac:       ce 01           movw    r24, r28
     aae:       0e 94 4f 04     call    0x89e   ; 0x89e <get_cluster>
                if (cstat == 0) break;                  /* Found a free cluster */
     ab2:       00 97           sbiw    r24, 0x00       ; 0
     ab4:       31 f0           breq    .+12            ; 0xac2 <create_chain+0x78>
                if (cstat == 1) return 1;               /* Any error occured */
     ab6:       01 97           sbiw    r24, 0x01       ; 1
     ab8:       19 f1           breq    .+70            ; 0xb00 <create_chain+0xb6>
                if (ncl == scl) return 0;               /* No free custer */
     aba:       c0 17           cp      r28, r16
     abc:       d1 07           cpc     r29, r17
     abe:       19 f1           breq    .+70            ; 0xb06 <create_chain+0xbc>
     ac0:       ec cf           rjmp    .-40            ; 0xa9a <create_chain+0x50>
        }

        if (!put_cluster(ncl, (CLUST)0x0FFFFFFF)) return 1;     /* Mark the new cluster "in use" */
     ac2:       6f ef           ldi     r22, 0xFF       ; 255
     ac4:       7f ef           ldi     r23, 0xFF       ; 255
     ac6:       ce 01           movw    r24, r28
     ac8:       0e 94 c1 03     call    0x782   ; 0x782 <put_cluster>
     acc:       88 23           and     r24, r24
     ace:       c1 f0           breq    .+48            ; 0xb00 <create_chain+0xb6>
        if (clust && !put_cluster(clust, ncl)) return 1;        /* Link it to previous one if needed */
     ad0:       e1 14           cp      r14, r1
     ad2:       f1 04           cpc     r15, r1
     ad4:       31 f0           breq    .+12            ; 0xae2 <create_chain+0x98>
     ad6:       be 01           movw    r22, r28
     ad8:       c7 01           movw    r24, r14
     ada:       0e 94 c1 03     call    0x782   ; 0x782 <put_cluster>
     ade:       88 23           and     r24, r24
     ae0:       79 f0           breq    .+30            ; 0xb00 <create_chain+0xb6>

        fs->last_clust = ncl;                           /* Update fsinfo */
     ae2:       f5 01           movw    r30, r10
     ae4:       d1 8f           std     Z+25, r29       ; 0x19
     ae6:       c0 8f           std     Z+24, r28       ; 0x18
        if (fs->free_clust != (CLUST)0xFFFFFFFF) {
     ae8:       82 8d           ldd     r24, Z+26       ; 0x1a
     aea:       93 8d           ldd     r25, Z+27       ; 0x1b
     aec:       ff ef           ldi     r31, 0xFF       ; 255
     aee:       8f 3f           cpi     r24, 0xFF       ; 255
     af0:       9f 07           cpc     r25, r31
     af2:       21 f0           breq    .+8             ; 0xafc <create_chain+0xb2>
                fs->free_clust--;
     af4:       01 97           sbiw    r24, 0x01       ; 1
     af6:       f5 01           movw    r30, r10
     af8:       93 8f           std     Z+27, r25       ; 0x1b
     afa:       82 8f           std     Z+26, r24       ; 0x1a
     afc:       be 01           movw    r22, r28
     afe:       05 c0           rjmp    .+10            ; 0xb0a <create_chain+0xc0>
     b00:       61 e0           ldi     r22, 0x01       ; 1
     b02:       70 e0           ldi     r23, 0x00       ; 0
     b04:       02 c0           rjmp    .+4             ; 0xb0a <create_chain+0xc0>
     b06:       60 e0           ldi     r22, 0x00       ; 0
     b08:       70 e0           ldi     r23, 0x00       ; 0
                fs->fsi_flag = 1;
#endif
        }

        return ncl;             /* Return new cluster number */
}
     b0a:       cb 01           movw    r24, r22
     b0c:       ea e0           ldi     r30, 0x0A       ; 10
     b0e:       cd b7           in      r28, 0x3d       ; 61
     b10:       de b7           in      r29, 0x3e       ; 62
     b12:       0c 94 4e 11     jmp     0x229c  ; 0x229c <__epilogue_restores__+0x10>

00000b16 <f_lseek>:

FRESULT f_lseek (
        FIL *fp,                /* Pointer to the file object */
        DWORD ofs               /* File pointer from top of file */
)
{
     b16:       a0 e0           ldi     r26, 0x00       ; 0
     b18:       b0 e0           ldi     r27, 0x00       ; 0
     b1a:       e1 e9           ldi     r30, 0x91       ; 145
     b1c:       f5 e0           ldi     r31, 0x05       ; 5
     b1e:       0c 94 2a 11     jmp     0x2254  ; 0x2254 <__prologue_saves__>
     b22:       ec 01           movw    r28, r24
     b24:       3a 01           movw    r6, r20
     b26:       4b 01           movw    r8, r22
        CLUST clust;
        DWORD csize;
        BYTE csect;
        FRESULT res;
        FATFS *fs = fp->fs;
     b28:       4c 80           ldd     r4, Y+4 ; 0x04
     b2a:       5d 80           ldd     r5, Y+5 ; 0x05


        res = validate(fs, fp->id);                     /* Check validity of the object */
     b2c:       68 81           ld      r22, Y
     b2e:       79 81           ldd     r23, Y+1        ; 0x01
     b30:       c2 01           movw    r24, r4
     b32:       0e 94 43 03     call    0x686   ; 0x686 <validate>
     b36:       1c 01           movw    r2, r24
        if (res) return res;
     b38:       89 2b           or      r24, r25
     b3a:       09 f0           breq    .+2             ; 0xb3e <f_lseek+0x28>
     b3c:       b8 c0           rjmp    .+368           ; 0xcae <f_lseek+0x198>

        if (fp->flag & FA__ERROR) return FR_RW_ERROR;
     b3e:       2a 81           ldd     r18, Y+2        ; 0x02
     b40:       22 23           and     r18, r18
     b42:       0c f4           brge    .+2             ; 0xb46 <f_lseek+0x30>
     b44:       b1 c0           rjmp    .+354           ; 0xca8 <f_lseek+0x192>
#if !_FS_READONLY
        if (ofs > fp->fsize && !(fp->flag & FA_WRITE))
     b46:       8a 85           ldd     r24, Y+10       ; 0x0a
     b48:       9b 85           ldd     r25, Y+11       ; 0x0b
     b4a:       ac 85           ldd     r26, Y+12       ; 0x0c
     b4c:       bd 85           ldd     r27, Y+13       ; 0x0d
     b4e:       86 15           cp      r24, r6
     b50:       97 05           cpc     r25, r7
     b52:       a8 05           cpc     r26, r8
     b54:       b9 05           cpc     r27, r9
     b56:       20 f4           brcc    .+8             ; 0xb60 <f_lseek+0x4a>
     b58:       21 fd           sbrc    r18, 1
     b5a:       02 c0           rjmp    .+4             ; 0xb60 <f_lseek+0x4a>
     b5c:       3c 01           movw    r6, r24
     b5e:       4d 01           movw    r8, r26
#else
        if (ofs > fp->fsize)
#endif
                ofs = fp->fsize;
        fp->fptr = 0; fp->sect_clust = 1;               /* Set file R/W pointer to top of the file */
     b60:       1e 82           std     Y+6, r1 ; 0x06
     b62:       1f 82           std     Y+7, r1 ; 0x07
     b64:       18 86           std     Y+8, r1 ; 0x08
     b66:       19 86           std     Y+9, r1 ; 0x09
     b68:       81 e0           ldi     r24, 0x01       ; 1
     b6a:       8b 83           std     Y+3, r24        ; 0x03

        /* Move file R/W pointer if needed */
        if (ofs) {
     b6c:       61 14           cp      r6, r1
     b6e:       71 04           cpc     r7, r1
     b70:       81 04           cpc     r8, r1
     b72:       91 04           cpc     r9, r1
     b74:       09 f4           brne    .+2             ; 0xb78 <f_lseek+0x62>
     b76:       7e c0           rjmp    .+252           ; 0xc74 <f_lseek+0x15e>
                clust = fp->org_clust;  /* Get start cluster */
     b78:       2e 85           ldd     r18, Y+14       ; 0x0e
     b7a:       3f 85           ldd     r19, Y+15       ; 0x0f
#if !_FS_READONLY
                if (!clust) {                   /* If the file does not have a cluster chain, create new cluster chain */
     b7c:       21 15           cp      r18, r1
     b7e:       31 05           cpc     r19, r1
     b80:       71 f4           brne    .+28            ; 0xb9e <f_lseek+0x88>
                        clust = create_chain(0);
     b82:       80 e0           ldi     r24, 0x00       ; 0
     b84:       90 e0           ldi     r25, 0x00       ; 0
     b86:       0e 94 25 05     call    0xa4a   ; 0xa4a <create_chain>
     b8a:       9c 01           movw    r18, r24
                        if (clust == 1) goto fk_error;
     b8c:       81 30           cpi     r24, 0x01       ; 1
     b8e:       91 05           cpc     r25, r1
     b90:       09 f4           brne    .+2             ; 0xb94 <f_lseek+0x7e>
     b92:       87 c0           rjmp    .+270           ; 0xca2 <f_lseek+0x18c>
                        fp->org_clust = clust;
     b94:       9f 87           std     Y+15, r25       ; 0x0f
     b96:       8e 87           std     Y+14, r24       ; 0x0e
                }
#endif
                if (clust) {                    /* If the file has a cluster chain, it can be followed */
     b98:       89 2b           or      r24, r25
     b9a:       09 f4           brne    .+2             ; 0xb9e <f_lseek+0x88>
     b9c:       6b c0           rjmp    .+214           ; 0xc74 <f_lseek+0x15e>
                        csize = (DWORD)fs->sects_clust * 512;           /* Cluster size in unit of byte */
     b9e:       f2 01           movw    r30, r4
     ba0:       85 8d           ldd     r24, Z+29       ; 0x1d
     ba2:       e8 2e           mov     r14, r24
     ba4:       ff 24           eor     r15, r15
     ba6:       00 27           eor     r16, r16
     ba8:       11 27           eor     r17, r17
     baa:       89 e0           ldi     r24, 0x09       ; 9
     bac:       ee 0c           add     r14, r14
     bae:       ff 1c           adc     r15, r15
     bb0:       00 1f           adc     r16, r16
     bb2:       11 1f           adc     r17, r17
     bb4:       8a 95           dec     r24
     bb6:       d1 f7           brne    .-12            ; 0xbac <f_lseek+0x96>
                        for (;;) {                                                                      /* Loop to skip leading clusters */
                                fp->curr_clust = clust;                                 /* Update current cluster */
     bb8:       39 8b           std     Y+17, r19       ; 0x11
     bba:       28 8b           std     Y+16, r18       ; 0x10
                                if (ofs <= csize) break;
     bbc:       e6 14           cp      r14, r6
     bbe:       f7 04           cpc     r15, r7
     bc0:       08 05           cpc     r16, r8
     bc2:       19 05           cpc     r17, r9
     bc4:       50 f5           brcc    .+84            ; 0xc1a <f_lseek+0x104>
#if !_FS_READONLY
                                if (fp->flag & FA_WRITE)                                /* Check if in write mode or not */
     bc6:       8a 81           ldd     r24, Y+2        ; 0x02
     bc8:       81 ff           sbrs    r24, 1
     bca:       04 c0           rjmp    .+8             ; 0xbd4 <f_lseek+0xbe>
                                        clust = create_chain(clust);            /* Force streached if in write mode */
     bcc:       c9 01           movw    r24, r18
     bce:       0e 94 25 05     call    0xa4a   ; 0xa4a <create_chain>
     bd2:       03 c0           rjmp    .+6             ; 0xbda <f_lseek+0xc4>
                                else
#endif
                                        clust = get_cluster(clust);                     /* Only follow cluster chain if not in write mode */
     bd4:       c9 01           movw    r24, r18
     bd6:       0e 94 4f 04     call    0x89e   ; 0x89e <get_cluster>
     bda:       9c 01           movw    r18, r24
                                if (clust == 0) {                                               /* Stop if could not follow the cluster chain */
     bdc:       00 97           sbiw    r24, 0x00       ; 0
     bde:       d9 f0           breq    .+54            ; 0xc16 <f_lseek+0x100>
                                        ofs = csize; break;
                                }
                                if (clust == 1 || clust >= fs->max_clust) goto fk_error;
     be0:       01 97           sbiw    r24, 0x01       ; 1
     be2:       09 f4           brne    .+2             ; 0xbe6 <f_lseek+0xd0>
     be4:       5e c0           rjmp    .+188           ; 0xca2 <f_lseek+0x18c>
     be6:       f2 01           movw    r30, r4
     be8:       86 89           ldd     r24, Z+22       ; 0x16
     bea:       97 89           ldd     r25, Z+23       ; 0x17
     bec:       28 17           cp      r18, r24
     bee:       39 07           cpc     r19, r25
     bf0:       08 f0           brcs    .+2             ; 0xbf4 <f_lseek+0xde>
     bf2:       57 c0           rjmp    .+174           ; 0xca2 <f_lseek+0x18c>
                                fp->fptr += csize;                                              /* Update R/W pointer */
     bf4:       8e 81           ldd     r24, Y+6        ; 0x06
     bf6:       9f 81           ldd     r25, Y+7        ; 0x07
     bf8:       a8 85           ldd     r26, Y+8        ; 0x08
     bfa:       b9 85           ldd     r27, Y+9        ; 0x09
     bfc:       8e 0d           add     r24, r14
     bfe:       9f 1d           adc     r25, r15
     c00:       a0 1f           adc     r26, r16
     c02:       b1 1f           adc     r27, r17
     c04:       8e 83           std     Y+6, r24        ; 0x06
     c06:       9f 83           std     Y+7, r25        ; 0x07
     c08:       a8 87           std     Y+8, r26        ; 0x08
     c0a:       b9 87           std     Y+9, r27        ; 0x09
                                ofs -= csize;
     c0c:       6e 18           sub     r6, r14
     c0e:       7f 08           sbc     r7, r15
     c10:       80 0a           sbc     r8, r16
     c12:       91 0a           sbc     r9, r17
     c14:       d1 cf           rjmp    .-94            ; 0xbb8 <f_lseek+0xa2>
                        }
     c16:       37 01           movw    r6, r14
     c18:       48 01           movw    r8, r16
                        csect = (BYTE)((ofs - 1) / 512);                        /* Sector offset in the cluster */
     c1a:       64 01           movw    r12, r8
     c1c:       53 01           movw    r10, r6
     c1e:       08 94           sec
     c20:       a1 08           sbc     r10, r1
     c22:       b1 08           sbc     r11, r1
     c24:       c1 08           sbc     r12, r1
     c26:       d1 08           sbc     r13, r1
     c28:       09 e0           ldi     r16, 0x09       ; 9
     c2a:       d6 94           lsr     r13
     c2c:       c7 94           ror     r12
     c2e:       b7 94           ror     r11
     c30:       a7 94           ror     r10
     c32:       0a 95           dec     r16
     c34:       d1 f7           brne    .-12            ; 0xc2a <f_lseek+0x114>
                        fp->curr_sect = clust2sect(clust) + csect;      /* Current sector */
     c36:       ea 2c           mov     r14, r10
     c38:       ff 24           eor     r15, r15
     c3a:       00 27           eor     r16, r16
     c3c:       11 27           eor     r17, r17
     c3e:       c9 01           movw    r24, r18
     c40:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
     c44:       e6 0e           add     r14, r22
     c46:       f7 1e           adc     r15, r23
     c48:       08 1f           adc     r16, r24
     c4a:       19 1f           adc     r17, r25
     c4c:       ea 8a           std     Y+18, r14       ; 0x12
     c4e:       fb 8a           std     Y+19, r15       ; 0x13
     c50:       0c 8b           std     Y+20, r16       ; 0x14
     c52:       1d 8b           std     Y+21, r17       ; 0x15
                        fp->sect_clust = fs->sects_clust - csect;       /* Left sector counter in the cluster */
     c54:       f2 01           movw    r30, r4
     c56:       85 8d           ldd     r24, Z+29       ; 0x1d
     c58:       8a 19           sub     r24, r10
     c5a:       8b 83           std     Y+3, r24        ; 0x03
                        fp->fptr += ofs;                                                        /* Update file R/W pointer */
     c5c:       8e 81           ldd     r24, Y+6        ; 0x06
     c5e:       9f 81           ldd     r25, Y+7        ; 0x07
     c60:       a8 85           ldd     r26, Y+8        ; 0x08
     c62:       b9 85           ldd     r27, Y+9        ; 0x09
     c64:       86 0d           add     r24, r6
     c66:       97 1d           adc     r25, r7
     c68:       a8 1d           adc     r26, r8
     c6a:       b9 1d           adc     r27, r9
     c6c:       8e 83           std     Y+6, r24        ; 0x06
     c6e:       9f 83           std     Y+7, r25        ; 0x07
     c70:       a8 87           std     Y+8, r26        ; 0x08
     c72:       b9 87           std     Y+9, r27        ; 0x09
                }
        }
#if !_FS_READONLY
        if ((fp->flag & FA_WRITE) && fp->fptr > fp->fsize) {    /* Set updated flag if in write mode */
     c74:       6a 81           ldd     r22, Y+2        ; 0x02
     c76:       61 ff           sbrs    r22, 1
     c78:       1a c0           rjmp    .+52            ; 0xcae <f_lseek+0x198>
     c7a:       2e 81           ldd     r18, Y+6        ; 0x06
     c7c:       3f 81           ldd     r19, Y+7        ; 0x07
     c7e:       48 85           ldd     r20, Y+8        ; 0x08
     c80:       59 85           ldd     r21, Y+9        ; 0x09
     c82:       8a 85           ldd     r24, Y+10       ; 0x0a
     c84:       9b 85           ldd     r25, Y+11       ; 0x0b
     c86:       ac 85           ldd     r26, Y+12       ; 0x0c
     c88:       bd 85           ldd     r27, Y+13       ; 0x0d
     c8a:       82 17           cp      r24, r18
     c8c:       93 07           cpc     r25, r19
     c8e:       a4 07           cpc     r26, r20
     c90:       b5 07           cpc     r27, r21
     c92:       68 f4           brcc    .+26            ; 0xcae <f_lseek+0x198>
                fp->fsize = fp->fptr;
     c94:       2a 87           std     Y+10, r18       ; 0x0a
     c96:       3b 87           std     Y+11, r19       ; 0x0b
     c98:       4c 87           std     Y+12, r20       ; 0x0c
     c9a:       5d 87           std     Y+13, r21       ; 0x0d
                fp->flag |= FA__WRITTEN;
     c9c:       60 62           ori     r22, 0x20       ; 32
     c9e:       6a 83           std     Y+2, r22        ; 0x02
     ca0:       06 c0           rjmp    .+12            ; 0xcae <f_lseek+0x198>
#endif

        return FR_OK;

fk_error:       /* Abort this function due to an unrecoverable error */
        fp->flag |= FA__ERROR;
     ca2:       8a 81           ldd     r24, Y+2        ; 0x02
     ca4:       80 68           ori     r24, 0x80       ; 128
     ca6:       8a 83           std     Y+2, r24        ; 0x02
     ca8:       18 e0           ldi     r17, 0x08       ; 8
     caa:       21 2e           mov     r2, r17
     cac:       31 2c           mov     r3, r1
        return FR_RW_ERROR;
}
     cae:       c1 01           movw    r24, r2
     cb0:       e2 e1           ldi     r30, 0x12       ; 18
     cb2:       cd b7           in      r28, 0x3d       ; 61
     cb4:       de b7           in      r29, 0x3e       ; 62
     cb6:       0c 94 46 11     jmp     0x228c  ; 0x228c <__epilogue_restores__>

00000cba <f_sync>:
/*-----------------------------------------------------------------------*/

FRESULT f_sync (
        FIL *fp         /* Pointer to the file object */
)
{
     cba:       ef 92           push    r14
     cbc:       ff 92           push    r15
     cbe:       0f 93           push    r16
     cc0:       1f 93           push    r17
     cc2:       cf 93           push    r28
     cc4:       df 93           push    r29
     cc6:       ec 01           movw    r28, r24
        BYTE *dir;
        FRESULT res;
        FATFS *fs = fp->fs;


        res = validate(fs, fp->id);                             /* Check validity of the object */
     cc8:       68 81           ld      r22, Y
     cca:       79 81           ldd     r23, Y+1        ; 0x01
     ccc:       8c 81           ldd     r24, Y+4        ; 0x04
     cce:       9d 81           ldd     r25, Y+5        ; 0x05
     cd0:       0e 94 43 03     call    0x686   ; 0x686 <validate>
     cd4:       7c 01           movw    r14, r24
        if (res == FR_OK) {
     cd6:       89 2b           or      r24, r25
     cd8:       09 f0           breq    .+2             ; 0xcdc <f_sync+0x22>
     cda:       40 c0           rjmp    .+128           ; 0xd5c <f_sync+0xa2>
                if (fp->flag & FA__WRITTEN) {           /* Has the file been written? */
     cdc:       8a 81           ldd     r24, Y+2        ; 0x02
     cde:       85 ff           sbrs    r24, 5
     ce0:       3d c0           rjmp    .+122           ; 0xd5c <f_sync+0xa2>
                        /* Update the directory entry */
                        if (!move_window(fp->dir_sect))
     ce2:       6e 89           ldd     r22, Y+22       ; 0x16
     ce4:       7f 89           ldd     r23, Y+23       ; 0x17
     ce6:       88 8d           ldd     r24, Y+24       ; 0x18
     ce8:       99 8d           ldd     r25, Y+25       ; 0x19
     cea:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     cee:       88 23           and     r24, r24
     cf0:       91 f1           breq    .+100           ; 0xd56 <f_sync+0x9c>
                                return FR_RW_ERROR;
                        dir = fp->dir_ptr;
     cf2:       0a 8d           ldd     r16, Y+26       ; 0x1a
     cf4:       1b 8d           ldd     r17, Y+27       ; 0x1b
                        dir[DIR_Attr] |= AM_ARC;                                                /* Set archive bit */
     cf6:       f8 01           movw    r30, r16
     cf8:       83 85           ldd     r24, Z+11       ; 0x0b
     cfa:       80 62           ori     r24, 0x20       ; 32
     cfc:       83 87           std     Z+11, r24       ; 0x0b
                        ST_DWORD(&dir[DIR_FileSize], fp->fsize);                /* Update file size */
     cfe:       8a 85           ldd     r24, Y+10       ; 0x0a
     d00:       9b 85           ldd     r25, Y+11       ; 0x0b
     d02:       ac 85           ldd     r26, Y+12       ; 0x0c
     d04:       bd 85           ldd     r27, Y+13       ; 0x0d
     d06:       84 8f           std     Z+28, r24       ; 0x1c
     d08:       95 8f           std     Z+29, r25       ; 0x1d
     d0a:       a6 8f           std     Z+30, r26       ; 0x1e
     d0c:       b7 8f           std     Z+31, r27       ; 0x1f
                        ST_WORD(&dir[DIR_FstClusLO], fp->org_clust);    /* Update start cluster */
     d0e:       8e 85           ldd     r24, Y+14       ; 0x0e
     d10:       9f 85           ldd     r25, Y+15       ; 0x0f
     d12:       93 8f           std     Z+27, r25       ; 0x1b
     d14:       82 8f           std     Z+26, r24       ; 0x1a
#if _FAT32
                        ST_WORD(&dir[DIR_FstClusHI], fp->org_clust >> 16);
#endif
                        tim = get_fattime();                                    /* Updated time */
     d16:       0e 94 bb 00     call    0x176   ; 0x176 <get_fattime>
                        ST_DWORD(&dir[DIR_WrtTime], tim);
     d1a:       f8 01           movw    r30, r16
     d1c:       66 8b           std     Z+22, r22       ; 0x16
     d1e:       77 8b           std     Z+23, r23       ; 0x17
     d20:       80 8f           std     Z+24, r24       ; 0x18
     d22:       91 8f           std     Z+25, r25       ; 0x19
                        fp->flag &= ~FA__WRITTEN;
     d24:       8a 81           ldd     r24, Y+2        ; 0x02
     d26:       8f 7d           andi    r24, 0xDF       ; 223
     d28:       8a 83           std     Y+2, r24        ; 0x02
FRESULT sync (void)             /* FR_OK: successful, FR_RW_ERROR: failed */
{
        FATFS *fs = FatFs;


        fs->winflag = 1;
     d2a:       e0 91 0a 01     lds     r30, 0x010A
     d2e:       f0 91 0b 01     lds     r31, 0x010B
     d32:       81 e0           ldi     r24, 0x01       ; 1
     d34:       87 8f           std     Z+31, r24       ; 0x1f
        if (!move_window(0)) return FR_RW_ERROR;
     d36:       60 e0           ldi     r22, 0x00       ; 0
     d38:       70 e0           ldi     r23, 0x00       ; 0
     d3a:       80 e0           ldi     r24, 0x00       ; 0
     d3c:       90 e0           ldi     r25, 0x00       ; 0
     d3e:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     d42:       88 23           and     r24, r24
     d44:       41 f0           breq    .+16            ; 0xd56 <f_sync+0x9c>
                ST_DWORD(&fs->win[FSI_Nxt_Free], fs->last_clust);
                disk_write(0, fs->win, fs->fsi_sector, 1);
                fs->fsi_flag = 0;
        }
#endif
        if (disk_ioctl(0, CTRL_SYNC, NULL) != RES_OK) return FR_RW_ERROR;
     d46:       40 e0           ldi     r20, 0x00       ; 0
     d48:       50 e0           ldi     r21, 0x00       ; 0
     d4a:       63 e0           ldi     r22, 0x03       ; 3
     d4c:       80 e0           ldi     r24, 0x00       ; 0
     d4e:       0e 94 e8 0d     call    0x1bd0  ; 0x1bd0 <disk_ioctl>
     d52:       89 2b           or      r24, r25
     d54:       19 f0           breq    .+6             ; 0xd5c <f_sync+0xa2>
     d56:       98 e0           ldi     r25, 0x08       ; 8
     d58:       e9 2e           mov     r14, r25
     d5a:       f1 2c           mov     r15, r1
                        fp->flag &= ~FA__WRITTEN;
                        res = sync();
                }
        }
        return res;
}
     d5c:       c7 01           movw    r24, r14
     d5e:       e6 e0           ldi     r30, 0x06       ; 6
     d60:       cd b7           in      r28, 0x3d       ; 61
     d62:       de b7           in      r29, 0x3e       ; 62
     d64:       0c 94 52 11     jmp     0x22a4  ; 0x22a4 <__epilogue_restores__+0x18>

00000d68 <f_close>:
/*-----------------------------------------------------------------------*/

FRESULT f_close (
        FIL *fp         /* Pointer to the file object to be closed */
)
{
     d68:       cf 93           push    r28
     d6a:       df 93           push    r29
     d6c:       ec 01           movw    r28, r24
        FRESULT res;


#if !_FS_READONLY
        res = f_sync(fp);
     d6e:       0e 94 5d 06     call    0xcba   ; 0xcba <f_sync>
#else
        res = validate(fp->fs, fp->id);
#endif
        if (res == FR_OK)
     d72:       00 97           sbiw    r24, 0x00       ; 0
     d74:       11 f4           brne    .+4             ; 0xd7a <f_close+0x12>
                fp->fs = NULL;
     d76:       1d 82           std     Y+5, r1 ; 0x05
     d78:       1c 82           std     Y+4, r1 ; 0x04
     d7a:       df 91           pop     r29
     d7c:       cf 91           pop     r28
     d7e:       08 95           ret

00000d80 <f_write>:
        FIL *fp,                        /* Pointer to the file object */
        const void *buff,       /* Pointer to the data to be written */
        WORD btw,                       /* Number of bytes to write */
        WORD *bw                        /* Pointer to number of bytes written */
)
{
     d80:       a0 e0           ldi     r26, 0x00       ; 0
     d82:       b0 e0           ldi     r27, 0x00       ; 0
     d84:       e6 ec           ldi     r30, 0xC6       ; 198
     d86:       f6 e0           ldi     r31, 0x06       ; 6
     d88:       0c 94 2c 11     jmp     0x2258  ; 0x2258 <__prologue_saves__+0x4>
     d8c:       ec 01           movw    r28, r24
     d8e:       8b 01           movw    r16, r22
     d90:       7a 01           movw    r14, r20
     d92:       39 01           movw    r6, r18
        WORD wcnt;
        CLUST clust;
        BYTE cc;
        FRESULT res;
        const BYTE *wbuff = buff;
        FATFS *fs = fp->fs;
     d94:       cc 80           ldd     r12, Y+4        ; 0x04
     d96:       dd 80           ldd     r13, Y+5        ; 0x05


        *bw = 0;
     d98:       f9 01           movw    r30, r18
     d9a:       11 82           std     Z+1, r1 ; 0x01
     d9c:       10 82           st      Z, r1
        res = validate(fs, fp->id);                                             /* Check validity of the object */
     d9e:       68 81           ld      r22, Y
     da0:       79 81           ldd     r23, Y+1        ; 0x01
     da2:       c6 01           movw    r24, r12
     da4:       0e 94 43 03     call    0x686   ; 0x686 <validate>
     da8:       4c 01           movw    r8, r24
        if (res) return res;
     daa:       89 2b           or      r24, r25
     dac:       09 f0           breq    .+2             ; 0xdb0 <f_write+0x30>
     dae:       1a c1           rjmp    .+564           ; 0xfe4 <f_write+0x264>
        if (fp->flag & FA__ERROR) return FR_RW_ERROR;   /* Check error flag */
     db0:       8a 81           ldd     r24, Y+2        ; 0x02
     db2:       88 23           and     r24, r24
     db4:       0c f4           brge    .+2             ; 0xdb8 <f_write+0x38>
     db6:       13 c1           rjmp    .+550           ; 0xfde <f_write+0x25e>
        if (!(fp->flag & FA_WRITE)) return FR_DENIED;   /* Check access mode */
     db8:       81 fd           sbrc    r24, 1
     dba:       04 c0           rjmp    .+8             ; 0xdc4 <f_write+0x44>
     dbc:       e6 e0           ldi     r30, 0x06       ; 6
     dbe:       8e 2e           mov     r8, r30
     dc0:       91 2c           mov     r9, r1
     dc2:       10 c1           rjmp    .+544           ; 0xfe4 <f_write+0x264>
        if (fp->fsize + btw < fp->fsize) return FR_OK;  /* File size cannot reach 4GB */
     dc4:       2a 85           ldd     r18, Y+10       ; 0x0a
     dc6:       3b 85           ldd     r19, Y+11       ; 0x0b
     dc8:       4c 85           ldd     r20, Y+12       ; 0x0c
     dca:       5d 85           ldd     r21, Y+13       ; 0x0d
     dcc:       c7 01           movw    r24, r14
     dce:       aa 27           eor     r26, r26
     dd0:       bb 27           eor     r27, r27
     dd2:       82 0f           add     r24, r18
     dd4:       93 1f           adc     r25, r19
     dd6:       a4 1f           adc     r26, r20
     dd8:       b5 1f           adc     r27, r21
     dda:       82 17           cp      r24, r18
     ddc:       93 07           cpc     r25, r19
     dde:       a4 07           cpc     r26, r20
     de0:       b5 07           cpc     r27, r21
     de2:       08 f4           brcc    .+2             ; 0xde6 <f_write+0x66>
     de4:       ff c0           rjmp    .+510           ; 0xfe4 <f_write+0x264>
        DWORD sect;
        WORD wcnt;
        CLUST clust;
        BYTE cc;
        FRESULT res;
        const BYTE *wbuff = buff;
     de6:       58 01           movw    r10, r16
                }
                if (!move_window(fp->curr_sect))                        /* Move sector window */
                        goto fw_error;
                wcnt = 512 - (WORD)(fp->fptr % 512);                    /* Copy fractional bytes bytes to sector window */
                if (wcnt > btw) wcnt = btw;
                memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
     de8:       70 e2           ldi     r23, 0x20       ; 32
     dea:       47 2e           mov     r4, r23
     dec:       51 2c           mov     r5, r1
     dee:       4c 0c           add     r4, r12
     df0:       5d 1c           adc     r5, r13
     df2:       d9 c0           rjmp    .+434           ; 0xfa6 <f_write+0x226>
        if (!(fp->flag & FA_WRITE)) return FR_DENIED;   /* Check access mode */
        if (fp->fsize + btw < fp->fsize) return FR_OK;  /* File size cannot reach 4GB */

        for ( ;  btw;                                                                   /* Repeat until all data transferred */
                wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
                if ((fp->fptr % 512) == 0) {                            /* On the sector boundary */
     df4:       2e 81           ldd     r18, Y+6        ; 0x06
     df6:       3f 81           ldd     r19, Y+7        ; 0x07
     df8:       48 85           ldd     r20, Y+8        ; 0x08
     dfa:       59 85           ldd     r21, Y+9        ; 0x09
     dfc:       da 01           movw    r26, r20
     dfe:       c9 01           movw    r24, r18
     e00:       91 70           andi    r25, 0x01       ; 1
     e02:       a0 70           andi    r26, 0x00       ; 0
     e04:       b0 70           andi    r27, 0x00       ; 0
     e06:       00 97           sbiw    r24, 0x00       ; 0
     e08:       a1 05           cpc     r26, r1
     e0a:       b1 05           cpc     r27, r1
     e0c:       09 f0           breq    .+2             ; 0xe10 <f_write+0x90>
     e0e:       93 c0           rjmp    .+294           ; 0xf36 <f_write+0x1b6>
                        if (--(fp->sect_clust)) {                               /* Decrement left sector counter */
     e10:       8b 81           ldd     r24, Y+3        ; 0x03
     e12:       81 50           subi    r24, 0x01       ; 1
     e14:       8b 83           std     Y+3, r24        ; 0x03
     e16:       88 23           and     r24, r24
     e18:       49 f0           breq    .+18            ; 0xe2c <f_write+0xac>
                                sect = fp->curr_sect + 1;                       /* Get current sector */
     e1a:       2a 89           ldd     r18, Y+18       ; 0x12
     e1c:       3b 89           ldd     r19, Y+19       ; 0x13
     e1e:       4c 89           ldd     r20, Y+20       ; 0x14
     e20:       5d 89           ldd     r21, Y+21       ; 0x15
     e22:       2f 5f           subi    r18, 0xFF       ; 255
     e24:       3f 4f           sbci    r19, 0xFF       ; 255
     e26:       4f 4f           sbci    r20, 0xFF       ; 255
     e28:       5f 4f           sbci    r21, 0xFF       ; 255
     e2a:       30 c0           rjmp    .+96            ; 0xe8c <f_write+0x10c>
                        } else {                                                                /* On the cluster boundary, get next cluster */
                                if (fp->fptr == 0) {                            /* Is top of the file */
     e2c:       21 15           cp      r18, r1
     e2e:       31 05           cpc     r19, r1
     e30:       41 05           cpc     r20, r1
     e32:       51 05           cpc     r21, r1
     e34:       69 f4           brne    .+26            ; 0xe50 <f_write+0xd0>
                                        clust = fp->org_clust;
     e36:       2e 85           ldd     r18, Y+14       ; 0x0e
     e38:       3f 85           ldd     r19, Y+15       ; 0x0f
                                        if (clust == 0)                                 /* No cluster is created yet */
     e3a:       21 15           cp      r18, r1
     e3c:       31 05           cpc     r19, r1
     e3e:       89 f4           brne    .+34            ; 0xe62 <f_write+0xe2>
                                                fp->org_clust = clust = create_chain(0);        /* Create a new cluster chain */
     e40:       80 e0           ldi     r24, 0x00       ; 0
     e42:       90 e0           ldi     r25, 0x00       ; 0
     e44:       0e 94 25 05     call    0xa4a   ; 0xa4a <create_chain>
     e48:       9c 01           movw    r18, r24
     e4a:       9f 87           std     Y+15, r25       ; 0x0f
     e4c:       8e 87           std     Y+14, r24       ; 0x0e
     e4e:       05 c0           rjmp    .+10            ; 0xe5a <f_write+0xda>
                                } else {                                                        /* Middle or end of file */
                                        clust = create_chain(fp->curr_clust);                   /* Trace or streach cluster chain */
     e50:       88 89           ldd     r24, Y+16       ; 0x10
     e52:       99 89           ldd     r25, Y+17       ; 0x11
     e54:       0e 94 25 05     call    0xa4a   ; 0xa4a <create_chain>
     e58:       9c 01           movw    r18, r24
                                }
                                if (clust == 0) break;                          /* Disk full */
     e5a:       21 15           cp      r18, r1
     e5c:       31 05           cpc     r19, r1
     e5e:       09 f4           brne    .+2             ; 0xe62 <f_write+0xe2>
     e60:       a6 c0           rjmp    .+332           ; 0xfae <f_write+0x22e>
                                if (clust == 1 || clust >= fs->max_clust) goto fw_error;
     e62:       21 30           cpi     r18, 0x01       ; 1
     e64:       31 05           cpc     r19, r1
     e66:       09 f4           brne    .+2             ; 0xe6a <f_write+0xea>
     e68:       b7 c0           rjmp    .+366           ; 0xfd8 <f_write+0x258>
     e6a:       f6 01           movw    r30, r12
     e6c:       86 89           ldd     r24, Z+22       ; 0x16
     e6e:       97 89           ldd     r25, Z+23       ; 0x17
     e70:       28 17           cp      r18, r24
     e72:       39 07           cpc     r19, r25
     e74:       08 f0           brcs    .+2             ; 0xe78 <f_write+0xf8>
     e76:       b0 c0           rjmp    .+352           ; 0xfd8 <f_write+0x258>
                                fp->curr_clust = clust;                         /* Current cluster */
     e78:       39 8b           std     Y+17, r19       ; 0x11
     e7a:       28 8b           std     Y+16, r18       ; 0x10
                                sect = clust2sect(clust);                       /* Get current sector */
     e7c:       c9 01           movw    r24, r18
     e7e:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
     e82:       9b 01           movw    r18, r22
     e84:       ac 01           movw    r20, r24
                                fp->sect_clust = fs->sects_clust;       /* Re-initialize the left sector counter */
     e86:       f6 01           movw    r30, r12
     e88:       85 8d           ldd     r24, Z+29       ; 0x1d
     e8a:       8b 83           std     Y+3, r24        ; 0x03
                        }
                        fp->curr_sect = sect;                                   /* Update current sector */
     e8c:       2a 8b           std     Y+18, r18       ; 0x12
     e8e:       3b 8b           std     Y+19, r19       ; 0x13
     e90:       4c 8b           std     Y+20, r20       ; 0x14
     e92:       5d 8b           std     Y+21, r21       ; 0x15
                        cc = btw / 512;                                                 /* When left bytes >= 512, */
     e94:       87 01           movw    r16, r14
     e96:       01 2f           mov     r16, r17
     e98:       11 27           eor     r17, r17
     e9a:       06 95           lsr     r16
                        if (cc) {                                                               /* Write maximum contiguous sectors directly */
     e9c:       00 23           and     r16, r16
     e9e:       61 f1           breq    .+88            ; 0xef8 <f_write+0x178>
     ea0:       8b 81           ldd     r24, Y+3        ; 0x03
     ea2:       10 2f           mov     r17, r16
     ea4:       80 17           cp      r24, r16
     ea6:       08 f4           brcc    .+2             ; 0xeaa <f_write+0x12a>
     ea8:       18 2f           mov     r17, r24
                                if (cc > fp->sect_clust) cc = fp->sect_clust;
                                if (disk_write(0, wbuff, sect, cc) != RES_OK)
     eaa:       01 2f           mov     r16, r17
     eac:       b5 01           movw    r22, r10
     eae:       80 e0           ldi     r24, 0x00       ; 0
     eb0:       0e 94 d3 0e     call    0x1da6  ; 0x1da6 <disk_write>
     eb4:       89 2b           or      r24, r25
     eb6:       09 f0           breq    .+2             ; 0xeba <f_write+0x13a>
     eb8:       8f c0           rjmp    .+286           ; 0xfd8 <f_write+0x258>
                                        goto fw_error;
                                fp->sect_clust -= cc - 1;
     eba:       8b 81           ldd     r24, Y+3        ; 0x03
     ebc:       8f 5f           subi    r24, 0xFF       ; 255
     ebe:       81 1b           sub     r24, r17
     ec0:       8b 83           std     Y+3, r24        ; 0x03
                                fp->curr_sect += cc - 1;
     ec2:       81 2f           mov     r24, r17
     ec4:       99 27           eor     r25, r25
     ec6:       01 97           sbiw    r24, 0x01       ; 1
     ec8:       9c 01           movw    r18, r24
     eca:       44 27           eor     r20, r20
     ecc:       37 fd           sbrc    r19, 7
     ece:       40 95           com     r20
     ed0:       54 2f           mov     r21, r20
     ed2:       8c 01           movw    r16, r24
     ed4:       0f 5f           subi    r16, 0xFF       ; 255
     ed6:       1f 4f           sbci    r17, 0xFF       ; 255
     ed8:       8a 89           ldd     r24, Y+18       ; 0x12
     eda:       9b 89           ldd     r25, Y+19       ; 0x13
     edc:       ac 89           ldd     r26, Y+20       ; 0x14
     ede:       bd 89           ldd     r27, Y+21       ; 0x15
     ee0:       82 0f           add     r24, r18
     ee2:       93 1f           adc     r25, r19
     ee4:       a4 1f           adc     r26, r20
     ee6:       b5 1f           adc     r27, r21
     ee8:       8a 8b           std     Y+18, r24       ; 0x12
     eea:       9b 8b           std     Y+19, r25       ; 0x13
     eec:       ac 8b           std     Y+20, r26       ; 0x14
     eee:       bd 8b           std     Y+21, r27       ; 0x15
                                wcnt = cc * 512; continue;
     ef0:       10 2f           mov     r17, r16
     ef2:       00 27           eor     r16, r16
     ef4:       11 0f           add     r17, r17
     ef6:       3d c0           rjmp    .+122           ; 0xf72 <f_write+0x1f2>
                        }
                        if (fp->fptr >= fp->fsize) {                    /* Flush R/W window if needed */
     ef8:       2e 81           ldd     r18, Y+6        ; 0x06
     efa:       3f 81           ldd     r19, Y+7        ; 0x07
     efc:       48 85           ldd     r20, Y+8        ; 0x08
     efe:       59 85           ldd     r21, Y+9        ; 0x09
     f00:       8a 85           ldd     r24, Y+10       ; 0x0a
     f02:       9b 85           ldd     r25, Y+11       ; 0x0b
     f04:       ac 85           ldd     r26, Y+12       ; 0x0c
     f06:       bd 85           ldd     r27, Y+13       ; 0x0d
     f08:       28 17           cp      r18, r24
     f0a:       39 07           cpc     r19, r25
     f0c:       4a 07           cpc     r20, r26
     f0e:       5b 07           cpc     r21, r27
     f10:       90 f0           brcs    .+36            ; 0xf36 <f_write+0x1b6>
                                if (!move_window(0)) goto fw_error;
     f12:       60 e0           ldi     r22, 0x00       ; 0
     f14:       70 e0           ldi     r23, 0x00       ; 0
     f16:       80 e0           ldi     r24, 0x00       ; 0
     f18:       90 e0           ldi     r25, 0x00       ; 0
     f1a:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     f1e:       88 23           and     r24, r24
     f20:       09 f4           brne    .+2             ; 0xf24 <f_write+0x1a4>
     f22:       5a c0           rjmp    .+180           ; 0xfd8 <f_write+0x258>
                                fs->winsect = fp->curr_sect;
     f24:       8a 89           ldd     r24, Y+18       ; 0x12
     f26:       9b 89           ldd     r25, Y+19       ; 0x13
     f28:       ac 89           ldd     r26, Y+20       ; 0x14
     f2a:       bd 89           ldd     r27, Y+21       ; 0x15
     f2c:       f6 01           movw    r30, r12
     f2e:       84 83           std     Z+4, r24        ; 0x04
     f30:       95 83           std     Z+5, r25        ; 0x05
     f32:       a6 83           std     Z+6, r26        ; 0x06
     f34:       b7 83           std     Z+7, r27        ; 0x07
                        }
                }
                if (!move_window(fp->curr_sect))                        /* Move sector window */
     f36:       6a 89           ldd     r22, Y+18       ; 0x12
     f38:       7b 89           ldd     r23, Y+19       ; 0x13
     f3a:       8c 89           ldd     r24, Y+20       ; 0x14
     f3c:       9d 89           ldd     r25, Y+21       ; 0x15
     f3e:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
     f42:       88 23           and     r24, r24
     f44:       09 f4           brne    .+2             ; 0xf48 <f_write+0x1c8>
     f46:       48 c0           rjmp    .+144           ; 0xfd8 <f_write+0x258>
                        goto fw_error;
                wcnt = 512 - (WORD)(fp->fptr % 512);                    /* Copy fractional bytes bytes to sector window */
     f48:       8e 81           ldd     r24, Y+6        ; 0x06
     f4a:       9f 81           ldd     r25, Y+7        ; 0x07
     f4c:       91 70           andi    r25, 0x01       ; 1
     f4e:       20 e0           ldi     r18, 0x00       ; 0
     f50:       32 e0           ldi     r19, 0x02       ; 2
     f52:       28 1b           sub     r18, r24
     f54:       39 0b           sbc     r19, r25
     f56:       87 01           movw    r16, r14
     f58:       2e 15           cp      r18, r14
     f5a:       3f 05           cpc     r19, r15
     f5c:       08 f4           brcc    .+2             ; 0xf60 <f_write+0x1e0>
     f5e:       89 01           movw    r16, r18
                if (wcnt > btw) wcnt = btw;
                memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
     f60:       a8 01           movw    r20, r16
     f62:       b5 01           movw    r22, r10
     f64:       84 0d           add     r24, r4
     f66:       95 1d           adc     r25, r5
     f68:       0e 94 a1 10     call    0x2142  ; 0x2142 <memcpy>
                fs->winflag = 1;
     f6c:       81 e0           ldi     r24, 0x01       ; 1
     f6e:       f6 01           movw    r30, r12
     f70:       87 8f           std     Z+31, r24       ; 0x1f
        if (fp->flag & FA__ERROR) return FR_RW_ERROR;   /* Check error flag */
        if (!(fp->flag & FA_WRITE)) return FR_DENIED;   /* Check access mode */
        if (fp->fsize + btw < fp->fsize) return FR_OK;  /* File size cannot reach 4GB */

        for ( ;  btw;                                                                   /* Repeat until all data transferred */
                wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) {
     f72:       a0 0e           add     r10, r16
     f74:       b1 1e           adc     r11, r17
     f76:       c8 01           movw    r24, r16
     f78:       aa 27           eor     r26, r26
     f7a:       bb 27           eor     r27, r27
     f7c:       2e 81           ldd     r18, Y+6        ; 0x06
     f7e:       3f 81           ldd     r19, Y+7        ; 0x07
     f80:       48 85           ldd     r20, Y+8        ; 0x08
     f82:       59 85           ldd     r21, Y+9        ; 0x09
     f84:       28 0f           add     r18, r24
     f86:       39 1f           adc     r19, r25
     f88:       4a 1f           adc     r20, r26
     f8a:       5b 1f           adc     r21, r27
     f8c:       2e 83           std     Y+6, r18        ; 0x06
     f8e:       3f 83           std     Y+7, r19        ; 0x07
     f90:       48 87           std     Y+8, r20        ; 0x08
     f92:       59 87           std     Y+9, r21        ; 0x09
     f94:       f3 01           movw    r30, r6
     f96:       80 81           ld      r24, Z
     f98:       91 81           ldd     r25, Z+1        ; 0x01
     f9a:       80 0f           add     r24, r16
     f9c:       91 1f           adc     r25, r17
     f9e:       91 83           std     Z+1, r25        ; 0x01
     fa0:       80 83           st      Z, r24
     fa2:       e0 1a           sub     r14, r16
     fa4:       f1 0a           sbc     r15, r17
        if (res) return res;
        if (fp->flag & FA__ERROR) return FR_RW_ERROR;   /* Check error flag */
        if (!(fp->flag & FA_WRITE)) return FR_DENIED;   /* Check access mode */
        if (fp->fsize + btw < fp->fsize) return FR_OK;  /* File size cannot reach 4GB */

        for ( ;  btw;                                                                   /* Repeat until all data transferred */
     fa6:       e1 14           cp      r14, r1
     fa8:       f1 04           cpc     r15, r1
     faa:       09 f0           breq    .+2             ; 0xfae <f_write+0x22e>
     fac:       23 cf           rjmp    .-442           ; 0xdf4 <f_write+0x74>
                if (wcnt > btw) wcnt = btw;
                memcpy(&fs->win[(WORD)fp->fptr % 512], wbuff, wcnt);
                fs->winflag = 1;
        }

        if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */
     fae:       2e 81           ldd     r18, Y+6        ; 0x06
     fb0:       3f 81           ldd     r19, Y+7        ; 0x07
     fb2:       48 85           ldd     r20, Y+8        ; 0x08
     fb4:       59 85           ldd     r21, Y+9        ; 0x09
     fb6:       8a 85           ldd     r24, Y+10       ; 0x0a
     fb8:       9b 85           ldd     r25, Y+11       ; 0x0b
     fba:       ac 85           ldd     r26, Y+12       ; 0x0c
     fbc:       bd 85           ldd     r27, Y+13       ; 0x0d
     fbe:       82 17           cp      r24, r18
     fc0:       93 07           cpc     r25, r19
     fc2:       a4 07           cpc     r26, r20
     fc4:       b5 07           cpc     r27, r21
     fc6:       20 f4           brcc    .+8             ; 0xfd0 <f_write+0x250>
     fc8:       2a 87           std     Y+10, r18       ; 0x0a
     fca:       3b 87           std     Y+11, r19       ; 0x0b
     fcc:       4c 87           std     Y+12, r20       ; 0x0c
     fce:       5d 87           std     Y+13, r21       ; 0x0d
        fp->flag |= FA__WRITTEN;                                                /* Set file changed flag */
     fd0:       8a 81           ldd     r24, Y+2        ; 0x02
     fd2:       80 62           ori     r24, 0x20       ; 32
     fd4:       8a 83           std     Y+2, r24        ; 0x02
     fd6:       06 c0           rjmp    .+12            ; 0xfe4 <f_write+0x264>
        return FR_OK;

fw_error:       /* Abort this function due to an unrecoverable error */
        fp->flag |= FA__ERROR;
     fd8:       8a 81           ldd     r24, Y+2        ; 0x02
     fda:       80 68           ori     r24, 0x80       ; 128
     fdc:       8a 83           std     Y+2, r24        ; 0x02
     fde:       28 e0           ldi     r18, 0x08       ; 8
     fe0:       82 2e           mov     r8, r18
     fe2:       91 2c           mov     r9, r1
        return FR_RW_ERROR;
}
     fe4:       c4 01           movw    r24, r8
     fe6:       e0 e1           ldi     r30, 0x10       ; 16
     fe8:       cd b7           in      r28, 0x3d       ; 61
     fea:       de b7           in      r29, 0x3e       ; 62
     fec:       0c 94 48 11     jmp     0x2290  ; 0x2290 <__epilogue_restores__+0x4>

00000ff0 <f_read>:
        FIL *fp,                /* Pointer to the file object */
        void *buff,             /* Pointer to data buffer */
        WORD btr,               /* Number of bytes to read */
        WORD *br                /* Pointer to number of bytes read */
)
{
     ff0:       a0 e0           ldi     r26, 0x00       ; 0
     ff2:       b0 e0           ldi     r27, 0x00       ; 0
     ff4:       ee ef           ldi     r30, 0xFE       ; 254
     ff6:       f7 e0           ldi     r31, 0x07       ; 7
     ff8:       0c 94 2c 11     jmp     0x2258  ; 0x2258 <__prologue_saves__+0x4>
     ffc:       ec 01           movw    r28, r24
     ffe:       8b 01           movw    r16, r22
    1000:       7a 01           movw    r14, r20
    1002:       39 01           movw    r6, r18
        DWORD sect, remain;
        WORD rcnt;
        CLUST clust;
        BYTE cc, *rbuff = buff;
        FRESULT res;
        FATFS *fs = fp->fs;
    1004:       8c 80           ldd     r8, Y+4 ; 0x04
    1006:       9d 80           ldd     r9, Y+5 ; 0x05


        *br = 0;
    1008:       f9 01           movw    r30, r18
    100a:       11 82           std     Z+1, r1 ; 0x01
    100c:       10 82           st      Z, r1
        res = validate(fs, fp->id);                                             /* Check validity of the object */
    100e:       68 81           ld      r22, Y
    1010:       79 81           ldd     r23, Y+1        ; 0x01
    1012:       c4 01           movw    r24, r8
    1014:       0e 94 43 03     call    0x686   ; 0x686 <validate>
    1018:       5c 01           movw    r10, r24
        if (res) return res;
    101a:       89 2b           or      r24, r25
    101c:       09 f0           breq    .+2             ; 0x1020 <f_read+0x30>
    101e:       d9 c0           rjmp    .+434           ; 0x11d2 <f_read+0x1e2>
        if (fp->flag & FA__ERROR) return FR_RW_ERROR;   /* Check error flag */
    1020:       8a 81           ldd     r24, Y+2        ; 0x02
    1022:       88 23           and     r24, r24
    1024:       0c f4           brge    .+2             ; 0x1028 <f_read+0x38>
    1026:       d2 c0           rjmp    .+420           ; 0x11cc <f_read+0x1dc>
        if (!(fp->flag & FA_READ)) return FR_DENIED;    /* Check access mode */
    1028:       80 fd           sbrc    r24, 0
    102a:       04 c0           rjmp    .+8             ; 0x1034 <f_read+0x44>
    102c:       06 e0           ldi     r16, 0x06       ; 6
    102e:       a0 2e           mov     r10, r16
    1030:       b1 2c           mov     r11, r1
    1032:       cf c0           rjmp    .+414           ; 0x11d2 <f_read+0x1e2>
        remain = fp->fsize - fp->fptr;
    1034:       2a 85           ldd     r18, Y+10       ; 0x0a
    1036:       3b 85           ldd     r19, Y+11       ; 0x0b
    1038:       4c 85           ldd     r20, Y+12       ; 0x0c
    103a:       5d 85           ldd     r21, Y+13       ; 0x0d
    103c:       8e 81           ldd     r24, Y+6        ; 0x06
    103e:       9f 81           ldd     r25, Y+7        ; 0x07
    1040:       a8 85           ldd     r26, Y+8        ; 0x08
    1042:       b9 85           ldd     r27, Y+9        ; 0x09
    1044:       28 1b           sub     r18, r24
    1046:       39 0b           sbc     r19, r25
    1048:       4a 0b           sbc     r20, r26
    104a:       5b 0b           sbc     r21, r27
        if (btr > remain) btr = (WORD)remain;                   /* Truncate read count by number of bytes left */
    104c:       c7 01           movw    r24, r14
    104e:       aa 27           eor     r26, r26
    1050:       bb 27           eor     r27, r27
    1052:       28 17           cp      r18, r24
    1054:       39 07           cpc     r19, r25
    1056:       4a 07           cpc     r20, r26
    1058:       5b 07           cpc     r21, r27
    105a:       08 f4           brcc    .+2             ; 0x105e <f_read+0x6e>
    105c:       79 01           movw    r14, r18
)
{
        DWORD sect, remain;
        WORD rcnt;
        CLUST clust;
        BYTE cc, *rbuff = buff;
    105e:       68 01           movw    r12, r16
                        }
                }
                if (!move_window(fp->curr_sect)) goto fr_error; /* Move sector window */
                rcnt = 512 - (WORD)(fp->fptr % 512);                    /* Copy fractional bytes from sector window */
                if (rcnt > btr) rcnt = btr;
                memcpy(rbuff, &fs->win[(WORD)fp->fptr % 512], rcnt);
    1060:       10 e2           ldi     r17, 0x20       ; 32
    1062:       41 2e           mov     r4, r17
    1064:       51 2c           mov     r5, r1
    1066:       48 0c           add     r4, r8
    1068:       59 1c           adc     r5, r9
    106a:       a8 c0           rjmp    .+336           ; 0x11bc <f_read+0x1cc>
        remain = fp->fsize - fp->fptr;
        if (btr > remain) btr = (WORD)remain;                   /* Truncate read count by number of bytes left */

        for ( ;  btr;                                                                   /* Repeat until all data transferred */
                rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
                if ((fp->fptr % 512) == 0) {                            /* On the sector boundary */
    106c:       2e 81           ldd     r18, Y+6        ; 0x06
    106e:       3f 81           ldd     r19, Y+7        ; 0x07
    1070:       48 85           ldd     r20, Y+8        ; 0x08
    1072:       59 85           ldd     r21, Y+9        ; 0x09
    1074:       da 01           movw    r26, r20
    1076:       c9 01           movw    r24, r18
    1078:       91 70           andi    r25, 0x01       ; 1
    107a:       a0 70           andi    r26, 0x00       ; 0
    107c:       b0 70           andi    r27, 0x00       ; 0
    107e:       00 97           sbiw    r24, 0x00       ; 0
    1080:       a1 05           cpc     r26, r1
    1082:       b1 05           cpc     r27, r1
    1084:       09 f0           breq    .+2             ; 0x1088 <f_read+0x98>
    1086:       66 c0           rjmp    .+204           ; 0x1154 <f_read+0x164>
                        if (--fp->sect_clust) {                                 /* Decrement left sector counter */
    1088:       8b 81           ldd     r24, Y+3        ; 0x03
    108a:       81 50           subi    r24, 0x01       ; 1
    108c:       8b 83           std     Y+3, r24        ; 0x03
    108e:       88 23           and     r24, r24
    1090:       49 f0           breq    .+18            ; 0x10a4 <f_read+0xb4>
                                sect = fp->curr_sect + 1;                       /* Get current sector */
    1092:       2a 89           ldd     r18, Y+18       ; 0x12
    1094:       3b 89           ldd     r19, Y+19       ; 0x13
    1096:       4c 89           ldd     r20, Y+20       ; 0x14
    1098:       5d 89           ldd     r21, Y+21       ; 0x15
    109a:       2f 5f           subi    r18, 0xFF       ; 255
    109c:       3f 4f           sbci    r19, 0xFF       ; 255
    109e:       4f 4f           sbci    r20, 0xFF       ; 255
    10a0:       5f 4f           sbci    r21, 0xFF       ; 255
    10a2:       22 c0           rjmp    .+68            ; 0x10e8 <f_read+0xf8>
                        } else {                                                                /* On the cluster boundary, get next cluster */
                                clust = (fp->fptr == 0) ?
    10a4:       21 15           cp      r18, r1
    10a6:       31 05           cpc     r19, r1
    10a8:       41 05           cpc     r20, r1
    10aa:       51 05           cpc     r21, r1
    10ac:       19 f4           brne    .+6             ; 0x10b4 <f_read+0xc4>
    10ae:       2e 85           ldd     r18, Y+14       ; 0x0e
    10b0:       3f 85           ldd     r19, Y+15       ; 0x0f
    10b2:       05 c0           rjmp    .+10            ; 0x10be <f_read+0xce>
    10b4:       88 89           ldd     r24, Y+16       ; 0x10
    10b6:       99 89           ldd     r25, Y+17       ; 0x11
    10b8:       0e 94 4f 04     call    0x89e   ; 0x89e <get_cluster>
    10bc:       9c 01           movw    r18, r24
                                        fp->org_clust : get_cluster(fp->curr_clust);
                                if (clust < 2 || clust >= fs->max_clust)
    10be:       22 30           cpi     r18, 0x02       ; 2
    10c0:       31 05           cpc     r19, r1
    10c2:       08 f4           brcc    .+2             ; 0x10c6 <f_read+0xd6>
    10c4:       80 c0           rjmp    .+256           ; 0x11c6 <f_read+0x1d6>
    10c6:       f4 01           movw    r30, r8
    10c8:       86 89           ldd     r24, Z+22       ; 0x16
    10ca:       97 89           ldd     r25, Z+23       ; 0x17
    10cc:       28 17           cp      r18, r24
    10ce:       39 07           cpc     r19, r25
    10d0:       08 f0           brcs    .+2             ; 0x10d4 <f_read+0xe4>
    10d2:       79 c0           rjmp    .+242           ; 0x11c6 <f_read+0x1d6>
                                        goto fr_error;
                                fp->curr_clust = clust;                         /* Current cluster */
    10d4:       39 8b           std     Y+17, r19       ; 0x11
    10d6:       28 8b           std     Y+16, r18       ; 0x10
                                sect = clust2sect(clust);                       /* Get current sector */
    10d8:       c9 01           movw    r24, r18
    10da:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
    10de:       9b 01           movw    r18, r22
    10e0:       ac 01           movw    r20, r24
                                fp->sect_clust = fs->sects_clust;       /* Re-initialize the left sector counter */
    10e2:       f4 01           movw    r30, r8
    10e4:       85 8d           ldd     r24, Z+29       ; 0x1d
    10e6:       8b 83           std     Y+3, r24        ; 0x03
                        }
                        fp->curr_sect = sect;                                   /* Update current sector */
    10e8:       2a 8b           std     Y+18, r18       ; 0x12
    10ea:       3b 8b           std     Y+19, r19       ; 0x13
    10ec:       4c 8b           std     Y+20, r20       ; 0x14
    10ee:       5d 8b           std     Y+21, r21       ; 0x15
                        cc = btr / 512;                                                 /* When left bytes >= 512, */
    10f0:       87 01           movw    r16, r14
    10f2:       01 2f           mov     r16, r17
    10f4:       11 27           eor     r17, r17
    10f6:       06 95           lsr     r16
                        if (cc) {                                                               /* Read maximum contiguous sectors directly */
    10f8:       00 23           and     r16, r16
    10fa:       61 f1           breq    .+88            ; 0x1154 <f_read+0x164>
    10fc:       8b 81           ldd     r24, Y+3        ; 0x03
    10fe:       10 2f           mov     r17, r16
    1100:       80 17           cp      r24, r16
    1102:       08 f4           brcc    .+2             ; 0x1106 <f_read+0x116>
    1104:       18 2f           mov     r17, r24
                                if (cc > fp->sect_clust) cc = fp->sect_clust;
                                if (disk_read(0, rbuff, sect, cc) != RES_OK)
    1106:       01 2f           mov     r16, r17
    1108:       b6 01           movw    r22, r12
    110a:       80 e0           ldi     r24, 0x00       ; 0
    110c:       0e 94 51 0f     call    0x1ea2  ; 0x1ea2 <disk_read>
    1110:       89 2b           or      r24, r25
    1112:       09 f0           breq    .+2             ; 0x1116 <f_read+0x126>
    1114:       58 c0           rjmp    .+176           ; 0x11c6 <f_read+0x1d6>
                                        goto fr_error;
                                fp->sect_clust -= cc - 1;
    1116:       8b 81           ldd     r24, Y+3        ; 0x03
    1118:       8f 5f           subi    r24, 0xFF       ; 255
    111a:       81 1b           sub     r24, r17
    111c:       8b 83           std     Y+3, r24        ; 0x03
                                fp->curr_sect += cc - 1;
    111e:       81 2f           mov     r24, r17
    1120:       99 27           eor     r25, r25
    1122:       01 97           sbiw    r24, 0x01       ; 1
    1124:       9c 01           movw    r18, r24
    1126:       44 27           eor     r20, r20
    1128:       37 fd           sbrc    r19, 7
    112a:       40 95           com     r20
    112c:       54 2f           mov     r21, r20
    112e:       8c 01           movw    r16, r24
    1130:       0f 5f           subi    r16, 0xFF       ; 255
    1132:       1f 4f           sbci    r17, 0xFF       ; 255
    1134:       8a 89           ldd     r24, Y+18       ; 0x12
    1136:       9b 89           ldd     r25, Y+19       ; 0x13
    1138:       ac 89           ldd     r26, Y+20       ; 0x14
    113a:       bd 89           ldd     r27, Y+21       ; 0x15
    113c:       82 0f           add     r24, r18
    113e:       93 1f           adc     r25, r19
    1140:       a4 1f           adc     r26, r20
    1142:       b5 1f           adc     r27, r21
    1144:       8a 8b           std     Y+18, r24       ; 0x12
    1146:       9b 8b           std     Y+19, r25       ; 0x13
    1148:       ac 8b           std     Y+20, r26       ; 0x14
    114a:       bd 8b           std     Y+21, r27       ; 0x15
                                rcnt = cc * 512; continue;
    114c:       10 2f           mov     r17, r16
    114e:       00 27           eor     r16, r16
    1150:       11 0f           add     r17, r17
    1152:       1a c0           rjmp    .+52            ; 0x1188 <f_read+0x198>
                        }
                }
                if (!move_window(fp->curr_sect)) goto fr_error; /* Move sector window */
    1154:       6a 89           ldd     r22, Y+18       ; 0x12
    1156:       7b 89           ldd     r23, Y+19       ; 0x13
    1158:       8c 89           ldd     r24, Y+20       ; 0x14
    115a:       9d 89           ldd     r25, Y+21       ; 0x15
    115c:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
    1160:       88 23           and     r24, r24
    1162:       89 f1           breq    .+98            ; 0x11c6 <f_read+0x1d6>
                rcnt = 512 - (WORD)(fp->fptr % 512);                    /* Copy fractional bytes from sector window */
    1164:       6e 81           ldd     r22, Y+6        ; 0x06
    1166:       7f 81           ldd     r23, Y+7        ; 0x07
    1168:       71 70           andi    r23, 0x01       ; 1
    116a:       80 e0           ldi     r24, 0x00       ; 0
    116c:       92 e0           ldi     r25, 0x02       ; 2
    116e:       86 1b           sub     r24, r22
    1170:       97 0b           sbc     r25, r23
    1172:       87 01           movw    r16, r14
    1174:       8e 15           cp      r24, r14
    1176:       9f 05           cpc     r25, r15
    1178:       08 f4           brcc    .+2             ; 0x117c <f_read+0x18c>
    117a:       8c 01           movw    r16, r24
                if (rcnt > btr) rcnt = btr;
                memcpy(rbuff, &fs->win[(WORD)fp->fptr % 512], rcnt);
    117c:       64 0d           add     r22, r4
    117e:       75 1d           adc     r23, r5
    1180:       a8 01           movw    r20, r16
    1182:       c6 01           movw    r24, r12
    1184:       0e 94 a1 10     call    0x2142  ; 0x2142 <memcpy>
        if (!(fp->flag & FA_READ)) return FR_DENIED;    /* Check access mode */
        remain = fp->fsize - fp->fptr;
        if (btr > remain) btr = (WORD)remain;                   /* Truncate read count by number of bytes left */

        for ( ;  btr;                                                                   /* Repeat until all data transferred */
                rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) {
    1188:       c0 0e           add     r12, r16
    118a:       d1 1e           adc     r13, r17
    118c:       c8 01           movw    r24, r16
    118e:       aa 27           eor     r26, r26
    1190:       bb 27           eor     r27, r27
    1192:       2e 81           ldd     r18, Y+6        ; 0x06
    1194:       3f 81           ldd     r19, Y+7        ; 0x07
    1196:       48 85           ldd     r20, Y+8        ; 0x08
    1198:       59 85           ldd     r21, Y+9        ; 0x09
    119a:       28 0f           add     r18, r24
    119c:       39 1f           adc     r19, r25
    119e:       4a 1f           adc     r20, r26
    11a0:       5b 1f           adc     r21, r27
    11a2:       2e 83           std     Y+6, r18        ; 0x06
    11a4:       3f 83           std     Y+7, r19        ; 0x07
    11a6:       48 87           std     Y+8, r20        ; 0x08
    11a8:       59 87           std     Y+9, r21        ; 0x09
    11aa:       f3 01           movw    r30, r6
    11ac:       80 81           ld      r24, Z
    11ae:       91 81           ldd     r25, Z+1        ; 0x01
    11b0:       80 0f           add     r24, r16
    11b2:       91 1f           adc     r25, r17
    11b4:       91 83           std     Z+1, r25        ; 0x01
    11b6:       80 83           st      Z, r24
    11b8:       e0 1a           sub     r14, r16
    11ba:       f1 0a           sbc     r15, r17
        if (fp->flag & FA__ERROR) return FR_RW_ERROR;   /* Check error flag */
        if (!(fp->flag & FA_READ)) return FR_DENIED;    /* Check access mode */
        remain = fp->fsize - fp->fptr;
        if (btr > remain) btr = (WORD)remain;                   /* Truncate read count by number of bytes left */

        for ( ;  btr;                                                                   /* Repeat until all data transferred */
    11bc:       e1 14           cp      r14, r1
    11be:       f1 04           cpc     r15, r1
    11c0:       09 f0           breq    .+2             ; 0x11c4 <f_read+0x1d4>
    11c2:       54 cf           rjmp    .-344           ; 0x106c <f_read+0x7c>
    11c4:       06 c0           rjmp    .+12            ; 0x11d2 <f_read+0x1e2>
        }

        return FR_OK;

fr_error:       /* Abort this function due to an unrecoverable error */
        fp->flag |= FA__ERROR;
    11c6:       8a 81           ldd     r24, Y+2        ; 0x02
    11c8:       80 68           ori     r24, 0x80       ; 128
    11ca:       8a 83           std     Y+2, r24        ; 0x02
    11cc:       f8 e0           ldi     r31, 0x08       ; 8
    11ce:       af 2e           mov     r10, r31
    11d0:       b1 2c           mov     r11, r1
        return FR_RW_ERROR;
}
    11d2:       c5 01           movw    r24, r10
    11d4:       e0 e1           ldi     r30, 0x10       ; 16
    11d6:       cd b7           in      r28, 0x3d       ; 61
    11d8:       de b7           in      r29, 0x3e       ; 62
    11da:       0c 94 48 11     jmp     0x2290  ; 0x2290 <__epilogue_restores__+0x4>

000011de <f_mount>:

FRESULT f_mount (
        BYTE drv,               /* Logical drive number to be mounted/unmounted */
        FATFS *fs               /* Pointer to new file system object (NULL for unmount)*/
)
{
    11de:       fb 01           movw    r30, r22
        FATFS *fsobj;


        if (drv) return FR_INVALID_DRIVE;
    11e0:       88 23           and     r24, r24
    11e2:       19 f0           breq    .+6             ; 0x11ea <f_mount+0xc>
    11e4:       85 e0           ldi     r24, 0x05       ; 5
    11e6:       90 e0           ldi     r25, 0x00       ; 0
    11e8:       08 95           ret
        fsobj = FatFs;
    11ea:       a0 91 0a 01     lds     r26, 0x010A
    11ee:       b0 91 0b 01     lds     r27, 0x010B
        FatFs = fs;
    11f2:       70 93 0b 01     sts     0x010B, r23
    11f6:       60 93 0a 01     sts     0x010A, r22
        if (fsobj) memset(fsobj, 0, sizeof(FATFS));
    11fa:       10 97           sbiw    r26, 0x00       ; 0
    11fc:       29 f0           breq    .+10            ; 0x1208 <f_mount+0x2a>
    11fe:       80 e2           ldi     r24, 0x20       ; 32
    1200:       92 e0           ldi     r25, 0x02       ; 2
    1202:       1d 92           st      X+, r1
    1204:       01 97           sbiw    r24, 0x01       ; 1
    1206:       e9 f7           brne    .-6             ; 0x1202 <f_mount+0x24>
        if (fs) memset(fs, 0, sizeof(FATFS));
    1208:       30 97           sbiw    r30, 0x00       ; 0
    120a:       19 f4           brne    .+6             ; 0x1212 <f_mount+0x34>
    120c:       80 e0           ldi     r24, 0x00       ; 0
    120e:       90 e0           ldi     r25, 0x00       ; 0
    1210:       08 95           ret
    1212:       80 e2           ldi     r24, 0x20       ; 32
    1214:       92 e0           ldi     r25, 0x02       ; 2
    1216:       11 92           st      Z+, r1
    1218:       01 97           sbiw    r24, 0x01       ; 1
    121a:       e9 f7           brne    .-6             ; 0x1216 <f_mount+0x38>
    121c:       80 e0           ldi     r24, 0x00       ; 0
    121e:       90 e0           ldi     r25, 0x00       ; 0

        return FR_OK;
}
    1220:       08 95           ret

00001222 <check_fs>:

static
BYTE check_fs (         /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record or error */
        DWORD sect              /* Sector# to check if it is a FAT boot record or not */
)
{
    1222:       0f 93           push    r16
    1224:       cf 93           push    r28
    1226:       df 93           push    r29
    1228:       9b 01           movw    r18, r22
    122a:       ac 01           movw    r20, r24
        FATFS *fs = FatFs;
    122c:       c0 91 0a 01     lds     r28, 0x010A
    1230:       d0 91 0b 01     lds     r29, 0x010B

        if (disk_read(0, fs->win, sect, 1) != RES_OK)   /* Load boot record */
    1234:       be 01           movw    r22, r28
    1236:       60 5e           subi    r22, 0xE0       ; 224
    1238:       7f 4f           sbci    r23, 0xFF       ; 255
    123a:       01 e0           ldi     r16, 0x01       ; 1
    123c:       80 e0           ldi     r24, 0x00       ; 0
    123e:       0e 94 51 0f     call    0x1ea2  ; 0x1ea2 <disk_read>
    1242:       89 2b           or      r24, r25
    1244:       d9 f4           brne    .+54            ; 0x127c <check_fs+0x5a>
                return 2;
        if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55)               /* Check record signature */
    1246:       c2 5e           subi    r28, 0xE2       ; 226
    1248:       dd 4f           sbci    r29, 0xFD       ; 253
    124a:       88 81           ld      r24, Y
    124c:       99 81           ldd     r25, Y+1        ; 0x01
    124e:       ce 51           subi    r28, 0x1E       ; 30
    1250:       d2 40           sbci    r29, 0x02       ; 2
    1252:       85 55           subi    r24, 0x55       ; 85
    1254:       9a 4a           sbci    r25, 0xAA       ; 170
    1256:       91 f4           brne    .+36            ; 0x127c <check_fs+0x5a>
    1258:       00 e0           ldi     r16, 0x00       ; 0
                return 2;

        if (!memcmp(&fs->win[BS_FilSysType], "FAT", 3)) /* Check FAT signature */
    125a:       43 e0           ldi     r20, 0x03       ; 3
    125c:       50 e0           ldi     r21, 0x00       ; 0
    125e:       60 e0           ldi     r22, 0x00       ; 0
    1260:       71 e0           ldi     r23, 0x01       ; 1
    1262:       ce 01           movw    r24, r28
    1264:       8a 5a           subi    r24, 0xAA       ; 170
    1266:       9f 4f           sbci    r25, 0xFF       ; 255
    1268:       0e 94 94 10     call    0x2128  ; 0x2128 <memcmp>
    126c:       89 2b           or      r24, r25
    126e:       09 f4           brne    .+2             ; 0x1272 <check_fs+0x50>
    1270:       01 e0           ldi     r16, 0x01       ; 1
    1272:       81 e0           ldi     r24, 0x01       ; 1
    1274:       08 27           eor     r16, r24
    1276:       80 2f           mov     r24, r16
    1278:       99 27           eor     r25, r25
    127a:       02 c0           rjmp    .+4             ; 0x1280 <check_fs+0x5e>
    127c:       82 e0           ldi     r24, 0x02       ; 2
    127e:       90 e0           ldi     r25, 0x00       ; 0
    1280:       df 91           pop     r29
    1282:       cf 91           pop     r28
    1284:       0f 91           pop     r16
    1286:       08 95           ret

00001288 <f_open>:
FRESULT f_open (
        FIL *fp,                        /* Pointer to the blank file object */
        const char *path,       /* Pointer to the file name */
        BYTE mode                       /* Access mode and file open mode flags */
)
{
    1288:       ad e1           ldi     r26, 0x1D       ; 29
    128a:       b0 e0           ldi     r27, 0x00       ; 0
    128c:       ea e4           ldi     r30, 0x4A       ; 74
    128e:       f9 e0           ldi     r31, 0x09       ; 9
    1290:       0c 94 2a 11     jmp     0x2254  ; 0x2254 <__prologue_saves__>
    1294:       9d 8f           std     Y+29, r25       ; 0x1d
    1296:       8c 8f           std     Y+28, r24       ; 0x1c
    1298:       6b 01           movw    r12, r22
        FRESULT res;
        BYTE *dir;
        DIR dirobj;
        char fn[8+3+1];
        FATFS *fs = FatFs;
    129a:       a0 90 0a 01     lds     r10, 0x010A
    129e:       b0 90 0b 01     lds     r11, 0x010B


        fp->fs = NULL;
    12a2:       fc 01           movw    r30, r24
    12a4:       15 82           std     Z+5, r1 ; 0x05
    12a6:       14 82           std     Z+4, r1 ; 0x04
#if !_FS_READONLY
        mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW);
    12a8:       f4 2f           mov     r31, r20
    12aa:       ff 71           andi    r31, 0x1F       ; 31
    12ac:       fb 8f           std     Y+27, r31       ; 0x1b
    12ae:       03 c0           rjmp    .+6             ; 0x12b6 <f_open+0x2e>
        const char *p = *path;
        FATFS *fs = FatFs;



        while (*p == ' ') p++;  /* Strip leading spaces */
    12b0:       08 94           sec
    12b2:       c1 1c           adc     r12, r1
    12b4:       d1 1c           adc     r13, r1
    12b6:       d6 01           movw    r26, r12
    12b8:       8c 91           ld      r24, X
    12ba:       80 32           cpi     r24, 0x20       ; 32
    12bc:       c9 f3           breq    .-14            ; 0x12b0 <f_open+0x28>
        if (*p == '/') p++;             /* Strip heading slash */
    12be:       8f 32           cpi     r24, 0x2F       ; 47
    12c0:       19 f4           brne    .+6             ; 0x12c8 <f_open+0x40>
    12c2:       08 94           sec
    12c4:       c1 1c           adc     r12, r1
    12c6:       d1 1c           adc     r13, r1
        *path = p;                              /* Return pointer to the path name */

        /* Is the file system object registered? */
        if (!fs) return FR_NOT_ENABLED;
    12c8:       a1 14           cp      r10, r1
    12ca:       b1 04           cpc     r11, r1
    12cc:       09 f4           brne    .+2             ; 0x12d0 <f_open+0x48>
    12ce:       15 c1           rjmp    .+554           ; 0x14fa <f_open+0x272>


        fp->fs = NULL;
#if !_FS_READONLY
        mode &= (FA_READ|FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW);
        res = auto_mount(&path, (BYTE)(mode & (FA_WRITE|FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)));
    12d0:       1b 8d           ldd     r17, Y+27       ; 0x1b
    12d2:       1e 71           andi    r17, 0x1E       ; 30

        /* Is the file system object registered? */
        if (!fs) return FR_NOT_ENABLED;

        /* Chekck if the logical drive has been mounted or not */
        if (fs->fs_type) {
    12d4:       f5 01           movw    r30, r10
    12d6:       84 8d           ldd     r24, Z+28       ; 0x1c
    12d8:       88 23           and     r24, r24
    12da:       61 f0           breq    .+24            ; 0x12f4 <f_open+0x6c>
                stat = disk_status(0);
    12dc:       80 e0           ldi     r24, 0x00       ; 0
    12de:       0e 94 bf 0d     call    0x1b7e  ; 0x1b7e <disk_status>
                if (!(stat & STA_NOINIT)) {                             /* If the physical drive is kept initialized */
    12e2:       99 27           eor     r25, r25
    12e4:       80 fd           sbrc    r24, 0
    12e6:       06 c0           rjmp    .+12            ; 0x12f4 <f_open+0x6c>
#if !_FS_READONLY
                        if (chk_wp && (stat & STA_PROTECT))     /* Check write protection if needed */
    12e8:       11 23           and     r17, r17
    12ea:       09 f4           brne    .+2             ; 0x12ee <f_open+0x66>
    12ec:       29 c3           rjmp    .+1618          ; 0x1940 <f_open+0x6b8>
    12ee:       82 fd           sbrc    r24, 2
    12f0:       07 c1           rjmp    .+526           ; 0x1500 <f_open+0x278>
    12f2:       26 c3           rjmp    .+1612          ; 0x1940 <f_open+0x6b8>
                }
        }

        /* The logical drive has not been mounted, following code attempts to mount the logical drive */

        memset(fs, 0, sizeof(FATFS));           /* Clean-up the file system object */
    12f4:       80 e2           ldi     r24, 0x20       ; 32
    12f6:       92 e0           ldi     r25, 0x02       ; 2
    12f8:       d5 01           movw    r26, r10
    12fa:       1d 92           st      X+, r1
    12fc:       01 97           sbiw    r24, 0x01       ; 1
    12fe:       e9 f7           brne    .-6             ; 0x12fa <f_open+0x72>
        stat = disk_initialize(0);                      /* Initialize low level disk I/O layer */
    1300:       80 e0           ldi     r24, 0x00       ; 0
    1302:       0e 94 ae 0f     call    0x1f5c  ; 0x1f5c <disk_initialize>
        if (stat & STA_NOINIT)                          /* Check if the drive is ready */
    1306:       99 27           eor     r25, r25
    1308:       80 ff           sbrs    r24, 0
    130a:       03 c0           rjmp    .+6             ; 0x1312 <f_open+0x8a>
    130c:       21 e0           ldi     r18, 0x01       ; 1
    130e:       30 e0           ldi     r19, 0x00       ; 0
    1310:       45 c3           rjmp    .+1674          ; 0x199c <f_open+0x714>
                return FR_NOT_READY;
#if !_FS_READONLY
        if (chk_wp && (stat & STA_PROTECT))     /* Check write protection if needed */
    1312:       11 23           and     r17, r17
    1314:       11 f0           breq    .+4             ; 0x131a <f_open+0x92>
    1316:       82 fd           sbrc    r24, 2
    1318:       f3 c0           rjmp    .+486           ; 0x1500 <f_open+0x278>
                return FR_WRITE_PROTECTED;
#endif

        /* Search FAT partition on the drive */
        fmt = check_fs(bootsect = 0);           /* Check sector 0 as an SFD format */
    131a:       60 e0           ldi     r22, 0x00       ; 0
    131c:       70 e0           ldi     r23, 0x00       ; 0
    131e:       80 e0           ldi     r24, 0x00       ; 0
    1320:       90 e0           ldi     r25, 0x00       ; 0
    1322:       0e 94 11 09     call    0x1222  ; 0x1222 <check_fs>
        if (fmt == 1) {                                         /* Not a FAT boot record, it may be patitioned */
    1326:       81 30           cpi     r24, 0x01       ; 1
    1328:       21 f0           breq    .+8             ; 0x1332 <f_open+0xaa>
    132a:       ee 24           eor     r14, r14
    132c:       ff 24           eor     r15, r15
    132e:       87 01           movw    r16, r14
    1330:       1e c0           rjmp    .+60            ; 0x136e <f_open+0xe6>
                /* Check a partition listed in top of the partition table */
                if (fs->win[MBR_Table+4]) {                                     /* Is the 1st partition existing? */
    1332:       e2 ee           ldi     r30, 0xE2       ; 226
    1334:       f1 e0           ldi     r31, 0x01       ; 1
    1336:       ae 0e           add     r10, r30
    1338:       bf 1e           adc     r11, r31
    133a:       d5 01           movw    r26, r10
    133c:       8c 91           ld      r24, X
    133e:       ee e1           ldi     r30, 0x1E       ; 30
    1340:       fe ef           ldi     r31, 0xFE       ; 254
    1342:       ae 0e           add     r10, r30
    1344:       bf 1e           adc     r11, r31
    1346:       88 23           and     r24, r24
    1348:       09 f4           brne    .+2             ; 0x134c <f_open+0xc4>
    134a:       dd c0           rjmp    .+442           ; 0x1506 <f_open+0x27e>
                        bootsect = LD_DWORD(&fs->win[MBR_Table+8]);     /* Partition offset in LBA */
    134c:       26 ee           ldi     r18, 0xE6       ; 230
    134e:       31 e0           ldi     r19, 0x01       ; 1
    1350:       a2 0e           add     r10, r18
    1352:       b3 1e           adc     r11, r19
    1354:       d5 01           movw    r26, r10
    1356:       ed 90           ld      r14, X+
    1358:       fd 90           ld      r15, X+
    135a:       0d 91           ld      r16, X+
    135c:       1c 91           ld      r17, X
    135e:       ea e1           ldi     r30, 0x1A       ; 26
    1360:       fe ef           ldi     r31, 0xFE       ; 254
    1362:       ae 0e           add     r10, r30
    1364:       bf 1e           adc     r11, r31
                        fmt = check_fs(bootsect);                               /* Check the partition */
    1366:       c8 01           movw    r24, r16
    1368:       b7 01           movw    r22, r14
    136a:       0e 94 11 09     call    0x1222  ; 0x1222 <check_fs>
                }
        }
        if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512)    /* No valid FAT patition is found */
    136e:       88 23           and     r24, r24
    1370:       09 f0           breq    .+2             ; 0x1374 <f_open+0xec>
    1372:       c9 c0           rjmp    .+402           ; 0x1506 <f_open+0x27e>
    1374:       f5 01           movw    r30, r10
    1376:       83 a5           ldd     r24, Z+43       ; 0x2b
    1378:       94 a5           ldd     r25, Z+44       ; 0x2c
    137a:       80 50           subi    r24, 0x00       ; 0
    137c:       92 40           sbci    r25, 0x02       ; 2
    137e:       09 f0           breq    .+2             ; 0x1382 <f_open+0xfa>
    1380:       c2 c0           rjmp    .+388           ; 0x1506 <f_open+0x27e>
                return FR_NO_FILESYSTEM;

        /* Initialize the file system object */
        fatsize = LD_WORD(&fs->win[BPB_FATSz16]);                       /* Number of sectors per FAT */
    1382:       f5 01           movw    r30, r10
    1384:       66 a9           ldd     r22, Z+54       ; 0x36
    1386:       77 a9           ldd     r23, Z+55       ; 0x37
        if (!fatsize) fatsize = LD_DWORD(&fs->win[BPB_FATSz32]);
    1388:       61 15           cp      r22, r1
    138a:       71 05           cpc     r23, r1
    138c:       19 f0           breq    .+6             ; 0x1394 <f_open+0x10c>
        }
        if (fmt || LD_WORD(&fs->win[BPB_BytsPerSec]) != 512)    /* No valid FAT patition is found */
                return FR_NO_FILESYSTEM;

        /* Initialize the file system object */
        fatsize = LD_WORD(&fs->win[BPB_FATSz16]);                       /* Number of sectors per FAT */
    138e:       88 27           eor     r24, r24
    1390:       99 27           eor     r25, r25
    1392:       0d c0           rjmp    .+26            ; 0x13ae <f_open+0x126>
        if (!fatsize) fatsize = LD_DWORD(&fs->win[BPB_FATSz32]);
    1394:       24 e4           ldi     r18, 0x44       ; 68
    1396:       30 e0           ldi     r19, 0x00       ; 0
    1398:       a2 0e           add     r10, r18
    139a:       b3 1e           adc     r11, r19
    139c:       d5 01           movw    r26, r10
    139e:       6d 91           ld      r22, X+
    13a0:       7d 91           ld      r23, X+
    13a2:       8d 91           ld      r24, X+
    13a4:       9c 91           ld      r25, X
    13a6:       ec eb           ldi     r30, 0xBC       ; 188
    13a8:       ff ef           ldi     r31, 0xFF       ; 255
    13aa:       ae 0e           add     r10, r30
    13ac:       bf 1e           adc     r11, r31
        fs->sects_fat = (CLUST)fatsize;
    13ae:       f5 01           movw    r30, r10
    13b0:       75 8b           std     Z+21, r23       ; 0x15
    13b2:       64 8b           std     Z+20, r22       ; 0x14
        fs->n_fats = fs->win[BPB_NumFATs];                                      /* Number of FAT copies */
    13b4:       20 a9           ldd     r18, Z+48       ; 0x30
    13b6:       26 8f           std     Z+30, r18       ; 0x1e
        fatsize *= fs->n_fats;                                                          /* (Number of sectors in FAT area) */
    13b8:       33 27           eor     r19, r19
    13ba:       44 27           eor     r20, r20
    13bc:       55 27           eor     r21, r21
    13be:       0e 94 e9 10     call    0x21d2  ; 0x21d2 <__mulsi3>
    13c2:       3b 01           movw    r6, r22
    13c4:       4c 01           movw    r8, r24
        fs->fatbase = bootsect + LD_WORD(&fs->win[BPB_RsvdSecCnt]);     /* FAT start sector (lba) */
    13c6:       a5 01           movw    r20, r10
    13c8:       42 5d           subi    r20, 0xD2       ; 210
    13ca:       5f 4f           sbci    r21, 0xFF       ; 255
    13cc:       f5 01           movw    r30, r10
    13ce:       86 a5           ldd     r24, Z+46       ; 0x2e
    13d0:       97 a5           ldd     r25, Z+47       ; 0x2f
    13d2:       aa 27           eor     r26, r26
    13d4:       bb 27           eor     r27, r27
    13d6:       e8 0e           add     r14, r24
    13d8:       f9 1e           adc     r15, r25
    13da:       0a 1f           adc     r16, r26
    13dc:       1b 1f           adc     r17, r27
    13de:       e0 86           std     Z+8, r14        ; 0x08
    13e0:       f1 86           std     Z+9, r15        ; 0x09
    13e2:       02 87           std     Z+10, r16       ; 0x0a
    13e4:       13 87           std     Z+11, r17       ; 0x0b
        fs->sects_clust = fs->win[BPB_SecPerClus];                      /* Number of sectors per cluster */
    13e6:       85 a5           ldd     r24, Z+45       ; 0x2d
    13e8:       85 8f           std     Z+29, r24       ; 0x1d
        fs->n_rootdir = LD_WORD(&fs->win[BPB_RootEntCnt]);      /* Nmuber of root directory entries */
    13ea:       21 a9           ldd     r18, Z+49       ; 0x31
    13ec:       32 a9           ldd     r19, Z+50       ; 0x32
    13ee:       33 83           std     Z+3, r19        ; 0x03
    13f0:       22 83           std     Z+2, r18        ; 0x02
        totalsect = LD_WORD(&fs->win[BPB_TotSec16]);            /* Number of sectors on the file system */
    13f2:       63 a9           ldd     r22, Z+51       ; 0x33
    13f4:       74 a9           ldd     r23, Z+52       ; 0x34
        if (!totalsect) totalsect = LD_DWORD(&fs->win[BPB_TotSec32]);
    13f6:       61 15           cp      r22, r1
    13f8:       71 05           cpc     r23, r1
    13fa:       21 f0           breq    .+8             ; 0x1404 <f_open+0x17c>
        fs->n_fats = fs->win[BPB_NumFATs];                                      /* Number of FAT copies */
        fatsize *= fs->n_fats;                                                          /* (Number of sectors in FAT area) */
        fs->fatbase = bootsect + LD_WORD(&fs->win[BPB_RsvdSecCnt]);     /* FAT start sector (lba) */
        fs->sects_clust = fs->win[BPB_SecPerClus];                      /* Number of sectors per cluster */
        fs->n_rootdir = LD_WORD(&fs->win[BPB_RootEntCnt]);      /* Nmuber of root directory entries */
        totalsect = LD_WORD(&fs->win[BPB_TotSec16]);            /* Number of sectors on the file system */
    13fc:       7b 01           movw    r14, r22
    13fe:       00 27           eor     r16, r16
    1400:       11 27           eor     r17, r17
    1402:       0d c0           rjmp    .+26            ; 0x141e <f_open+0x196>
        if (!totalsect) totalsect = LD_DWORD(&fs->win[BPB_TotSec32]);
    1404:       80 e4           ldi     r24, 0x40       ; 64
    1406:       90 e0           ldi     r25, 0x00       ; 0
    1408:       a8 0e           add     r10, r24
    140a:       b9 1e           adc     r11, r25
    140c:       d5 01           movw    r26, r10
    140e:       ed 90           ld      r14, X+
    1410:       fd 90           ld      r15, X+
    1412:       0d 91           ld      r16, X+
    1414:       1c 91           ld      r17, X
    1416:       e0 ec           ldi     r30, 0xC0       ; 192
    1418:       ff ef           ldi     r31, 0xFF       ; 255
    141a:       ae 0e           add     r10, r30
    141c:       bf 1e           adc     r11, r31
        fs->max_clust = maxclust = (totalsect                           /* Last cluster# + 1 */
    141e:       da 01           movw    r26, r20
    1420:       8d 91           ld      r24, X+
    1422:       9c 91           ld      r25, X
    1424:       aa 27           eor     r26, r26
    1426:       bb 27           eor     r27, r27
    1428:       e8 1a           sub     r14, r24
    142a:       f9 0a           sbc     r15, r25
    142c:       0a 0b           sbc     r16, r26
    142e:       1b 0b           sbc     r17, r27
    1430:       e6 18           sub     r14, r6
    1432:       f7 08           sbc     r15, r7
    1434:       08 09           sbc     r16, r8
    1436:       19 09           sbc     r17, r9
    1438:       e4 e0           ldi     r30, 0x04       ; 4
    143a:       36 95           lsr     r19
    143c:       27 95           ror     r18
    143e:       ea 95           dec     r30
    1440:       e1 f7           brne    .-8             ; 0x143a <f_open+0x1b2>
    1442:       c9 01           movw    r24, r18
    1444:       aa 27           eor     r26, r26
    1446:       bb 27           eor     r27, r27
    1448:       e8 1a           sub     r14, r24
    144a:       f9 0a           sbc     r15, r25
    144c:       0a 0b           sbc     r16, r26
    144e:       1b 0b           sbc     r17, r27
    1450:       f5 01           movw    r30, r10
    1452:       25 8d           ldd     r18, Z+29       ; 0x1d
    1454:       33 27           eor     r19, r19
    1456:       44 27           eor     r20, r20
    1458:       55 27           eor     r21, r21
    145a:       c8 01           movw    r24, r16
    145c:       b7 01           movw    r22, r14
    145e:       0e 94 08 11     call    0x2210  ; 0x2210 <__udivmodsi4>
    1462:       2e 5f           subi    r18, 0xFE       ; 254
    1464:       3f 4f           sbci    r19, 0xFF       ; 255
    1466:       4f 4f           sbci    r20, 0xFF       ; 255
    1468:       5f 4f           sbci    r21, 0xFF       ; 255
    146a:       f5 01           movw    r30, r10
    146c:       37 8b           std     Z+23, r19       ; 0x17
    146e:       26 8b           std     Z+22, r18       ; 0x16
                - LD_WORD(&fs->win[BPB_RsvdSecCnt]) - fatsize - fs->n_rootdir / 16
                ) / fs->sects_clust + 2;

        fmt = FS_FAT12;                                                                         /* Determine the FAT sub type */
        if (maxclust > 0xFF7) fmt = FS_FAT16;
    1470:       28 3f           cpi     r18, 0xF8       ; 248
    1472:       ff e0           ldi     r31, 0x0F       ; 15
    1474:       3f 07           cpc     r19, r31
    1476:       f0 e0           ldi     r31, 0x00       ; 0
    1478:       4f 07           cpc     r20, r31
    147a:       f0 e0           ldi     r31, 0x00       ; 0
    147c:       5f 07           cpc     r21, r31
    147e:       10 f4           brcc    .+4             ; 0x1484 <f_open+0x1fc>
    1480:       61 e0           ldi     r22, 0x01       ; 1
    1482:       06 c0           rjmp    .+12            ; 0x1490 <f_open+0x208>
        if (maxclust > 0xFFF7)
    1484:       28 5f           subi    r18, 0xF8       ; 248
    1486:       3f 4f           sbci    r19, 0xFF       ; 255
    1488:       40 40           sbci    r20, 0x00       ; 0
    148a:       50 40           sbci    r21, 0x00       ; 0
    148c:       e0 f5           brcc    .+120           ; 0x1506 <f_open+0x27e>
    148e:       62 e0           ldi     r22, 0x02       ; 2
                fmt = FS_FAT32;
        if (fmt == FS_FAT32)
                fs->dirbase = LD_DWORD(&fs->win[BPB_RootClus]); /* Root directory start cluster */
        else
#endif
                fs->dirbase = fs->fatbase + fatsize;                    /* Root directory start sector (lba) */
    1490:       f5 01           movw    r30, r10
    1492:       20 85           ldd     r18, Z+8        ; 0x08
    1494:       31 85           ldd     r19, Z+9        ; 0x09
    1496:       42 85           ldd     r20, Z+10       ; 0x0a
    1498:       53 85           ldd     r21, Z+11       ; 0x0b
    149a:       d4 01           movw    r26, r8
    149c:       c3 01           movw    r24, r6
    149e:       82 0f           add     r24, r18
    14a0:       93 1f           adc     r25, r19
    14a2:       a4 1f           adc     r26, r20
    14a4:       b5 1f           adc     r27, r21
    14a6:       84 87           std     Z+12, r24       ; 0x0c
    14a8:       95 87           std     Z+13, r25       ; 0x0d
    14aa:       a6 87           std     Z+14, r26       ; 0x0e
    14ac:       b7 87           std     Z+15, r27       ; 0x0f
        fs->database = fs->fatbase + fatsize + fs->n_rootdir / 16;      /* Data start sector (lba) */
    14ae:       82 81           ldd     r24, Z+2        ; 0x02
    14b0:       93 81           ldd     r25, Z+3        ; 0x03
    14b2:       74 e0           ldi     r23, 0x04       ; 4
    14b4:       96 95           lsr     r25
    14b6:       87 95           ror     r24
    14b8:       7a 95           dec     r23
    14ba:       e1 f7           brne    .-8             ; 0x14b4 <f_open+0x22c>
    14bc:       aa 27           eor     r26, r26
    14be:       bb 27           eor     r27, r27
    14c0:       82 0f           add     r24, r18
    14c2:       93 1f           adc     r25, r19
    14c4:       a4 1f           adc     r26, r20
    14c6:       b5 1f           adc     r27, r21
    14c8:       86 0d           add     r24, r6
    14ca:       97 1d           adc     r25, r7
    14cc:       a8 1d           adc     r26, r8
    14ce:       b9 1d           adc     r27, r9
    14d0:       80 8b           std     Z+16, r24       ; 0x10
    14d2:       91 8b           std     Z+17, r25       ; 0x11
    14d4:       a2 8b           std     Z+18, r26       ; 0x12
    14d6:       b3 8b           std     Z+19, r27       ; 0x13
        fs->fs_type = fmt;                                                                      /* FAT sub-type */
    14d8:       64 8f           std     Z+28, r22       ; 0x1c

#if !_FS_READONLY
        fs->free_clust = (CLUST)0xFFFFFFFF;
    14da:       8f ef           ldi     r24, 0xFF       ; 255
    14dc:       9f ef           ldi     r25, 0xFF       ; 255
    14de:       93 8f           std     Z+27, r25       ; 0x1b
    14e0:       82 8f           std     Z+26, r24       ; 0x1a
                        fs->free_clust = LD_DWORD(&fs->win[FSI_Free_Count]);
                }
        }
#endif
#endif
        fs->id = ++fsid;                                                                        /* File system mount ID */
    14e2:       80 91 0c 01     lds     r24, 0x010C
    14e6:       90 91 0d 01     lds     r25, 0x010D
    14ea:       01 96           adiw    r24, 0x01       ; 1
    14ec:       90 93 0d 01     sts     0x010D, r25
    14f0:       80 93 0c 01     sts     0x010C, r24
    14f4:       91 83           std     Z+1, r25        ; 0x01
    14f6:       80 83           st      Z, r24
    14f8:       23 c2           rjmp    .+1094          ; 0x1940 <f_open+0x6b8>
    14fa:       2a e0           ldi     r18, 0x0A       ; 10
    14fc:       30 e0           ldi     r19, 0x00       ; 0
    14fe:       4e c2           rjmp    .+1180          ; 0x199c <f_open+0x714>
    1500:       29 e0           ldi     r18, 0x09       ; 9
    1502:       30 e0           ldi     r19, 0x00       ; 0
    1504:       4b c2           rjmp    .+1174          ; 0x199c <f_open+0x714>
    1506:       2b e0           ldi     r18, 0x0B       ; 11
    1508:       30 e0           ldi     r19, 0x00       ; 0
    150a:       48 c2           rjmp    .+1168          ; 0x199c <f_open+0x714>
    150c:       36 01           movw    r6, r12
)
{
        BYTE n, t, c, a, b;


        memset(dirname, ' ', 8+3);      /* Fill buffer with spaces */
    150e:       4e 01           movw    r8, r28
    1510:       08 94           sec
    1512:       81 1c           adc     r8, r1
    1514:       91 1c           adc     r9, r1
        for (;;) {
                ds = make_dirfile(&path, fn);                                   /* Get a paragraph into fn[] */
                if (ds == 1) return FR_INVALID_NAME;
                for (;;) {
                        if (!move_window(dirobj->sect)) return FR_RW_ERROR;
                        dptr = &fs->win[(dirobj->index & 15) * 32];             /* Pointer to the directory entry */
    1516:       50 e2           ldi     r21, 0x20       ; 32
    1518:       45 2e           mov     r4, r21
    151a:       51 2c           mov     r5, r1
    151c:       4e 0e           add     r4, r30
    151e:       5f 1e           adc     r5, r31
                        if (dptr[DIR_Name] == 0)                                                /* Has it reached to end of dir? */
                                return !ds ? FR_NO_FILE : FR_NO_PATH;
                        if (dptr[DIR_Name] != 0xE5                                              /* Matched? */
                                && !(dptr[DIR_Attr] & AM_VOL)
                                && !memcmp(&dptr[DIR_Name], fn, 8+3) ) break;
                        if (!next_dir_entry(dirobj))                                    /* Next directory pointer */
    1520:       4d e0           ldi     r20, 0x0D       ; 13
    1522:       24 2e           mov     r2, r20
    1524:       31 2c           mov     r3, r1
    1526:       2c 0e           add     r2, r28
    1528:       3d 1e           adc     r3, r29
)
{
        BYTE n, t, c, a, b;


        memset(dirname, ' ', 8+3);      /* Fill buffer with spaces */
    152a:       4b e0           ldi     r20, 0x0B       ; 11
    152c:       50 e0           ldi     r21, 0x00       ; 0
    152e:       60 e2           ldi     r22, 0x20       ; 32
    1530:       70 e0           ldi     r23, 0x00       ; 0
    1532:       c4 01           movw    r24, r8
    1534:       0e 94 aa 10     call    0x2154  ; 0x2154 <memset>
    1538:       40 e0           ldi     r20, 0x00       ; 0
    153a:       68 e0           ldi     r22, 0x08       ; 8
    153c:       30 e0           ldi     r19, 0x00       ; 0
    153e:       58 e1           ldi     r21, 0x18       ; 24
    1540:       02 c0           rjmp    .+4             ; 0x1546 <f_open+0x2be>
    1542:       48 e0           ldi     r20, 0x08       ; 8
    1544:       6b e0           ldi     r22, 0x0B       ; 11
        a = 0; b = 0x18;        /* NT flag */
        n = 0; t = 8;
        for (;;) {
                c = *(*path)++;
    1546:       d3 01           movw    r26, r6
    1548:       2d 91           ld      r18, X+
    154a:       3d 01           movw    r6, r26
                if (c == '\0' || c == '/') {            /* Reached to end of str or directory separator */
    154c:       22 23           and     r18, r18
    154e:       11 f0           breq    .+4             ; 0x1554 <f_open+0x2cc>
    1550:       2f 32           cpi     r18, 0x2F       ; 47
    1552:       51 f4           brne    .+20            ; 0x1568 <f_open+0x2e0>
                        if (n == 0) break;
    1554:       44 23           and     r20, r20
    1556:       09 f4           brne    .+2             ; 0x155a <f_open+0x2d2>
    1558:       43 c0           rjmp    .+134           ; 0x15e0 <f_open+0x358>
                        dirname[11] = _USE_NTFLAG ? (a & b) : 0;
    155a:       53 23           and     r21, r19
    155c:       5c 87           std     Y+12, r21       ; 0x0c
                        return c;
    155e:       82 2f           mov     r24, r18
    1560:       99 27           eor     r25, r25
    1562:       87 fd           sbrc    r24, 7
    1564:       90 95           com     r25
    1566:       3e c0           rjmp    .+124           ; 0x15e4 <f_open+0x35c>

        memset(dirname, ' ', 8+3);      /* Fill buffer with spaces */
        a = 0; b = 0x18;        /* NT flag */
        n = 0; t = 8;
        for (;;) {
                c = *(*path)++;
    1568:       92 2f           mov     r25, r18
                if (c == '\0' || c == '/') {            /* Reached to end of str or directory separator */
                        if (n == 0) break;
                        dirname[11] = _USE_NTFLAG ? (a & b) : 0;
                        return c;
                }
                if (c <= ' ' || c == 0x7F) break;               /* Reject invisible chars */
    156a:       21 32           cpi     r18, 0x21       ; 33
    156c:       c8 f1           brcs    .+114           ; 0x15e0 <f_open+0x358>
    156e:       2f 37           cpi     r18, 0x7F       ; 127
    1570:       b9 f1           breq    .+110           ; 0x15e0 <f_open+0x358>
                if (c == '.') {
    1572:       2e 32           cpi     r18, 0x2E       ; 46
    1574:       39 f4           brne    .+14            ; 0x1584 <f_open+0x2fc>
                        if (!(a & 1) && n >= 1 && n <= 8) {     /* Enter extension part */
    1576:       30 fd           sbrc    r19, 0
    1578:       33 c0           rjmp    .+102           ; 0x15e0 <f_open+0x358>
    157a:       44 23           and     r20, r20
    157c:       89 f1           breq    .+98            ; 0x15e0 <f_open+0x358>
    157e:       49 30           cpi     r20, 0x09       ; 9
    1580:       00 f3           brcs    .-64            ; 0x1542 <f_open+0x2ba>
    1582:       2e c0           rjmp    .+92            ; 0x15e0 <f_open+0x358>
                    (c >= 0xE0 && c <= 0xFC))) {
                        if (n == 0 && c == 0xE5)                /* Change heading \xE5 to \x05 */
                                c = 0x05;
                        a ^= 1; goto md_l2;
                }
                if (c == '"') break;                            /* Reject " */
    1584:       22 32           cpi     r18, 0x22       ; 34
    1586:       61 f1           breq    .+88            ; 0x15e0 <f_open+0x358>
                if (c <= ')') goto md_l1;                       /* Accept ! # $ % & ' ( ) */
    1588:       2a 32           cpi     r18, 0x2A       ; 42
    158a:       08 f1           brcs    .+66            ; 0x15ce <f_open+0x346>
                if (c <= ',') break;                            /* Reject * + , */
    158c:       2d 32           cpi     r18, 0x2D       ; 45
    158e:       40 f1           brcs    .+80            ; 0x15e0 <f_open+0x358>
                if (c <= '9') goto md_l1;                       /* Accept - 0-9 */
    1590:       2a 33           cpi     r18, 0x3A       ; 58
    1592:       e8 f0           brcs    .+58            ; 0x15ce <f_open+0x346>
                if (c <= '?') break;                            /* Reject : ; < = > ? */
    1594:       20 34           cpi     r18, 0x40       ; 64
    1596:       20 f1           brcs    .+72            ; 0x15e0 <f_open+0x358>
                if (!(a & 1)) { /* These checks are not applied to S-JIS 2nd byte */
    1598:       30 fd           sbrc    r19, 0
    159a:       19 c0           rjmp    .+50            ; 0x15ce <f_open+0x346>
                        if (c == '|') break;                    /* Reject | */
    159c:       2c 37           cpi     r18, 0x7C       ; 124
    159e:       01 f1           breq    .+64            ; 0x15e0 <f_open+0x358>
                        if (c >= '[' && c <= ']') break;/* Reject [ \ ] */
    15a0:       82 2f           mov     r24, r18
    15a2:       8b 55           subi    r24, 0x5B       ; 91
    15a4:       83 30           cpi     r24, 0x03       ; 3
    15a6:       e0 f0           brcs    .+56            ; 0x15e0 <f_open+0x358>
                        if (_USE_NTFLAG && c >= 'A' && c <= 'Z')
    15a8:       86 5e           subi    r24, 0xE6       ; 230
    15aa:       8a 31           cpi     r24, 0x1A       ; 26
    15ac:       28 f4           brcc    .+10            ; 0x15b8 <f_open+0x330>
                                (t == 8) ? (b &= ~0x08) : (b &= ~0x10);
    15ae:       68 30           cpi     r22, 0x08       ; 8
    15b0:       11 f4           brne    .+4             ; 0x15b6 <f_open+0x32e>
    15b2:       57 7f           andi    r21, 0xF7       ; 247
    15b4:       01 c0           rjmp    .+2             ; 0x15b8 <f_open+0x330>
    15b6:       5f 7e           andi    r21, 0xEF       ; 239
                        if (c >= 'a' && c <= 'z') {             /* Convert to upper case */
    15b8:       82 2f           mov     r24, r18
    15ba:       81 56           subi    r24, 0x61       ; 97
    15bc:       8a 31           cpi     r24, 0x1A       ; 26
    15be:       38 f4           brcc    .+14            ; 0x15ce <f_open+0x346>
                                c -= 0x20;
    15c0:       92 2f           mov     r25, r18
    15c2:       90 52           subi    r25, 0x20       ; 32
                                if (_USE_NTFLAG) (t == 8) ? (a |= 0x08) : (a |= 0x10);
    15c4:       68 30           cpi     r22, 0x08       ; 8
    15c6:       11 f4           brne    .+4             ; 0x15cc <f_open+0x344>
    15c8:       38 60           ori     r19, 0x08       ; 8
    15ca:       01 c0           rjmp    .+2             ; 0x15ce <f_open+0x346>
    15cc:       30 61           ori     r19, 0x10       ; 16
                        }
                }
        md_l1:
                a &= ~1;
        md_l2:
                if (n >= t) break;
    15ce:       46 17           cp      r20, r22
    15d0:       38 f4           brcc    .+14            ; 0x15e0 <f_open+0x358>
                                c -= 0x20;
                                if (_USE_NTFLAG) (t == 8) ? (a |= 0x08) : (a |= 0x10);
                        }
                }
        md_l1:
                a &= ~1;
    15d2:       3e 7f           andi    r19, 0xFE       ; 254
        md_l2:
                if (n >= t) break;
                dirname[n++] = c;
    15d4:       f4 01           movw    r30, r8
    15d6:       e4 0f           add     r30, r20
    15d8:       f1 1d           adc     r31, r1
    15da:       90 83           st      Z, r25
    15dc:       4f 5f           subi    r20, 0xFF       ; 255
    15de:       b3 cf           rjmp    .-154           ; 0x1546 <f_open+0x2be>
    15e0:       81 e0           ldi     r24, 0x01       ; 1
    15e2:       90 e0           ldi     r25, 0x00       ; 0
        if (*path == '\0') {                                                    /* Null path means the root directory */
                *dir = NULL; return FR_OK;
        }

        for (;;) {
                ds = make_dirfile(&path, fn);                                   /* Get a paragraph into fn[] */
    15e4:       d8 2e           mov     r13, r24
                if (ds == 1) return FR_INVALID_NAME;
    15e6:       b1 e0           ldi     r27, 0x01       ; 1
    15e8:       8b 17           cp      r24, r27
    15ea:       19 f4           brne    .+6             ; 0x15f2 <f_open+0x36a>
    15ec:       24 e0           ldi     r18, 0x04       ; 4
    15ee:       30 e0           ldi     r19, 0x00       ; 0
    15f0:       55 c0           rjmp    .+170           ; 0x169c <f_open+0x414>
                for (;;) {
                        if (!move_window(dirobj->sect)) return FR_RW_ERROR;
    15f2:       6f 89           ldd     r22, Y+23       ; 0x17
    15f4:       78 8d           ldd     r23, Y+24       ; 0x18
    15f6:       89 8d           ldd     r24, Y+25       ; 0x19
    15f8:       9a 8d           ldd     r25, Y+26       ; 0x1a
    15fa:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
    15fe:       88 23           and     r24, r24
    1600:       19 f4           brne    .+6             ; 0x1608 <f_open+0x380>
    1602:       28 e0           ldi     r18, 0x08       ; 8
    1604:       30 e0           ldi     r19, 0x00       ; 0
    1606:       4a c0           rjmp    .+148           ; 0x169c <f_open+0x414>
                        dptr = &fs->win[(dirobj->index & 15) * 32];             /* Pointer to the directory entry */
    1608:       0f 85           ldd     r16, Y+15       ; 0x0f
    160a:       18 89           ldd     r17, Y+16       ; 0x10
    160c:       0f 70           andi    r16, 0x0F       ; 15
    160e:       10 70           andi    r17, 0x00       ; 0
    1610:       35 e0           ldi     r19, 0x05       ; 5
    1612:       00 0f           add     r16, r16
    1614:       11 1f           adc     r17, r17
    1616:       3a 95           dec     r19
    1618:       e1 f7           brne    .-8             ; 0x1612 <f_open+0x38a>
    161a:       04 0d           add     r16, r4
    161c:       15 1d           adc     r17, r5
                        if (dptr[DIR_Name] == 0)                                                /* Has it reached to end of dir? */
    161e:       f8 01           movw    r30, r16
    1620:       80 81           ld      r24, Z
    1622:       88 23           and     r24, r24
    1624:       a9 f0           breq    .+42            ; 0x1650 <f_open+0x3c8>
                                return !ds ? FR_NO_FILE : FR_NO_PATH;
                        if (dptr[DIR_Name] != 0xE5                                              /* Matched? */
    1626:       85 3e           cpi     r24, 0xE5       ; 229
    1628:       71 f0           breq    .+28            ; 0x1646 <f_open+0x3be>
    162a:       f8 01           movw    r30, r16
    162c:       83 85           ldd     r24, Z+11       ; 0x0b
    162e:       e8 2e           mov     r14, r24
    1630:       ff 24           eor     r15, r15
    1632:       e3 fc           sbrc    r14, 3
    1634:       08 c0           rjmp    .+16            ; 0x1646 <f_open+0x3be>
    1636:       4b e0           ldi     r20, 0x0B       ; 11
    1638:       50 e0           ldi     r21, 0x00       ; 0
    163a:       b4 01           movw    r22, r8
    163c:       c8 01           movw    r24, r16
    163e:       0e 94 94 10     call    0x2128  ; 0x2128 <memcmp>
    1642:       89 2b           or      r24, r25
    1644:       51 f0           breq    .+20            ; 0x165a <f_open+0x3d2>
                                && !(dptr[DIR_Attr] & AM_VOL)
                                && !memcmp(&dptr[DIR_Name], fn, 8+3) ) break;
                        if (!next_dir_entry(dirobj))                                    /* Next directory pointer */
    1646:       c1 01           movw    r24, r2
    1648:       0e 94 cb 04     call    0x996   ; 0x996 <next_dir_entry>
    164c:       88 23           and     r24, r24
    164e:       89 f6           brne    .-94            ; 0x15f2 <f_open+0x36a>
                                return !ds ? FR_NO_FILE : FR_NO_PATH;
    1650:       dd 20           and     r13, r13
    1652:       59 f4           brne    .+22            ; 0x166a <f_open+0x3e2>
    1654:       22 e0           ldi     r18, 0x02       ; 2
    1656:       30 e0           ldi     r19, 0x00       ; 0
    1658:       21 c0           rjmp    .+66            ; 0x169c <f_open+0x414>
                }
                if (!ds) { *dir = dptr; return FR_OK; }                         /* Matched with end of path */
    165a:       dd 20           and     r13, r13
    165c:       21 f4           brne    .+8             ; 0x1666 <f_open+0x3de>
    165e:       68 01           movw    r12, r16
    1660:       20 e0           ldi     r18, 0x00       ; 0
    1662:       30 e0           ldi     r19, 0x00       ; 0
    1664:       1b c0           rjmp    .+54            ; 0x169c <f_open+0x414>
                if (!(dptr[DIR_Attr] & AM_DIR)) return FR_NO_PATH;      /* Cannot trace because it is a file */
    1666:       e4 fc           sbrc    r14, 4
    1668:       03 c0           rjmp    .+6             ; 0x1670 <f_open+0x3e8>
    166a:       23 e0           ldi     r18, 0x03       ; 3
    166c:       30 e0           ldi     r19, 0x00       ; 0
    166e:       16 c0           rjmp    .+44            ; 0x169c <f_open+0x414>
                clust =                                                                                         /* Get cluster# of the directory */
    1670:       f8 01           movw    r30, r16
    1672:       82 8d           ldd     r24, Z+26       ; 0x1a
    1674:       93 8d           ldd     r25, Z+27       ; 0x1b
#if _FAT32
                        ((DWORD)LD_WORD(&dptr[DIR_FstClusHI]) << 16) |
#endif
                        LD_WORD(&dptr[DIR_FstClusLO]);
                dirobj->clust = dirobj->sclust = clust;                         /* Restart scannig with the new directory */
    1676:       9c 8b           std     Y+20, r25       ; 0x14
    1678:       8b 8b           std     Y+19, r24       ; 0x13
    167a:       9e 8b           std     Y+22, r25       ; 0x16
    167c:       8d 8b           std     Y+21, r24       ; 0x15
                dirobj->sect = clust2sect(clust);
    167e:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
    1682:       6f 8b           std     Y+23, r22       ; 0x17
    1684:       78 8f           std     Y+24, r23       ; 0x18
    1686:       89 8f           std     Y+25, r24       ; 0x19
    1688:       9a 8f           std     Y+26, r25       ; 0x1a
                dirobj->index = 2;
    168a:       82 e0           ldi     r24, 0x02       ; 2
    168c:       90 e0           ldi     r25, 0x00       ; 0
    168e:       98 8b           std     Y+16, r25       ; 0x10
    1690:       8f 87           std     Y+15, r24       ; 0x0f
    1692:       4b cf           rjmp    .-362           ; 0x152a <f_open+0x2a2>
    1694:       20 e0           ldi     r18, 0x00       ; 0
    1696:       30 e0           ldi     r19, 0x00       ; 0
    1698:       cc 24           eor     r12, r12
    169a:       dd 24           eor     r13, r13
        /* Trace the file path */
        res = trace_path(&dirobj, fn, path, &dir);      /* Trace the file path */

#if !_FS_READONLY
        /* Create or Open a File */
        if (mode & (FA_CREATE_ALWAYS|FA_OPEN_ALWAYS|FA_CREATE_NEW)) {
    169c:       fb 8d           ldd     r31, Y+27       ; 0x1b
    169e:       4f 2f           mov     r20, r31
    16a0:       55 27           eor     r21, r21
    16a2:       ca 01           movw    r24, r20
    16a4:       8c 71           andi    r24, 0x1C       ; 28
    16a6:       90 70           andi    r25, 0x00       ; 0
    16a8:       89 2b           or      r24, r25
    16aa:       09 f4           brne    .+2             ; 0x16ae <f_open+0x426>
    16ac:       fe c0           rjmp    .+508           ; 0x18aa <f_open+0x622>
                CLUST rs;
                DWORD dw;
                if (res != FR_OK) {             /* No file, create new */
    16ae:       21 15           cp      r18, r1
    16b0:       31 05           cpc     r19, r1
    16b2:       09 f4           brne    .+2             ; 0x16b6 <f_open+0x42e>
    16b4:       8f c0           rjmp    .+286           ; 0x17d4 <f_open+0x54c>
                        if (res != FR_NO_FILE) return res;
    16b6:       22 30           cpi     r18, 0x02       ; 2
    16b8:       31 05           cpc     r19, r1
    16ba:       09 f0           breq    .+2             ; 0x16be <f_open+0x436>
    16bc:       6f c1           rjmp    .+734           ; 0x199c <f_open+0x714>
)
{
        CLUST clust;
        DWORD sector;
        BYTE c, n, *dptr;
        FATFS *fs = FatFs;
    16be:       60 90 0a 01     lds     r6, 0x010A
    16c2:       70 90 0b 01     lds     r7, 0x010B


        /* Re-initialize directory object */
        clust = dirobj->sclust;
    16c6:       0b 89           ldd     r16, Y+19       ; 0x13
    16c8:       1c 89           ldd     r17, Y+20       ; 0x14
        if (clust) {    /* Dyanmic directory table */
    16ca:       01 15           cp      r16, r1
    16cc:       11 05           cpc     r17, r1
    16ce:       51 f0           breq    .+20            ; 0x16e4 <f_open+0x45c>
                dirobj->clust = clust;
    16d0:       1e 8b           std     Y+22, r17       ; 0x16
    16d2:       0d 8b           std     Y+21, r16       ; 0x15
                dirobj->sect = clust2sect(clust);
    16d4:       c8 01           movw    r24, r16
    16d6:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
    16da:       6f 8b           std     Y+23, r22       ; 0x17
    16dc:       78 8f           std     Y+24, r23       ; 0x18
    16de:       89 8f           std     Y+25, r24       ; 0x19
    16e0:       9a 8f           std     Y+26, r25       ; 0x1a
    16e2:       09 c0           rjmp    .+18            ; 0x16f6 <f_open+0x46e>
        } else {                /* Static directory table */
                dirobj->sect = fs->dirbase;
    16e4:       f3 01           movw    r30, r6
    16e6:       84 85           ldd     r24, Z+12       ; 0x0c
    16e8:       95 85           ldd     r25, Z+13       ; 0x0d
    16ea:       a6 85           ldd     r26, Z+14       ; 0x0e
    16ec:       b7 85           ldd     r27, Z+15       ; 0x0f
    16ee:       8f 8b           std     Y+23, r24       ; 0x17
    16f0:       98 8f           std     Y+24, r25       ; 0x18
    16f2:       a9 8f           std     Y+25, r26       ; 0x19
    16f4:       ba 8f           std     Y+26, r27       ; 0x1a
        }
        dirobj->index = 0;
    16f6:       18 8a           std     Y+16, r1        ; 0x10
    16f8:       1f 86           std     Y+15, r1        ; 0x0f

        do {
                if (!move_window(dirobj->sect)) return FR_RW_ERROR;
                dptr = &fs->win[(dirobj->index & 15) * 32];     /* Pointer to the directory entry */
    16fa:       20 e2           ldi     r18, 0x20       ; 32
    16fc:       e2 2e           mov     r14, r18
    16fe:       f1 2c           mov     r15, r1
    1700:       e6 0c           add     r14, r6
    1702:       f7 1c           adc     r15, r7
                c = dptr[DIR_Name];
                if (c == 0 || c == 0xE5) {                      /* Found an empty entry! */
                        *dir = dptr; return FR_OK;
                }
        } while (next_dir_entry(dirobj));                               /* Next directory pointer */
    1704:       9d e0           ldi     r25, 0x0D       ; 13
    1706:       49 2e           mov     r4, r25
    1708:       51 2c           mov     r5, r1
    170a:       4c 0e           add     r4, r28
    170c:       5d 1e           adc     r5, r29
                dirobj->sect = fs->dirbase;
        }
        dirobj->index = 0;

        do {
                if (!move_window(dirobj->sect)) return FR_RW_ERROR;
    170e:       6f 89           ldd     r22, Y+23       ; 0x17
    1710:       78 8d           ldd     r23, Y+24       ; 0x18
    1712:       89 8d           ldd     r24, Y+25       ; 0x19
    1714:       9a 8d           ldd     r25, Y+26       ; 0x1a
    1716:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
    171a:       88 23           and     r24, r24
    171c:       09 f4           brne    .+2             ; 0x1720 <f_open+0x498>
    171e:       0a c1           rjmp    .+532           ; 0x1934 <f_open+0x6ac>
                dptr = &fs->win[(dirobj->index & 15) * 32];     /* Pointer to the directory entry */
    1720:       47 01           movw    r8, r14
    1722:       cf 84           ldd     r12, Y+15       ; 0x0f
    1724:       d8 88           ldd     r13, Y+16       ; 0x10
    1726:       ff e0           ldi     r31, 0x0F       ; 15
    1728:       cf 22           and     r12, r31
    172a:       dd 24           eor     r13, r13
    172c:       85 e0           ldi     r24, 0x05       ; 5
    172e:       cc 0c           add     r12, r12
    1730:       dd 1c           adc     r13, r13
    1732:       8a 95           dec     r24
    1734:       e1 f7           brne    .-8             ; 0x172e <f_open+0x4a6>
    1736:       ce 0c           add     r12, r14
    1738:       df 1c           adc     r13, r15
                c = dptr[DIR_Name];
    173a:       d6 01           movw    r26, r12
    173c:       8c 91           ld      r24, X
                if (c == 0 || c == 0xE5) {                      /* Found an empty entry! */
    173e:       88 23           and     r24, r24
    1740:       09 f4           brne    .+2             ; 0x1744 <f_open+0x4bc>
    1742:       18 c1           rjmp    .+560           ; 0x1974 <f_open+0x6ec>
    1744:       85 3e           cpi     r24, 0xE5       ; 229
    1746:       09 f4           brne    .+2             ; 0x174a <f_open+0x4c2>
    1748:       15 c1           rjmp    .+554           ; 0x1974 <f_open+0x6ec>
                        *dir = dptr; return FR_OK;
                }
        } while (next_dir_entry(dirobj));                               /* Next directory pointer */
    174a:       c2 01           movw    r24, r4
    174c:       0e 94 cb 04     call    0x996   ; 0x996 <next_dir_entry>
    1750:       88 23           and     r24, r24
    1752:       e9 f6           brne    .-70            ; 0x170e <f_open+0x486>
        /* Reached to end of the directory table */

        /* Abort when static table or could not stretch dynamic table */
        if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
    1754:       01 2b           or      r16, r17
    1756:       09 f4           brne    .+2             ; 0x175a <f_open+0x4d2>
    1758:       ea c0           rjmp    .+468           ; 0x192e <f_open+0x6a6>
    175a:       8d 89           ldd     r24, Y+21       ; 0x15
    175c:       9e 89           ldd     r25, Y+22       ; 0x16
    175e:       0e 94 25 05     call    0xa4a   ; 0xa4a <create_chain>
    1762:       8c 01           movw    r16, r24
    1764:       00 97           sbiw    r24, 0x00       ; 0
    1766:       09 f4           brne    .+2             ; 0x176a <f_open+0x4e2>
    1768:       e2 c0           rjmp    .+452           ; 0x192e <f_open+0x6a6>
        if (clust == 1 || !move_window(0)) return FR_RW_ERROR;
    176a:       01 97           sbiw    r24, 0x01       ; 1
    176c:       09 f4           brne    .+2             ; 0x1770 <f_open+0x4e8>
    176e:       e2 c0           rjmp    .+452           ; 0x1934 <f_open+0x6ac>
    1770:       60 e0           ldi     r22, 0x00       ; 0
    1772:       70 e0           ldi     r23, 0x00       ; 0
    1774:       80 e0           ldi     r24, 0x00       ; 0
    1776:       90 e0           ldi     r25, 0x00       ; 0
    1778:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
    177c:       88 23           and     r24, r24
    177e:       09 f4           brne    .+2             ; 0x1782 <f_open+0x4fa>
    1780:       d9 c0           rjmp    .+434           ; 0x1934 <f_open+0x6ac>

        fs->winsect = sector = clust2sect(clust);                       /* Cleanup the expanded table */
    1782:       c8 01           movw    r24, r16
    1784:       0e 94 18 03     call    0x630   ; 0x630 <clust2sect>
    1788:       6b 01           movw    r12, r22
    178a:       7c 01           movw    r14, r24
    178c:       f3 01           movw    r30, r6
    178e:       64 83           std     Z+4, r22        ; 0x04
    1790:       75 83           std     Z+5, r23        ; 0x05
    1792:       86 83           std     Z+6, r24        ; 0x06
    1794:       97 83           std     Z+7, r25        ; 0x07
        memset(fs->win, 0, 512);
    1796:       80 e0           ldi     r24, 0x00       ; 0
    1798:       92 e0           ldi     r25, 0x02       ; 2
    179a:       d4 01           movw    r26, r8
    179c:       1d 92           st      X+, r1
    179e:       01 97           sbiw    r24, 0x01       ; 1
    17a0:       e9 f7           brne    .-6             ; 0x179c <f_open+0x514>
        for (n = fs->sects_clust; n; n--) {
    17a2:       15 8d           ldd     r17, Z+29       ; 0x1d
    17a4:       10 c0           rjmp    .+32            ; 0x17c6 <f_open+0x53e>
                if (disk_write(0, fs->win, sector, 1) != RES_OK)
    17a6:       01 e0           ldi     r16, 0x01       ; 1
    17a8:       a7 01           movw    r20, r14
    17aa:       96 01           movw    r18, r12
    17ac:       b4 01           movw    r22, r8
    17ae:       80 e0           ldi     r24, 0x00       ; 0
    17b0:       0e 94 d3 0e     call    0x1da6  ; 0x1da6 <disk_write>
    17b4:       89 2b           or      r24, r25
    17b6:       09 f0           breq    .+2             ; 0x17ba <f_open+0x532>
    17b8:       bd c0           rjmp    .+378           ; 0x1934 <f_open+0x6ac>
                        return FR_RW_ERROR;
                sector++;
    17ba:       08 94           sec
    17bc:       c1 1c           adc     r12, r1
    17be:       d1 1c           adc     r13, r1
    17c0:       e1 1c           adc     r14, r1
    17c2:       f1 1c           adc     r15, r1
        if (!clust || !(clust = create_chain(dirobj->clust))) return FR_DENIED;
        if (clust == 1 || !move_window(0)) return FR_RW_ERROR;

        fs->winsect = sector = clust2sect(clust);                       /* Cleanup the expanded table */
        memset(fs->win, 0, 512);
        for (n = fs->sects_clust; n; n--) {
    17c4:       11 50           subi    r17, 0x01       ; 1
    17c6:       11 23           and     r17, r17
    17c8:       71 f7           brne    .-36            ; 0x17a6 <f_open+0x51e>
                if (disk_write(0, fs->win, sector, 1) != RES_OK)
                        return FR_RW_ERROR;
                sector++;
        }
        fs->winflag = 1;
    17ca:       81 e0           ldi     r24, 0x01       ; 1
    17cc:       f3 01           movw    r30, r6
    17ce:       87 8f           std     Z+31, r24       ; 0x1f
    17d0:       64 01           movw    r12, r8
    17d2:       d0 c0           rjmp    .+416           ; 0x1974 <f_open+0x6ec>
                        memset(dir, 0, 32);             /* Initialize the new entry */
                        memcpy(&dir[DIR_Name], fn, 8+3);
                        dir[DIR_NTres] = fn[11];
                        mode |= FA_CREATE_ALWAYS;
                } else {                                /* Any object is already existing */
                        if (mode & FA_CREATE_NEW)                       /* Cannot create new */
    17d4:       42 ff           sbrs    r20, 2
    17d6:       03 c0           rjmp    .+6             ; 0x17de <f_open+0x556>
    17d8:       27 e0           ldi     r18, 0x07       ; 7
    17da:       30 e0           ldi     r19, 0x00       ; 0
    17dc:       df c0           rjmp    .+446           ; 0x199c <f_open+0x714>
                                return FR_EXIST;
                        if (dir == NULL || (dir[DIR_Attr] & (AM_RDO|AM_DIR)))   /* Cannot overwrite (R/O or DIR) */
    17de:       c1 14           cp      r12, r1
    17e0:       d1 04           cpc     r13, r1
    17e2:       09 f4           brne    .+2             ; 0x17e6 <f_open+0x55e>
    17e4:       a4 c0           rjmp    .+328           ; 0x192e <f_open+0x6a6>
    17e6:       f6 01           movw    r30, r12
    17e8:       83 85           ldd     r24, Z+11       ; 0x0b
    17ea:       81 71           andi    r24, 0x11       ; 17
    17ec:       09 f0           breq    .+2             ; 0x17f0 <f_open+0x568>
    17ee:       9f c0           rjmp    .+318           ; 0x192e <f_open+0x6a6>
                                return FR_DENIED;
                        if (mode & FA_CREATE_ALWAYS) {          /* Resize it to zero */
    17f0:       43 ff           sbrs    r20, 3
    17f2:       46 c0           rjmp    .+140           ; 0x1880 <f_open+0x5f8>
#if _FAT32
                                rs = ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) | LD_WORD(&dir[DIR_FstClusLO]);
                                ST_WORD(&dir[DIR_FstClusHI], 0);
#else
                                rs = LD_WORD(&dir[DIR_FstClusLO]);
    17f4:       82 8c           ldd     r8, Z+26        ; 0x1a
    17f6:       93 8c           ldd     r9, Z+27        ; 0x1b
#endif
                                ST_WORD(&dir[DIR_FstClusLO], 0);        /* cluster = 0 */
    17f8:       13 8e           std     Z+27, r1        ; 0x1b
    17fa:       12 8e           std     Z+26, r1        ; 0x1a
                                ST_DWORD(&dir[DIR_FileSize], 0);        /* size = 0 */
    17fc:       14 8e           std     Z+28, r1        ; 0x1c
    17fe:       15 8e           std     Z+29, r1        ; 0x1d
    1800:       16 8e           std     Z+30, r1        ; 0x1e
    1802:       17 8e           std     Z+31, r1        ; 0x1f
                                fs->winflag = 1;
    1804:       81 e0           ldi     r24, 0x01       ; 1
    1806:       f5 01           movw    r30, r10
    1808:       87 8f           std     Z+31, r24       ; 0x1f
                                dw = fs->winsect;                               /* Remove the cluster chain */
    180a:       24 80           ldd     r2, Z+4 ; 0x04
    180c:       35 80           ldd     r3, Z+5 ; 0x05
    180e:       46 80           ldd     r4, Z+6 ; 0x06
    1810:       57 80           ldd     r5, Z+7 ; 0x07
BOOL remove_chain (             /* TRUE: successful, FALSE: failed */
        CLUST clust                     /* Cluster# to remove chain from */
)
{
        CLUST nxt;
        FATFS *fs = FatFs;
    1812:       e0 90 0a 01     lds     r14, 0x010A
    1816:       f0 90 0b 01     lds     r15, 0x010B
    181a:       84 01           movw    r16, r8
    181c:       1b c0           rjmp    .+54            ; 0x1854 <f_open+0x5cc>


        while (clust >= 2 && clust < fs->max_clust) {
                nxt = get_cluster(clust);
    181e:       c8 01           movw    r24, r16
    1820:       0e 94 4f 04     call    0x89e   ; 0x89e <get_cluster>
    1824:       3c 01           movw    r6, r24
                if (nxt == 1) return FALSE;
    1826:       01 97           sbiw    r24, 0x01       ; 1
    1828:       09 f4           brne    .+2             ; 0x182c <f_open+0x5a4>
    182a:       84 c0           rjmp    .+264           ; 0x1934 <f_open+0x6ac>
                if (!put_cluster(clust, 0)) return FALSE;
    182c:       60 e0           ldi     r22, 0x00       ; 0
    182e:       70 e0           ldi     r23, 0x00       ; 0
    1830:       c8 01           movw    r24, r16
    1832:       0e 94 c1 03     call    0x782   ; 0x782 <put_cluster>
    1836:       88 23           and     r24, r24
    1838:       09 f4           brne    .+2             ; 0x183c <f_open+0x5b4>
    183a:       7c c0           rjmp    .+248           ; 0x1934 <f_open+0x6ac>
                if (fs->free_clust != (CLUST)0xFFFFFFFF) {
    183c:       f7 01           movw    r30, r14
    183e:       82 8d           ldd     r24, Z+26       ; 0x1a
    1840:       93 8d           ldd     r25, Z+27       ; 0x1b
    1842:       ff ef           ldi     r31, 0xFF       ; 255
    1844:       8f 3f           cpi     r24, 0xFF       ; 255
    1846:       9f 07           cpc     r25, r31
    1848:       21 f0           breq    .+8             ; 0x1852 <f_open+0x5ca>
                        fs->free_clust++;
    184a:       01 96           adiw    r24, 0x01       ; 1
    184c:       f7 01           movw    r30, r14
    184e:       93 8f           std     Z+27, r25       ; 0x1b
    1850:       82 8f           std     Z+26, r24       ; 0x1a
    1852:       83 01           movw    r16, r6
{
        CLUST nxt;
        FATFS *fs = FatFs;


        while (clust >= 2 && clust < fs->max_clust) {
    1854:       02 30           cpi     r16, 0x02       ; 2
    1856:       11 05           cpc     r17, r1
    1858:       30 f0           brcs    .+12            ; 0x1866 <f_open+0x5de>
    185a:       f7 01           movw    r30, r14
    185c:       86 89           ldd     r24, Z+22       ; 0x16
    185e:       97 89           ldd     r25, Z+23       ; 0x17
    1860:       08 17           cp      r16, r24
    1862:       19 07           cpc     r17, r25
    1864:       e0 f2           brcs    .-72            ; 0x181e <f_open+0x596>
#endif
                                ST_WORD(&dir[DIR_FstClusLO], 0);        /* cluster = 0 */
                                ST_DWORD(&dir[DIR_FileSize], 0);        /* size = 0 */
                                fs->winflag = 1;
                                dw = fs->winsect;                               /* Remove the cluster chain */
                                if (!remove_chain(rs) || !move_window(dw))
    1866:       c2 01           movw    r24, r4
    1868:       b1 01           movw    r22, r2
    186a:       0e 94 55 03     call    0x6aa   ; 0x6aa <move_window>
    186e:       88 23           and     r24, r24
    1870:       09 f4           brne    .+2             ; 0x1874 <f_open+0x5ec>
    1872:       60 c0           rjmp    .+192           ; 0x1934 <f_open+0x6ac>
                                        return FR_RW_ERROR;
                                fs->last_clust = rs - 1;                /* Reuse the cluster hole */
    1874:       08 94           sec
    1876:       81 08           sbc     r8, r1
    1878:       91 08           sbc     r9, r1
    187a:       f5 01           movw    r30, r10
    187c:       91 8e           std     Z+25, r9        ; 0x19
    187e:       80 8e           std     Z+24, r8        ; 0x18
                        }
                }
                if (mode & FA_CREATE_ALWAYS) {
    1880:       fb 8d           ldd     r31, Y+27       ; 0x1b
    1882:       f3 ff           sbrs    r31, 3
    1884:       23 c0           rjmp    .+70            ; 0x18cc <f_open+0x644>
                        dir[DIR_Attr] = AM_ARC;         /* New attribute */
    1886:       80 e2           ldi     r24, 0x20       ; 32
    1888:       f6 01           movw    r30, r12
    188a:       83 87           std     Z+11, r24       ; 0x0b
                        dw = get_fattime();
    188c:       0e 94 bb 00     call    0x176   ; 0x176 <get_fattime>
                        ST_DWORD(&dir[DIR_WrtTime], dw);        /* Updated time */
    1890:       f6 01           movw    r30, r12
    1892:       66 8b           std     Z+22, r22       ; 0x16
    1894:       77 8b           std     Z+23, r23       ; 0x17
    1896:       80 8f           std     Z+24, r24       ; 0x18
    1898:       91 8f           std     Z+25, r25       ; 0x19
                        ST_DWORD(&dir[DIR_CrtTime], dw);        /* Created time */
    189a:       66 87           std     Z+14, r22       ; 0x0e
    189c:       77 87           std     Z+15, r23       ; 0x0f
    189e:       80 8b           std     Z+16, r24       ; 0x10
    18a0:       91 8b           std     Z+17, r25       ; 0x11
                        fs->winflag = 1;
    18a2:       81 e0           ldi     r24, 0x01       ; 1
    18a4:       f5 01           movw    r30, r10
    18a6:       87 8f           std     Z+31, r24       ; 0x1f
    18a8:       11 c0           rjmp    .+34            ; 0x18cc <f_open+0x644>
                }
        }
        /* Open a File */
        else {
#endif /* !_FS_READONLY */
                if (res != FR_OK) return res;           /* Trace failed */
    18aa:       21 15           cp      r18, r1
    18ac:       31 05           cpc     r19, r1
    18ae:       09 f0           breq    .+2             ; 0x18b2 <f_open+0x62a>
    18b0:       75 c0           rjmp    .+234           ; 0x199c <f_open+0x714>
                if (dir == NULL || (dir[DIR_Attr] & AM_DIR))    /* It is a directory */
    18b2:       c1 14           cp      r12, r1
    18b4:       d1 04           cpc     r13, r1
    18b6:       09 f4           brne    .+2             ; 0x18ba <f_open+0x632>
    18b8:       40 c0           rjmp    .+128           ; 0x193a <f_open+0x6b2>
    18ba:       f6 01           movw    r30, r12
    18bc:       83 85           ldd     r24, Z+11       ; 0x0b
    18be:       99 27           eor     r25, r25
    18c0:       84 fd           sbrc    r24, 4
    18c2:       3b c0           rjmp    .+118           ; 0x193a <f_open+0x6b2>
                        return FR_NO_FILE;
#if !_FS_READONLY
                if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */
    18c4:       41 ff           sbrs    r20, 1
    18c6:       02 c0           rjmp    .+4             ; 0x18cc <f_open+0x644>
    18c8:       80 fd           sbrc    r24, 0
    18ca:       31 c0           rjmp    .+98            ; 0x192e <f_open+0x6a6>
                        return FR_DENIED;
        }

        fp->dir_sect = fs->winsect;                     /* Pointer to the directory entry */
    18cc:       f5 01           movw    r30, r10
    18ce:       84 81           ldd     r24, Z+4        ; 0x04
    18d0:       95 81           ldd     r25, Z+5        ; 0x05
    18d2:       a6 81           ldd     r26, Z+6        ; 0x06
    18d4:       b7 81           ldd     r27, Z+7        ; 0x07
    18d6:       ec 8d           ldd     r30, Y+28       ; 0x1c
    18d8:       fd 8d           ldd     r31, Y+29       ; 0x1d
    18da:       86 8b           std     Z+22, r24       ; 0x16
    18dc:       97 8b           std     Z+23, r25       ; 0x17
    18de:       a0 8f           std     Z+24, r26       ; 0x18
    18e0:       b1 8f           std     Z+25, r27       ; 0x19
        fp->dir_ptr = dir;
    18e2:       d3 8e           std     Z+27, r13       ; 0x1b
    18e4:       c2 8e           std     Z+26, r12       ; 0x1a
#endif
        fp->flag = mode;                                                        /* File access mode */
    18e6:       2b 8d           ldd     r18, Y+27       ; 0x1b
    18e8:       22 83           std     Z+2, r18        ; 0x02
        fp->org_clust =                                                         /* File start cluster */
    18ea:       f6 01           movw    r30, r12
    18ec:       82 8d           ldd     r24, Z+26       ; 0x1a
    18ee:       93 8d           ldd     r25, Z+27       ; 0x1b
    18f0:       ec 8d           ldd     r30, Y+28       ; 0x1c
    18f2:       fd 8d           ldd     r31, Y+29       ; 0x1d
    18f4:       97 87           std     Z+15, r25       ; 0x0f
    18f6:       86 87           std     Z+14, r24       ; 0x0e
#if _FAT32
                ((DWORD)LD_WORD(&dir[DIR_FstClusHI]) << 16) |
#endif
                LD_WORD(&dir[DIR_FstClusLO]);
        fp->fsize = LD_DWORD(&dir[DIR_FileSize]);       /* File size */
    18f8:       f6 01           movw    r30, r12
    18fa:       84 8d           ldd     r24, Z+28       ; 0x1c
    18fc:       95 8d           ldd     r25, Z+29       ; 0x1d
    18fe:       a6 8d           ldd     r26, Z+30       ; 0x1e
    1900:       b7 8d           ldd     r27, Z+31       ; 0x1f
    1902:       ec 8d           ldd     r30, Y+28       ; 0x1c
    1904:       fd 8d           ldd     r31, Y+29       ; 0x1d
    1906:       82 87           std     Z+10, r24       ; 0x0a
    1908:       93 87           std     Z+11, r25       ; 0x0b
    190a:       a4 87           std     Z+12, r26       ; 0x0c
    190c:       b5 87           std     Z+13, r27       ; 0x0d
        fp->fptr = 0;                                                           /* File ptr */
    190e:       16 82           std     Z+6, r1 ; 0x06
    1910:       17 82           std     Z+7, r1 ; 0x07
    1912:       10 86           std     Z+8, r1 ; 0x08
    1914:       11 86           std     Z+9, r1 ; 0x09
        fp->sect_clust = 1;                                                     /* Sector counter */
    1916:       81 e0           ldi     r24, 0x01       ; 1
    1918:       83 83           std     Z+3, r24        ; 0x03
        fp->fs = fs; fp->id = fs->id;                           /* Owner file system object of the file */
    191a:       b5 82           std     Z+5, r11        ; 0x05
    191c:       a4 82           std     Z+4, r10        ; 0x04
    191e:       d5 01           movw    r26, r10
    1920:       8d 91           ld      r24, X+
    1922:       9c 91           ld      r25, X
    1924:       91 83           std     Z+1, r25        ; 0x01
    1926:       80 83           st      Z, r24
    1928:       20 e0           ldi     r18, 0x00       ; 0
    192a:       30 e0           ldi     r19, 0x00       ; 0
    192c:       37 c0           rjmp    .+110           ; 0x199c <f_open+0x714>

        return FR_OK;
    192e:       26 e0           ldi     r18, 0x06       ; 6
    1930:       30 e0           ldi     r19, 0x00       ; 0
    1932:       34 c0           rjmp    .+104           ; 0x199c <f_open+0x714>
    1934:       28 e0           ldi     r18, 0x08       ; 8
    1936:       30 e0           ldi     r19, 0x00       ; 0
    1938:       31 c0           rjmp    .+98            ; 0x199c <f_open+0x714>
    193a:       22 e0           ldi     r18, 0x02       ; 2
    193c:       30 e0           ldi     r19, 0x00       ; 0
    193e:       2e c0           rjmp    .+92            ; 0x199c <f_open+0x714>
)
{
        CLUST clust;
        char ds;
        BYTE *dptr = NULL;
        FATFS *fs = FatFs;
    1940:       e0 91 0a 01     lds     r30, 0x010A
    1944:       f0 91 0b 01     lds     r31, 0x010B

        /* Initialize directory object */
        clust = fs->dirbase;
    1948:       84 85           ldd     r24, Z+12       ; 0x0c
    194a:       95 85           ldd     r25, Z+13       ; 0x0d
                dirobj->clust = dirobj->sclust = clust;
                dirobj->sect = clust2sect(clust);
        } else
#endif
        {
                dirobj->clust = dirobj->sclust = 0;
    194c:       1c 8a           std     Y+20, r1        ; 0x14
    194e:       1b 8a           std     Y+19, r1        ; 0x13
    1950:       1e 8a           std     Y+22, r1        ; 0x16
    1952:       1d 8a           std     Y+21, r1        ; 0x15
                dirobj->sect = clust;
    1954:       aa 27           eor     r26, r26
    1956:       bb 27           eor     r27, r27
    1958:       8f 8b           std     Y+23, r24       ; 0x17
    195a:       98 8f           std     Y+24, r25       ; 0x18
    195c:       a9 8f           std     Y+25, r26       ; 0x19
    195e:       ba 8f           std     Y+26, r27       ; 0x1a
        }
        dirobj->index = 0;
    1960:       18 8a           std     Y+16, r1        ; 0x10
    1962:       1f 86           std     Y+15, r1        ; 0x0f
        dirobj->fs = fs;
    1964:       fa 8b           std     Y+18, r31       ; 0x12
    1966:       e9 8b           std     Y+17, r30       ; 0x11

        if (*path == '\0') {                                                    /* Null path means the root directory */
    1968:       d6 01           movw    r26, r12
    196a:       8c 91           ld      r24, X
    196c:       88 23           and     r24, r24
    196e:       09 f4           brne    .+2             ; 0x1972 <f_open+0x6ea>
    1970:       91 ce           rjmp    .-734           ; 0x1694 <f_open+0x40c>
    1972:       cc cd           rjmp    .-1128          ; 0x150c <f_open+0x284>
                DWORD dw;
                if (res != FR_OK) {             /* No file, create new */
                        if (res != FR_NO_FILE) return res;
                        res = reserve_direntry(&dirobj, &dir);
                        if (res != FR_OK) return res;
                        memset(dir, 0, 32);             /* Initialize the new entry */
    1974:       80 e2           ldi     r24, 0x20       ; 32
    1976:       f6 01           movw    r30, r12
    1978:       11 92           st      Z+, r1
    197a:       8a 95           dec     r24
    197c:       e9 f7           brne    .-6             ; 0x1978 <f_open+0x6f0>
                        memcpy(&dir[DIR_Name], fn, 8+3);
    197e:       f6 01           movw    r30, r12
    1980:       de 01           movw    r26, r28
    1982:       11 96           adiw    r26, 0x01       ; 1
    1984:       8b e0           ldi     r24, 0x0B       ; 11
    1986:       0d 90           ld      r0, X+
    1988:       01 92           st      Z+, r0
    198a:       81 50           subi    r24, 0x01       ; 1
    198c:       e1 f7           brne    .-8             ; 0x1986 <f_open+0x6fe>
                        dir[DIR_NTres] = fn[11];
    198e:       8c 85           ldd     r24, Y+12       ; 0x0c
    1990:       f6 01           movw    r30, r12
    1992:       84 87           std     Z+12, r24       ; 0x0c
                        mode |= FA_CREATE_ALWAYS;
    1994:       fb 8d           ldd     r31, Y+27       ; 0x1b
    1996:       f8 60           ori     r31, 0x08       ; 8
    1998:       fb 8f           std     Y+27, r31       ; 0x1b
    199a:       72 cf           rjmp    .-284           ; 0x1880 <f_open+0x5f8>
        fp->fptr = 0;                                                           /* File ptr */
        fp->sect_clust = 1;                                                     /* Sector counter */
        fp->fs = fs; fp->id = fs->id;                           /* Owner file system object of the file */

        return FR_OK;
}
    199c:       c9 01           movw    r24, r18
    199e:       e2 e1           ldi     r30, 0x12       ; 18
    19a0:       6d 96           adiw    r28, 0x1d       ; 29
    19a2:       0c 94 46 11     jmp     0x228c  ; 0x228c <__epilogue_restores__>

000019a6 <wait_ready>:
/* Wait for card ready                                                   */
/*-----------------------------------------------------------------------*/

static
BYTE wait_ready (void)
{
    19a6:       82 e3           ldi     r24, 0x32       ; 50
    19a8:       80 93 10 01     sts     0x0110, r24
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    19ac:       8f ef           ldi     r24, 0xFF       ; 255
    19ae:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    19b0:       0d b4           in      r0, 0x2d        ; 45
    19b2:       07 fe           sbrs    r0, 7
    19b4:       fd cf           rjmp    .-6             ; 0x19b0 <wait_ready+0xa>
        return SPDR;
    19b6:       8e b5           in      r24, 0x2e       ; 46
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    19b8:       8f ef           ldi     r24, 0xFF       ; 255
    19ba:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    19bc:       0d b4           in      r0, 0x2d        ; 45
    19be:       07 fe           sbrs    r0, 7
    19c0:       fd cf           rjmp    .-6             ; 0x19bc <wait_ready+0x16>
        return SPDR;
    19c2:       8e b5           in      r24, 0x2e       ; 46
    19c4:       28 2f           mov     r18, r24
    19c6:       33 27           eor     r19, r19

        Timer2 = 50;    /* Wait for ready in timeout of 500ms */
        rcvr_spi();
        do
                res = rcvr_spi();
        while ((res != 0xFF) && Timer2);
    19c8:       8f 3f           cpi     r24, 0xFF       ; 255
    19ca:       21 f0           breq    .+8             ; 0x19d4 <wait_ready+0x2e>
    19cc:       80 91 10 01     lds     r24, 0x0110
    19d0:       88 23           and     r24, r24
    19d2:       91 f7           brne    .-28            ; 0x19b8 <wait_ready+0x12>

        return res;
}
    19d4:       c9 01           movw    r24, r18
    19d6:       08 95           ret

000019d8 <rcvr_datablock>:
static
BOOL rcvr_datablock (
        BYTE *buff,                     /* Data buffer to store received data */
        UINT btr                        /* Byte count (must be even number) */
)
{
    19d8:       fc 01           movw    r30, r24
        BYTE token;


        Timer1 = 10;
    19da:       8a e0           ldi     r24, 0x0A       ; 10
    19dc:       80 93 0f 01     sts     0x010F, r24
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    19e0:       8f ef           ldi     r24, 0xFF       ; 255
    19e2:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    19e4:       0d b4           in      r0, 0x2d        ; 45
    19e6:       07 fe           sbrs    r0, 7
    19e8:       fd cf           rjmp    .-6             ; 0x19e4 <rcvr_datablock+0xc>
        return SPDR;
    19ea:       8e b5           in      r24, 0x2e       ; 46


        Timer1 = 10;
        do {                                                    /* Wait for data packet in timeout of 100ms */
                token = rcvr_spi();
        } while ((token == 0xFF) && Timer1);
    19ec:       8f 3f           cpi     r24, 0xFF       ; 255
    19ee:       29 f4           brne    .+10            ; 0x19fa <rcvr_datablock+0x22>
    19f0:       80 91 0f 01     lds     r24, 0x010F
    19f4:       88 23           and     r24, r24
    19f6:       29 f1           breq    .+74            ; 0x1a42 <rcvr_datablock+0x6a>
    19f8:       f3 cf           rjmp    .-26            ; 0x19e0 <rcvr_datablock+0x8>
        if(token != 0xFE) return FALSE; /* If not valid data token, retutn with error */
    19fa:       8e 3f           cpi     r24, 0xFE       ; 254
    19fc:       11 f5           brne    .+68            ; 0x1a42 <rcvr_datablock+0x6a>

        do {                                                    /* Receive the data block into buffer */
                rcvr_spi_m(buff++);
    19fe:       8f ef           ldi     r24, 0xFF       ; 255
    1a00:       8e bd           out     0x2e, r24       ; 46
    1a02:       0d b4           in      r0, 0x2d        ; 45
    1a04:       07 fe           sbrs    r0, 7
    1a06:       fd cf           rjmp    .-6             ; 0x1a02 <rcvr_datablock+0x2a>
    1a08:       8e b5           in      r24, 0x2e       ; 46
    1a0a:       80 83           st      Z, r24
                rcvr_spi_m(buff++);
    1a0c:       8f ef           ldi     r24, 0xFF       ; 255
    1a0e:       8e bd           out     0x2e, r24       ; 46
    1a10:       0d b4           in      r0, 0x2d        ; 45
    1a12:       07 fe           sbrs    r0, 7
    1a14:       fd cf           rjmp    .-6             ; 0x1a10 <rcvr_datablock+0x38>
    1a16:       8e b5           in      r24, 0x2e       ; 46
    1a18:       81 83           std     Z+1, r24        ; 0x01
        } while (btr -= 2);
    1a1a:       62 50           subi    r22, 0x02       ; 2
    1a1c:       70 40           sbci    r23, 0x00       ; 0
    1a1e:       11 f0           breq    .+4             ; 0x1a24 <rcvr_datablock+0x4c>
    1a20:       32 96           adiw    r30, 0x02       ; 2
    1a22:       ed cf           rjmp    .-38            ; 0x19fe <rcvr_datablock+0x26>
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1a24:       8f ef           ldi     r24, 0xFF       ; 255
    1a26:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1a28:       0d b4           in      r0, 0x2d        ; 45
    1a2a:       07 fe           sbrs    r0, 7
    1a2c:       fd cf           rjmp    .-6             ; 0x1a28 <rcvr_datablock+0x50>
        return SPDR;
    1a2e:       8e b5           in      r24, 0x2e       ; 46
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1a30:       8f ef           ldi     r24, 0xFF       ; 255
    1a32:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1a34:       0d b4           in      r0, 0x2d        ; 45
    1a36:       07 fe           sbrs    r0, 7
    1a38:       fd cf           rjmp    .-6             ; 0x1a34 <rcvr_datablock+0x5c>
        return SPDR;
    1a3a:       8e b5           in      r24, 0x2e       ; 46
    1a3c:       81 e0           ldi     r24, 0x01       ; 1
    1a3e:       90 e0           ldi     r25, 0x00       ; 0
    1a40:       08 95           ret
                rcvr_spi_m(buff++);
        } while (btr -= 2);
        rcvr_spi();                                             /* Discard CRC */
        rcvr_spi();

        return TRUE;                                    /* Return with success */
    1a42:       80 e0           ldi     r24, 0x00       ; 0
    1a44:       90 e0           ldi     r25, 0x00       ; 0
}
    1a46:       08 95           ret

00001a48 <xmit_datablock>:
static
BOOL xmit_datablock (
        const BYTE *buff,       /* 512 byte data block to be transmitted */
        BYTE token                      /* Data/Stop token */
)
{
    1a48:       1f 93           push    r17
    1a4a:       cf 93           push    r28
    1a4c:       df 93           push    r29
    1a4e:       ec 01           movw    r28, r24
    1a50:       16 2f           mov     r17, r22
        BYTE resp, wc;


        if (wait_ready() != 0xFF) return FALSE;
    1a52:       0e 94 d3 0c     call    0x19a6  ; 0x19a6 <wait_ready>
    1a56:       8f 3f           cpi     r24, 0xFF       ; 255
    1a58:       19 f0           breq    .+6             ; 0x1a60 <xmit_datablock+0x18>
    1a5a:       80 e0           ldi     r24, 0x00       ; 0
    1a5c:       90 e0           ldi     r25, 0x00       ; 0
    1a5e:       31 c0           rjmp    .+98            ; 0x1ac2 <xmit_datablock+0x7a>

        xmit_spi(token);                                        /* Xmit data token */
    1a60:       1e bd           out     0x2e, r17       ; 46
    1a62:       0d b4           in      r0, 0x2d        ; 45
    1a64:       07 fe           sbrs    r0, 7
    1a66:       fd cf           rjmp    .-6             ; 0x1a62 <xmit_datablock+0x1a>
        if (token != 0xFD) {    /* Is data token */
    1a68:       1d 3f           cpi     r17, 0xFD       ; 253
    1a6a:       19 f4           brne    .+6             ; 0x1a72 <xmit_datablock+0x2a>
    1a6c:       81 e0           ldi     r24, 0x01       ; 1
    1a6e:       90 e0           ldi     r25, 0x00       ; 0
    1a70:       28 c0           rjmp    .+80            ; 0x1ac2 <xmit_datablock+0x7a>
    1a72:       90 e0           ldi     r25, 0x00       ; 0
                wc = 0;
                do {                                                    /* Xmit the 512 byte data block to MMC */
                        xmit_spi(*buff++);
    1a74:       88 81           ld      r24, Y
    1a76:       8e bd           out     0x2e, r24       ; 46
    1a78:       0d b4           in      r0, 0x2d        ; 45
    1a7a:       07 fe           sbrs    r0, 7
    1a7c:       fd cf           rjmp    .-6             ; 0x1a78 <xmit_datablock+0x30>
                        xmit_spi(*buff++);
    1a7e:       89 81           ldd     r24, Y+1        ; 0x01
    1a80:       8e bd           out     0x2e, r24       ; 46
    1a82:       0d b4           in      r0, 0x2d        ; 45
    1a84:       07 fe           sbrs    r0, 7
    1a86:       fd cf           rjmp    .-6             ; 0x1a82 <xmit_datablock+0x3a>
                } while (--wc);
    1a88:       91 50           subi    r25, 0x01       ; 1
    1a8a:       11 f0           breq    .+4             ; 0x1a90 <xmit_datablock+0x48>
    1a8c:       22 96           adiw    r28, 0x02       ; 2
    1a8e:       f2 cf           rjmp    .-28            ; 0x1a74 <xmit_datablock+0x2c>
                xmit_spi(0xFF);                                 /* CRC (Dummy) */
    1a90:       8f ef           ldi     r24, 0xFF       ; 255
    1a92:       8e bd           out     0x2e, r24       ; 46
    1a94:       0d b4           in      r0, 0x2d        ; 45
    1a96:       07 fe           sbrs    r0, 7
    1a98:       fd cf           rjmp    .-6             ; 0x1a94 <xmit_datablock+0x4c>
                xmit_spi(0xFF);
    1a9a:       8f ef           ldi     r24, 0xFF       ; 255
    1a9c:       8e bd           out     0x2e, r24       ; 46
    1a9e:       0d b4           in      r0, 0x2d        ; 45
    1aa0:       07 fe           sbrs    r0, 7
    1aa2:       fd cf           rjmp    .-6             ; 0x1a9e <xmit_datablock+0x56>
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1aa4:       8f ef           ldi     r24, 0xFF       ; 255
    1aa6:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1aa8:       0d b4           in      r0, 0x2d        ; 45
    1aaa:       07 fe           sbrs    r0, 7
    1aac:       fd cf           rjmp    .-6             ; 0x1aa8 <xmit_datablock+0x60>
        return SPDR;
    1aae:       8e b5           in      r24, 0x2e       ; 46
    1ab0:       90 e0           ldi     r25, 0x00       ; 0
    1ab2:       8f 71           andi    r24, 0x1F       ; 31
    1ab4:       85 30           cpi     r24, 0x05       ; 5
    1ab6:       09 f0           breq    .+2             ; 0x1aba <xmit_datablock+0x72>
    1ab8:       91 e0           ldi     r25, 0x01       ; 1
    1aba:       81 e0           ldi     r24, 0x01       ; 1
    1abc:       98 27           eor     r25, r24
    1abe:       89 2f           mov     r24, r25
    1ac0:       99 27           eor     r25, r25
    1ac2:       df 91           pop     r29
    1ac4:       cf 91           pop     r28
    1ac6:       1f 91           pop     r17
    1ac8:       08 95           ret

00001aca <send_cmd>:
static
BYTE send_cmd (
        BYTE cmd,               /* Command byte */
        DWORD arg               /* Argument */
)
{
    1aca:       df 92           push    r13
    1acc:       ef 92           push    r14
    1ace:       ff 92           push    r15
    1ad0:       0f 93           push    r16
    1ad2:       1f 93           push    r17
    1ad4:       d8 2e           mov     r13, r24
    1ad6:       7a 01           movw    r14, r20
    1ad8:       8b 01           movw    r16, r22
        BYTE n, res;


        if (wait_ready() != 0xFF) return 0xFF;
    1ada:       0e 94 d3 0c     call    0x19a6  ; 0x19a6 <wait_ready>
    1ade:       8f 3f           cpi     r24, 0xFF       ; 255
    1ae0:       19 f0           breq    .+6             ; 0x1ae8 <send_cmd+0x1e>
    1ae2:       2f ef           ldi     r18, 0xFF       ; 255
    1ae4:       30 e0           ldi     r19, 0x00       ; 0
    1ae6:       44 c0           rjmp    .+136           ; 0x1b70 <send_cmd+0xa6>

        /* Send command packet */
        xmit_spi(cmd);                                          /* Command */
    1ae8:       de bc           out     0x2e, r13       ; 46
    1aea:       0d b4           in      r0, 0x2d        ; 45
    1aec:       07 fe           sbrs    r0, 7
    1aee:       fd cf           rjmp    .-6             ; 0x1aea <send_cmd+0x20>
        xmit_spi((BYTE)(arg >> 24));            /* Argument[31..24] */
    1af0:       81 2f           mov     r24, r17
    1af2:       99 27           eor     r25, r25
    1af4:       aa 27           eor     r26, r26
    1af6:       bb 27           eor     r27, r27
    1af8:       8e bd           out     0x2e, r24       ; 46
    1afa:       0d b4           in      r0, 0x2d        ; 45
    1afc:       07 fe           sbrs    r0, 7
    1afe:       fd cf           rjmp    .-6             ; 0x1afa <send_cmd+0x30>
        xmit_spi((BYTE)(arg >> 16));            /* Argument[23..16] */
    1b00:       c8 01           movw    r24, r16
    1b02:       aa 27           eor     r26, r26
    1b04:       bb 27           eor     r27, r27
    1b06:       8e bd           out     0x2e, r24       ; 46
    1b08:       0d b4           in      r0, 0x2d        ; 45
    1b0a:       07 fe           sbrs    r0, 7
    1b0c:       fd cf           rjmp    .-6             ; 0x1b08 <send_cmd+0x3e>
        xmit_spi((BYTE)(arg >> 8));                     /* Argument[15..8] */
    1b0e:       bb 27           eor     r27, r27
    1b10:       a1 2f           mov     r26, r17
    1b12:       90 2f           mov     r25, r16
    1b14:       8f 2d           mov     r24, r15
    1b16:       8e bd           out     0x2e, r24       ; 46
    1b18:       0d b4           in      r0, 0x2d        ; 45
    1b1a:       07 fe           sbrs    r0, 7
    1b1c:       fd cf           rjmp    .-6             ; 0x1b18 <send_cmd+0x4e>
        xmit_spi((BYTE)arg);                            /* Argument[7..0] */
    1b1e:       ee bc           out     0x2e, r14       ; 46
    1b20:       0d b4           in      r0, 0x2d        ; 45
    1b22:       07 fe           sbrs    r0, 7
    1b24:       fd cf           rjmp    .-6             ; 0x1b20 <send_cmd+0x56>
        n = 0;
        if (cmd == CMD0) n = 0x95;                      /* CRC for CMD0(0) */
    1b26:       80 e4           ldi     r24, 0x40       ; 64
    1b28:       d8 16           cp      r13, r24
    1b2a:       11 f4           brne    .+4             ; 0x1b30 <send_cmd+0x66>
    1b2c:       85 e9           ldi     r24, 0x95       ; 149
    1b2e:       06 c0           rjmp    .+12            ; 0x1b3c <send_cmd+0x72>
        if (cmd == CMD8) n = 0x87;                      /* CRC for CMD8(0x1AA) */
    1b30:       88 e4           ldi     r24, 0x48       ; 72
    1b32:       d8 16           cp      r13, r24
    1b34:       11 f4           brne    .+4             ; 0x1b3a <send_cmd+0x70>
    1b36:       87 e8           ldi     r24, 0x87       ; 135
    1b38:       01 c0           rjmp    .+2             ; 0x1b3c <send_cmd+0x72>
    1b3a:       80 e0           ldi     r24, 0x00       ; 0
        xmit_spi(n);
    1b3c:       8e bd           out     0x2e, r24       ; 46
    1b3e:       0d b4           in      r0, 0x2d        ; 45
    1b40:       07 fe           sbrs    r0, 7
    1b42:       fd cf           rjmp    .-6             ; 0x1b3e <send_cmd+0x74>

        /* Receive command response */
        if (cmd == CMD12) rcvr_spi();           /* Skip a stuff byte when stop reading */
    1b44:       8c e4           ldi     r24, 0x4C       ; 76
    1b46:       d8 16           cp      r13, r24
    1b48:       31 f4           brne    .+12            ; 0x1b56 <send_cmd+0x8c>
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1b4a:       8f ef           ldi     r24, 0xFF       ; 255
    1b4c:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1b4e:       0d b4           in      r0, 0x2d        ; 45
    1b50:       07 fe           sbrs    r0, 7
    1b52:       fd cf           rjmp    .-6             ; 0x1b4e <send_cmd+0x84>
        return SPDR;
    1b54:       8e b5           in      r24, 0x2e       ; 46
    1b56:       9a e0           ldi     r25, 0x0A       ; 10
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1b58:       8f ef           ldi     r24, 0xFF       ; 255
    1b5a:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1b5c:       0d b4           in      r0, 0x2d        ; 45
    1b5e:       07 fe           sbrs    r0, 7
    1b60:       fd cf           rjmp    .-6             ; 0x1b5c <send_cmd+0x92>
        return SPDR;
    1b62:       8e b5           in      r24, 0x2e       ; 46
    1b64:       28 2f           mov     r18, r24
    1b66:       33 27           eor     r19, r19
        /* Receive command response */
        if (cmd == CMD12) rcvr_spi();           /* Skip a stuff byte when stop reading */
        n = 10;                                                         /* Wait for a valid response in timeout of 10 attempts */
        do
                res = rcvr_spi();
        while ((res & 0x80) && --n);
    1b68:       87 ff           sbrs    r24, 7
    1b6a:       02 c0           rjmp    .+4             ; 0x1b70 <send_cmd+0xa6>
    1b6c:       91 50           subi    r25, 0x01       ; 1
    1b6e:       a1 f7           brne    .-24            ; 0x1b58 <send_cmd+0x8e>

        return res;                     /* Return with the response value */
}
    1b70:       c9 01           movw    r24, r18
    1b72:       1f 91           pop     r17
    1b74:       0f 91           pop     r16
    1b76:       ff 90           pop     r15
    1b78:       ef 90           pop     r14
    1b7a:       df 90           pop     r13
    1b7c:       08 95           ret

00001b7e <disk_status>:
/*-----------------------------------------------------------------------*/

DSTATUS disk_status (
        BYTE drv                /* Physical drive nmuber (0) */
)
{
    1b7e:       88 23           and     r24, r24
    1b80:       19 f0           breq    .+6             ; 0x1b88 <disk_status+0xa>
        if (drv) return STA_NOINIT;             /* Supports only single drive */
    1b82:       81 e0           ldi     r24, 0x01       ; 1
    1b84:       90 e0           ldi     r25, 0x00       ; 0
    1b86:       08 95           ret
        return Stat;
    1b88:       80 91 04 01     lds     r24, 0x0104
    1b8c:       99 27           eor     r25, r25
}
    1b8e:       08 95           ret

00001b90 <disk_timerproc>:
/* Device timer interrupt procedure      */
/* This must be called in period of 10ms */
/* (Platform dependent)                  */

void disk_timerproc (void)
{
    1b90:       80 91 0f 01     lds     r24, 0x010F
        static BYTE pv;
        BYTE n, s;


        n = Timer1;                                             /* 100Hz decrement timer */
        if (n) Timer1 = --n;
    1b94:       88 23           and     r24, r24
    1b96:       19 f0           breq    .+6             ; 0x1b9e <disk_timerproc+0xe>
    1b98:       81 50           subi    r24, 0x01       ; 1
    1b9a:       80 93 0f 01     sts     0x010F, r24
        n = Timer2;
    1b9e:       80 91 10 01     lds     r24, 0x0110
        if (n) Timer2 = --n;
    1ba2:       88 23           and     r24, r24
    1ba4:       19 f0           breq    .+6             ; 0x1bac <disk_timerproc+0x1c>
    1ba6:       81 50           subi    r24, 0x01       ; 1
    1ba8:       80 93 10 01     sts     0x0110, r24

        n = pv;
    1bac:       90 91 0e 01     lds     r25, 0x010E
        pv = SOCKPORT & (SOCKINS);              /* Sample socket switch */
    1bb0:       83 b1           in      r24, 0x03       ; 3
    1bb2:       81 70           andi    r24, 0x01       ; 1
    1bb4:       80 93 0e 01     sts     0x010E, r24

        if (n == pv) {                                  /* Have contacts stabled? */
    1bb8:       98 17           cp      r25, r24
    1bba:       49 f4           brne    .+18            ; 0x1bce <disk_timerproc+0x3e>
                s = Stat;
    1bbc:       80 91 04 01     lds     r24, 0x0104
                if (pv & SOCKINS)                       /* INS = H (Socket empty) */
    1bc0:       90 ff           sbrs    r25, 0
    1bc2:       02 c0           rjmp    .+4             ; 0x1bc8 <disk_timerproc+0x38>
                        s |= (STA_NODISK | STA_NOINIT);
    1bc4:       83 60           ori     r24, 0x03       ; 3
    1bc6:       01 c0           rjmp    .+2             ; 0x1bca <disk_timerproc+0x3a>
                else                                            /* INS = L (Card inserted) */
                        s &= ~STA_NODISK;
    1bc8:       8d 7f           andi    r24, 0xFD       ; 253

                Stat = s;
    1bca:       80 93 04 01     sts     0x0104, r24
    1bce:       08 95           ret

00001bd0 <disk_ioctl>:
DRESULT disk_ioctl (
        BYTE drv,               /* Physical drive nmuber (0) */
        BYTE ctrl,              /* Control code */
        void *buff              /* Buffer to send/receive data block */
)
{
    1bd0:       a0 e1           ldi     r26, 0x10       ; 16
    1bd2:       b0 e0           ldi     r27, 0x00       ; 0
    1bd4:       ee ee           ldi     r30, 0xEE       ; 238
    1bd6:       fd e0           ldi     r31, 0x0D       ; 13
    1bd8:       0c 94 38 11     jmp     0x2270  ; 0x2270 <__prologue_saves__+0x1c>
    1bdc:       fa 01           movw    r30, r20
        DRESULT res;
        BYTE n, csd[16], *ptr = buff;
        WORD csize;


        if (drv) return RES_PARERR;
    1bde:       88 23           and     r24, r24
    1be0:       19 f0           breq    .+6             ; 0x1be8 <disk_ioctl+0x18>
    1be2:       24 e0           ldi     r18, 0x04       ; 4
    1be4:       30 e0           ldi     r19, 0x00       ; 0
    1be6:       da c0           rjmp    .+436           ; 0x1d9c <disk_ioctl+0x1cc>
        BYTE ctrl,              /* Control code */
        void *buff              /* Buffer to send/receive data block */
)
{
        DRESULT res;
        BYTE n, csd[16], *ptr = buff;
    1be8:       8a 01           movw    r16, r20
        WORD csize;


        if (drv) return RES_PARERR;

        SELECT();               /* CS = L */
    1bea:       2a 98           cbi     0x05, 2 ; 5

        res = RES_ERROR;
        switch (ctrl) {
    1bec:       63 30           cpi     r22, 0x03       ; 3
    1bee:       09 f4           brne    .+2             ; 0x1bf2 <disk_ioctl+0x22>
    1bf0:       82 c0           rjmp    .+260           ; 0x1cf6 <disk_ioctl+0x126>
    1bf2:       64 30           cpi     r22, 0x04       ; 4
    1bf4:       28 f4           brcc    .+10            ; 0x1c00 <disk_ioctl+0x30>
    1bf6:       61 30           cpi     r22, 0x01       ; 1
    1bf8:       79 f0           breq    .+30            ; 0x1c18 <disk_ioctl+0x48>
    1bfa:       62 30           cpi     r22, 0x02       ; 2
    1bfc:       51 f4           brne    .+20            ; 0x1c12 <disk_ioctl+0x42>
    1bfe:       74 c0           rjmp    .+232           ; 0x1ce8 <disk_ioctl+0x118>
    1c00:       6b 30           cpi     r22, 0x0B       ; 11
    1c02:       09 f4           brne    .+2             ; 0x1c06 <disk_ioctl+0x36>
    1c04:       88 c0           rjmp    .+272           ; 0x1d16 <disk_ioctl+0x146>
    1c06:       6c 30           cpi     r22, 0x0C       ; 12
    1c08:       09 f4           brne    .+2             ; 0x1c0c <disk_ioctl+0x3c>
    1c0a:       9f c0           rjmp    .+318           ; 0x1d4a <disk_ioctl+0x17a>
    1c0c:       6a 30           cpi     r22, 0x0A       ; 10
    1c0e:       09 f4           brne    .+2             ; 0x1c12 <disk_ioctl+0x42>
    1c10:       78 c0           rjmp    .+240           ; 0x1d02 <disk_ioctl+0x132>
    1c12:       24 e0           ldi     r18, 0x04       ; 4
    1c14:       30 e0           ldi     r19, 0x00       ; 0
    1c16:       b8 c0           rjmp    .+368           ; 0x1d88 <disk_ioctl+0x1b8>
                case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
                        if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
    1c18:       40 e0           ldi     r20, 0x00       ; 0
    1c1a:       50 e0           ldi     r21, 0x00       ; 0
    1c1c:       60 e0           ldi     r22, 0x00       ; 0
    1c1e:       70 e0           ldi     r23, 0x00       ; 0
    1c20:       89 e4           ldi     r24, 0x49       ; 73
    1c22:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1c26:       88 23           and     r24, r24
    1c28:       09 f0           breq    .+2             ; 0x1c2c <disk_ioctl+0x5c>
    1c2a:       ac c0           rjmp    .+344           ; 0x1d84 <disk_ioctl+0x1b4>
    1c2c:       60 e1           ldi     r22, 0x10       ; 16
    1c2e:       70 e0           ldi     r23, 0x00       ; 0
    1c30:       ce 01           movw    r24, r28
    1c32:       01 96           adiw    r24, 0x01       ; 1
    1c34:       0e 94 ec 0c     call    0x19d8  ; 0x19d8 <rcvr_datablock>
    1c38:       88 23           and     r24, r24
    1c3a:       09 f4           brne    .+2             ; 0x1c3e <disk_ioctl+0x6e>
    1c3c:       a3 c0           rjmp    .+326           ; 0x1d84 <disk_ioctl+0x1b4>
                                if ((csd[0] >> 6) == 1) {       /* SDC ver 2.00 */
    1c3e:       89 81           ldd     r24, Y+1        ; 0x01
    1c40:       82 95           swap    r24
    1c42:       86 95           lsr     r24
    1c44:       86 95           lsr     r24
    1c46:       83 70           andi    r24, 0x03       ; 3
    1c48:       7a 85           ldd     r23, Y+10       ; 0x0a
    1c4a:       49 85           ldd     r20, Y+9        ; 0x09
    1c4c:       81 30           cpi     r24, 0x01       ; 1
    1c4e:       c1 f4           brne    .+48            ; 0x1c80 <disk_ioctl+0xb0>
                                        csize = csd[9] + ((WORD)csd[8] << 8) + 1;
                                        *(DWORD*)buff = (DWORD)csize << 10;
    1c50:       87 2f           mov     r24, r23
    1c52:       99 27           eor     r25, r25
    1c54:       01 96           adiw    r24, 0x01       ; 1
    1c56:       24 2f           mov     r18, r20
    1c58:       33 27           eor     r19, r19
    1c5a:       32 2f           mov     r19, r18
    1c5c:       22 27           eor     r18, r18
    1c5e:       82 0f           add     r24, r18
    1c60:       93 1f           adc     r25, r19
    1c62:       aa 27           eor     r26, r26
    1c64:       bb 27           eor     r27, r27
    1c66:       6a e0           ldi     r22, 0x0A       ; 10
    1c68:       88 0f           add     r24, r24
    1c6a:       99 1f           adc     r25, r25
    1c6c:       aa 1f           adc     r26, r26
    1c6e:       bb 1f           adc     r27, r27
    1c70:       6a 95           dec     r22
    1c72:       d1 f7           brne    .-12            ; 0x1c68 <disk_ioctl+0x98>
    1c74:       f8 01           movw    r30, r16
    1c76:       80 83           st      Z, r24
    1c78:       91 83           std     Z+1, r25        ; 0x01
    1c7a:       a2 83           std     Z+2, r26        ; 0x02
    1c7c:       b3 83           std     Z+3, r27        ; 0x03
    1c7e:       38 c0           rjmp    .+112           ; 0x1cf0 <disk_ioctl+0x120>
                                } else {                                        /* MMC or SDC ver 1.XX */
                                        n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
                                        csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
                                        *(DWORD*)buff = (DWORD)csize << (n - 9);
    1c80:       42 95           swap    r20
    1c82:       46 95           lsr     r20
    1c84:       46 95           lsr     r20
    1c86:       43 70           andi    r20, 0x03       ; 3
    1c88:       28 85           ldd     r18, Y+8        ; 0x08
    1c8a:       33 27           eor     r19, r19
    1c8c:       22 0f           add     r18, r18
    1c8e:       33 1f           adc     r19, r19
    1c90:       22 0f           add     r18, r18
    1c92:       33 1f           adc     r19, r19
    1c94:       24 0f           add     r18, r20
    1c96:       31 1d           adc     r19, r1
    1c98:       2f 5f           subi    r18, 0xFF       ; 255
    1c9a:       3f 4f           sbci    r19, 0xFF       ; 255
    1c9c:       8f 81           ldd     r24, Y+7        ; 0x07
    1c9e:       99 27           eor     r25, r25
    1ca0:       83 70           andi    r24, 0x03       ; 3
    1ca2:       90 70           andi    r25, 0x00       ; 0
    1ca4:       98 2f           mov     r25, r24
    1ca6:       88 27           eor     r24, r24
    1ca8:       99 0f           add     r25, r25
    1caa:       99 0f           add     r25, r25
    1cac:       28 0f           add     r18, r24
    1cae:       39 1f           adc     r19, r25
    1cb0:       44 27           eor     r20, r20
    1cb2:       55 27           eor     r21, r21
    1cb4:       6e 81           ldd     r22, Y+6        ; 0x06
    1cb6:       6f 70           andi    r22, 0x0F       ; 15
    1cb8:       6e 5f           subi    r22, 0xFE       ; 254
    1cba:       73 70           andi    r23, 0x03       ; 3
    1cbc:       77 0f           add     r23, r23
    1cbe:       67 0f           add     r22, r23
    1cc0:       8b 85           ldd     r24, Y+11       ; 0x0b
    1cc2:       88 1f           adc     r24, r24
    1cc4:       88 27           eor     r24, r24
    1cc6:       88 1f           adc     r24, r24
    1cc8:       86 0f           add     r24, r22
    1cca:       99 27           eor     r25, r25
    1ccc:       09 97           sbiw    r24, 0x09       ; 9
    1cce:       04 c0           rjmp    .+8             ; 0x1cd8 <disk_ioctl+0x108>
    1cd0:       22 0f           add     r18, r18
    1cd2:       33 1f           adc     r19, r19
    1cd4:       44 1f           adc     r20, r20
    1cd6:       55 1f           adc     r21, r21
    1cd8:       8a 95           dec     r24
    1cda:       d2 f7           brpl    .-12            ; 0x1cd0 <disk_ioctl+0x100>
    1cdc:       f8 01           movw    r30, r16
    1cde:       20 83           st      Z, r18
    1ce0:       31 83           std     Z+1, r19        ; 0x01
    1ce2:       42 83           std     Z+2, r20        ; 0x02
    1ce4:       53 83           std     Z+3, r21        ; 0x03
    1ce6:       04 c0           rjmp    .+8             ; 0x1cf0 <disk_ioctl+0x120>
                                res = RES_OK;
                        }
                        break;

                case GET_SECTOR_SIZE :  /* Get sectors on the disk (WORD) */
                        *(WORD*)buff = 512;
    1ce8:       80 e0           ldi     r24, 0x00       ; 0
    1cea:       92 e0           ldi     r25, 0x02       ; 2
    1cec:       91 83           std     Z+1, r25        ; 0x01
    1cee:       80 83           st      Z, r24
    1cf0:       20 e0           ldi     r18, 0x00       ; 0
    1cf2:       30 e0           ldi     r19, 0x00       ; 0
    1cf4:       49 c0           rjmp    .+146           ; 0x1d88 <disk_ioctl+0x1b8>
                        res = RES_OK;
                        break;

                case CTRL_SYNC :        /* Make sure that data has been written */
                        if (wait_ready() == 0xFF)
    1cf6:       0e 94 d3 0c     call    0x19a6  ; 0x19a6 <wait_ready>
    1cfa:       90 e0           ldi     r25, 0x00       ; 0
    1cfc:       8f 3f           cpi     r24, 0xFF       ; 255
    1cfe:       01 f5           brne    .+64            ; 0x1d40 <disk_ioctl+0x170>
    1d00:       1e c0           rjmp    .+60            ; 0x1d3e <disk_ioctl+0x16e>
                                res = RES_OK;
                        break;

                case MMC_GET_CSD :      /* Receive CSD as a data block (16 bytes) */
                        if (Stat & STA_NOINIT) return RES_NOTRDY;
    1d02:       80 91 04 01     lds     r24, 0x0104
    1d06:       80 fd           sbrc    r24, 0
    1d08:       47 c0           rjmp    .+142           ; 0x1d98 <disk_ioctl+0x1c8>
                        if ((send_cmd(CMD9, 0) == 0)    /* READ_CSD */
    1d0a:       40 e0           ldi     r20, 0x00       ; 0
    1d0c:       50 e0           ldi     r21, 0x00       ; 0
    1d0e:       60 e0           ldi     r22, 0x00       ; 0
    1d10:       70 e0           ldi     r23, 0x00       ; 0
    1d12:       89 e4           ldi     r24, 0x49       ; 73
    1d14:       09 c0           rjmp    .+18            ; 0x1d28 <disk_ioctl+0x158>
                                && rcvr_datablock(ptr, 16))
                                res = RES_OK;
                        break;

                case MMC_GET_CID :      /* Receive CID as a data block (16 bytes) */
                        if (Stat & STA_NOINIT) return RES_NOTRDY;
    1d16:       80 91 04 01     lds     r24, 0x0104
    1d1a:       80 fd           sbrc    r24, 0
    1d1c:       3d c0           rjmp    .+122           ; 0x1d98 <disk_ioctl+0x1c8>
                        if ((send_cmd(CMD10, 0) == 0)   /* READ_CID */
    1d1e:       40 e0           ldi     r20, 0x00       ; 0
    1d20:       50 e0           ldi     r21, 0x00       ; 0
    1d22:       60 e0           ldi     r22, 0x00       ; 0
    1d24:       70 e0           ldi     r23, 0x00       ; 0
    1d26:       8a e4           ldi     r24, 0x4A       ; 74
    1d28:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1d2c:       88 23           and     r24, r24
    1d2e:       51 f5           brne    .+84            ; 0x1d84 <disk_ioctl+0x1b4>
    1d30:       60 e1           ldi     r22, 0x10       ; 16
    1d32:       70 e0           ldi     r23, 0x00       ; 0
    1d34:       c8 01           movw    r24, r16
    1d36:       0e 94 ec 0c     call    0x19d8  ; 0x19d8 <rcvr_datablock>
    1d3a:       90 e0           ldi     r25, 0x00       ; 0
    1d3c:       81 11           cpse    r24, r1
    1d3e:       91 e0           ldi     r25, 0x01       ; 1
    1d40:       81 e0           ldi     r24, 0x01       ; 1
    1d42:       98 27           eor     r25, r24
    1d44:       29 2f           mov     r18, r25
    1d46:       33 27           eor     r19, r19
    1d48:       1f c0           rjmp    .+62            ; 0x1d88 <disk_ioctl+0x1b8>
                                && rcvr_datablock(ptr, 16))
                                res = RES_OK;
                        break;

                case MMC_GET_OCR :      /* Receive OCR as an R3 resp (4 bytes) */
                        if (Stat & STA_NOINIT) return RES_NOTRDY;
    1d4a:       80 91 04 01     lds     r24, 0x0104
    1d4e:       80 fd           sbrc    r24, 0
    1d50:       23 c0           rjmp    .+70            ; 0x1d98 <disk_ioctl+0x1c8>
                        if (send_cmd(CMD58, 0) == 0) {  /* READ_OCR */
    1d52:       40 e0           ldi     r20, 0x00       ; 0
    1d54:       50 e0           ldi     r21, 0x00       ; 0
    1d56:       60 e0           ldi     r22, 0x00       ; 0
    1d58:       70 e0           ldi     r23, 0x00       ; 0
    1d5a:       8a e7           ldi     r24, 0x7A       ; 122
    1d5c:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1d60:       88 23           and     r24, r24
    1d62:       81 f4           brne    .+32            ; 0x1d84 <disk_ioctl+0x1b4>
    1d64:       90 e0           ldi     r25, 0x00       ; 0
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1d66:       8f ef           ldi     r24, 0xFF       ; 255
    1d68:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1d6a:       0d b4           in      r0, 0x2d        ; 45
    1d6c:       07 fe           sbrs    r0, 7
    1d6e:       fd cf           rjmp    .-6             ; 0x1d6a <disk_ioctl+0x19a>
        return SPDR;
    1d70:       8e b5           in      r24, 0x2e       ; 46

                case MMC_GET_OCR :      /* Receive OCR as an R3 resp (4 bytes) */
                        if (Stat & STA_NOINIT) return RES_NOTRDY;
                        if (send_cmd(CMD58, 0) == 0) {  /* READ_OCR */
                                for (n = 0; n < 4; n++)
                                        *ptr++ = rcvr_spi();
    1d72:       f8 01           movw    r30, r16
    1d74:       80 83           st      Z, r24
                        break;

                case MMC_GET_OCR :      /* Receive OCR as an R3 resp (4 bytes) */
                        if (Stat & STA_NOINIT) return RES_NOTRDY;
                        if (send_cmd(CMD58, 0) == 0) {  /* READ_OCR */
                                for (n = 0; n < 4; n++)
    1d76:       9f 5f           subi    r25, 0xFF       ; 255
    1d78:       94 30           cpi     r25, 0x04       ; 4
    1d7a:       09 f4           brne    .+2             ; 0x1d7e <disk_ioctl+0x1ae>
    1d7c:       b9 cf           rjmp    .-142           ; 0x1cf0 <disk_ioctl+0x120>
                                        *ptr++ = rcvr_spi();
    1d7e:       0f 5f           subi    r16, 0xFF       ; 255
    1d80:       1f 4f           sbci    r17, 0xFF       ; 255
    1d82:       f1 cf           rjmp    .-30            ; 0x1d66 <disk_ioctl+0x196>
    1d84:       21 e0           ldi     r18, 0x01       ; 1
    1d86:       30 e0           ldi     r19, 0x00       ; 0

                default:
                        res = RES_PARERR;
        }

        DESELECT();                     /* CS = H */
    1d88:       2a 9a           sbi     0x05, 2 ; 5
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1d8a:       8f ef           ldi     r24, 0xFF       ; 255
    1d8c:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1d8e:       0d b4           in      r0, 0x2d        ; 45
    1d90:       07 fe           sbrs    r0, 7
    1d92:       fd cf           rjmp    .-6             ; 0x1d8e <disk_ioctl+0x1be>
        return SPDR;
    1d94:       8e b5           in      r24, 0x2e       ; 46
    1d96:       02 c0           rjmp    .+4             ; 0x1d9c <disk_ioctl+0x1cc>
        }

        DESELECT();                     /* CS = H */
        rcvr_spi();                     /* Idle (Release DO) */

        return res;
    1d98:       23 e0           ldi     r18, 0x03       ; 3
    1d9a:       30 e0           ldi     r19, 0x00       ; 0
}
    1d9c:       c9 01           movw    r24, r18
    1d9e:       e4 e0           ldi     r30, 0x04       ; 4
    1da0:       60 96           adiw    r28, 0x10       ; 16
    1da2:       0c 94 54 11     jmp     0x22a8  ; 0x22a8 <__epilogue_restores__+0x1c>

00001da6 <disk_write>:
        BYTE drv,                       /* Physical drive nmuber (0) */
        const BYTE *buff,       /* Pointer to the data to be written */
        DWORD sector,           /* Start sector number (LBA) */
        BYTE count                      /* Sector count (1..255) */
)
{
    1da6:       cf 92           push    r12
    1da8:       df 92           push    r13
    1daa:       ef 92           push    r14
    1dac:       ff 92           push    r15
    1dae:       0f 93           push    r16
    1db0:       cf 93           push    r28
    1db2:       df 93           push    r29
    1db4:       eb 01           movw    r28, r22
    1db6:       69 01           movw    r12, r18
    1db8:       7a 01           movw    r14, r20
        if (drv || !count) return RES_PARERR;
    1dba:       88 23           and     r24, r24
    1dbc:       09 f0           breq    .+2             ; 0x1dc0 <disk_write+0x1a>
    1dbe:       67 c0           rjmp    .+206           ; 0x1e8e <disk_write+0xe8>
    1dc0:       00 23           and     r16, r16
    1dc2:       09 f4           brne    .+2             ; 0x1dc6 <disk_write+0x20>
    1dc4:       64 c0           rjmp    .+200           ; 0x1e8e <disk_write+0xe8>
        if (Stat & STA_NOINIT) return RES_NOTRDY;
    1dc6:       80 91 04 01     lds     r24, 0x0104
    1dca:       80 ff           sbrs    r24, 0
    1dcc:       03 c0           rjmp    .+6             ; 0x1dd4 <disk_write+0x2e>
    1dce:       83 e0           ldi     r24, 0x03       ; 3
    1dd0:       90 e0           ldi     r25, 0x00       ; 0
    1dd2:       5f c0           rjmp    .+190           ; 0x1e92 <disk_write+0xec>
        if (Stat & STA_PROTECT) return RES_WRPRT;
    1dd4:       80 91 04 01     lds     r24, 0x0104
    1dd8:       82 ff           sbrs    r24, 2
    1dda:       03 c0           rjmp    .+6             ; 0x1de2 <disk_write+0x3c>
    1ddc:       82 e0           ldi     r24, 0x02       ; 2
    1dde:       90 e0           ldi     r25, 0x00       ; 0
    1de0:       58 c0           rjmp    .+176           ; 0x1e92 <disk_write+0xec>

        if (!(CardType & 4)) sector *= 512;     /* Convert to byte address if needed */
    1de2:       80 91 11 01     lds     r24, 0x0111
    1de6:       99 27           eor     r25, r25
    1de8:       82 fd           sbrc    r24, 2
    1dea:       07 c0           rjmp    .+14            ; 0x1dfa <disk_write+0x54>
    1dec:       e9 e0           ldi     r30, 0x09       ; 9
    1dee:       cc 0c           add     r12, r12
    1df0:       dd 1c           adc     r13, r13
    1df2:       ee 1c           adc     r14, r14
    1df4:       ff 1c           adc     r15, r15
    1df6:       ea 95           dec     r30
    1df8:       d1 f7           brne    .-12            ; 0x1dee <disk_write+0x48>

        SELECT();                       /* CS = L */
    1dfa:       2a 98           cbi     0x05, 2 ; 5

        if (count == 1) {       /* Single block write */
    1dfc:       01 30           cpi     r16, 0x01       ; 1
    1dfe:       79 f4           brne    .+30            ; 0x1e1e <disk_write+0x78>
                if ((send_cmd(CMD24, sector) == 0)      /* WRITE_BLOCK */
    1e00:       b7 01           movw    r22, r14
    1e02:       a6 01           movw    r20, r12
    1e04:       88 e5           ldi     r24, 0x58       ; 88
    1e06:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1e0a:       88 23           and     r24, r24
    1e0c:       91 f5           brne    .+100           ; 0x1e72 <disk_write+0xcc>
    1e0e:       6e ef           ldi     r22, 0xFE       ; 254
    1e10:       ce 01           movw    r24, r28
    1e12:       0e 94 24 0d     call    0x1a48  ; 0x1a48 <xmit_datablock>
    1e16:       81 11           cpse    r24, r1
    1e18:       81 e0           ldi     r24, 0x01       ; 1
    1e1a:       08 27           eor     r16, r24
    1e1c:       2a c0           rjmp    .+84            ; 0x1e72 <disk_write+0xcc>
                        && xmit_datablock(buff, 0xFE))
                        count = 0;
        }
        else {                          /* Multiple block write */
                if (CardType & 2) {
    1e1e:       81 ff           sbrs    r24, 1
    1e20:       0e c0           rjmp    .+28            ; 0x1e3e <disk_write+0x98>
                        send_cmd(CMD55, 0); send_cmd(CMD23, count);     /* ACMD23 */
    1e22:       40 e0           ldi     r20, 0x00       ; 0
    1e24:       50 e0           ldi     r21, 0x00       ; 0
    1e26:       60 e0           ldi     r22, 0x00       ; 0
    1e28:       70 e0           ldi     r23, 0x00       ; 0
    1e2a:       87 e7           ldi     r24, 0x77       ; 119
    1e2c:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1e30:       40 2f           mov     r20, r16
    1e32:       55 27           eor     r21, r21
    1e34:       66 27           eor     r22, r22
    1e36:       77 27           eor     r23, r23
    1e38:       87 e5           ldi     r24, 0x57       ; 87
    1e3a:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
                }
                if (send_cmd(CMD25, sector) == 0) {     /* WRITE_MULTIPLE_BLOCK */
    1e3e:       b7 01           movw    r22, r14
    1e40:       a6 01           movw    r20, r12
    1e42:       89 e5           ldi     r24, 0x59       ; 89
    1e44:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1e48:       88 23           and     r24, r24
    1e4a:       99 f4           brne    .+38            ; 0x1e72 <disk_write+0xcc>
                        do {
                                if (!xmit_datablock(buff, 0xFC)) break;
    1e4c:       6c ef           ldi     r22, 0xFC       ; 252
    1e4e:       ce 01           movw    r24, r28
    1e50:       0e 94 24 0d     call    0x1a48  ; 0x1a48 <xmit_datablock>
    1e54:       88 23           and     r24, r24
    1e56:       29 f0           breq    .+10            ; 0x1e62 <disk_write+0xbc>
                                buff += 512;
                        } while (--count);
    1e58:       01 50           subi    r16, 0x01       ; 1
    1e5a:       19 f0           breq    .+6             ; 0x1e62 <disk_write+0xbc>
                        send_cmd(CMD55, 0); send_cmd(CMD23, count);     /* ACMD23 */
                }
                if (send_cmd(CMD25, sector) == 0) {     /* WRITE_MULTIPLE_BLOCK */
                        do {
                                if (!xmit_datablock(buff, 0xFC)) break;
                                buff += 512;
    1e5c:       c0 50           subi    r28, 0x00       ; 0
    1e5e:       de 4f           sbci    r29, 0xFE       ; 254
    1e60:       f5 cf           rjmp    .-22            ; 0x1e4c <disk_write+0xa6>
                        } while (--count);
                        if (!xmit_datablock(0, 0xFD))   /* STOP_TRAN token */
    1e62:       6d ef           ldi     r22, 0xFD       ; 253
    1e64:       80 e0           ldi     r24, 0x00       ; 0
    1e66:       90 e0           ldi     r25, 0x00       ; 0
    1e68:       0e 94 24 0d     call    0x1a48  ; 0x1a48 <xmit_datablock>
    1e6c:       88 23           and     r24, r24
    1e6e:       09 f4           brne    .+2             ; 0x1e72 <disk_write+0xcc>
    1e70:       01 e0           ldi     r16, 0x01       ; 1
                                count = 1;
                }
        }

        DESELECT();                     /* CS = H */
    1e72:       2a 9a           sbi     0x05, 2 ; 5
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1e74:       8f ef           ldi     r24, 0xFF       ; 255
    1e76:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1e78:       0d b4           in      r0, 0x2d        ; 45
    1e7a:       07 fe           sbrs    r0, 7
    1e7c:       fd cf           rjmp    .-6             ; 0x1e78 <disk_write+0xd2>
        return SPDR;
    1e7e:       8e b5           in      r24, 0x2e       ; 46
        }

        DESELECT();                     /* CS = H */
        rcvr_spi();                     /* Idle (Release DO) */

        return count ? RES_ERROR : RES_OK;
    1e80:       80 e0           ldi     r24, 0x00       ; 0
    1e82:       90 e0           ldi     r25, 0x00       ; 0
    1e84:       00 23           and     r16, r16
    1e86:       29 f0           breq    .+10            ; 0x1e92 <disk_write+0xec>
    1e88:       81 e0           ldi     r24, 0x01       ; 1
    1e8a:       90 e0           ldi     r25, 0x00       ; 0
    1e8c:       02 c0           rjmp    .+4             ; 0x1e92 <disk_write+0xec>
    1e8e:       84 e0           ldi     r24, 0x04       ; 4
    1e90:       90 e0           ldi     r25, 0x00       ; 0
    1e92:       df 91           pop     r29
    1e94:       cf 91           pop     r28
    1e96:       0f 91           pop     r16
    1e98:       ff 90           pop     r15
    1e9a:       ef 90           pop     r14
    1e9c:       df 90           pop     r13
    1e9e:       cf 90           pop     r12
    1ea0:       08 95           ret

00001ea2 <disk_read>:
        BYTE drv,                       /* Physical drive nmuber (0) */
        BYTE *buff,                     /* Pointer to the data buffer to store read data */
        DWORD sector,           /* Start sector number (LBA) */
        BYTE count                      /* Sector count (1..255) */
)
{
    1ea2:       0f 93           push    r16
    1ea4:       cf 93           push    r28
    1ea6:       df 93           push    r29
    1ea8:       eb 01           movw    r28, r22
        if (drv || !count) return RES_PARERR;
    1eaa:       88 23           and     r24, r24
    1eac:       09 f0           breq    .+2             ; 0x1eb0 <disk_read+0xe>
    1eae:       50 c0           rjmp    .+160           ; 0x1f50 <disk_read+0xae>
    1eb0:       00 23           and     r16, r16
    1eb2:       09 f4           brne    .+2             ; 0x1eb6 <disk_read+0x14>
    1eb4:       4d c0           rjmp    .+154           ; 0x1f50 <disk_read+0xae>
        if (Stat & STA_NOINIT) return RES_NOTRDY;
    1eb6:       80 91 04 01     lds     r24, 0x0104
    1eba:       80 ff           sbrs    r24, 0
    1ebc:       03 c0           rjmp    .+6             ; 0x1ec4 <disk_read+0x22>
    1ebe:       83 e0           ldi     r24, 0x03       ; 3
    1ec0:       90 e0           ldi     r25, 0x00       ; 0
    1ec2:       48 c0           rjmp    .+144           ; 0x1f54 <disk_read+0xb2>

        if (!(CardType & 4)) sector *= 512;     /* Convert to byte address if needed */
    1ec4:       80 91 11 01     lds     r24, 0x0111
    1ec8:       82 fd           sbrc    r24, 2
    1eca:       07 c0           rjmp    .+14            ; 0x1eda <disk_read+0x38>
    1ecc:       f9 e0           ldi     r31, 0x09       ; 9
    1ece:       22 0f           add     r18, r18
    1ed0:       33 1f           adc     r19, r19
    1ed2:       44 1f           adc     r20, r20
    1ed4:       55 1f           adc     r21, r21
    1ed6:       fa 95           dec     r31
    1ed8:       d1 f7           brne    .-12            ; 0x1ece <disk_read+0x2c>

        SELECT();                       /* CS = L */
    1eda:       2a 98           cbi     0x05, 2 ; 5

        if (count == 1) {       /* Single block read */
    1edc:       01 30           cpi     r16, 0x01       ; 1
    1ede:       81 f4           brne    .+32            ; 0x1f00 <disk_read+0x5e>
                if ((send_cmd(CMD17, sector) == 0)      /* READ_SINGLE_BLOCK */
    1ee0:       ba 01           movw    r22, r20
    1ee2:       a9 01           movw    r20, r18
    1ee4:       81 e5           ldi     r24, 0x51       ; 81
    1ee6:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1eea:       88 23           and     r24, r24
    1eec:       19 f5           brne    .+70            ; 0x1f34 <disk_read+0x92>
    1eee:       60 e0           ldi     r22, 0x00       ; 0
    1ef0:       72 e0           ldi     r23, 0x02       ; 2
    1ef2:       ce 01           movw    r24, r28
    1ef4:       0e 94 ec 0c     call    0x19d8  ; 0x19d8 <rcvr_datablock>
    1ef8:       81 11           cpse    r24, r1
    1efa:       81 e0           ldi     r24, 0x01       ; 1
    1efc:       08 27           eor     r16, r24
    1efe:       1a c0           rjmp    .+52            ; 0x1f34 <disk_read+0x92>
                        && rcvr_datablock(buff, 512))
                        count = 0;
        }
        else {                          /* Multiple block read */
                if (send_cmd(CMD18, sector) == 0) {     /* READ_MULTIPLE_BLOCK */
    1f00:       ba 01           movw    r22, r20
    1f02:       a9 01           movw    r20, r18
    1f04:       82 e5           ldi     r24, 0x52       ; 82
    1f06:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1f0a:       88 23           and     r24, r24
    1f0c:       99 f4           brne    .+38            ; 0x1f34 <disk_read+0x92>
                        do {
                                if (!rcvr_datablock(buff, 512)) break;
    1f0e:       60 e0           ldi     r22, 0x00       ; 0
    1f10:       72 e0           ldi     r23, 0x02       ; 2
    1f12:       ce 01           movw    r24, r28
    1f14:       0e 94 ec 0c     call    0x19d8  ; 0x19d8 <rcvr_datablock>
    1f18:       88 23           and     r24, r24
    1f1a:       29 f0           breq    .+10            ; 0x1f26 <disk_read+0x84>
                                buff += 512;
                        } while (--count);
    1f1c:       01 50           subi    r16, 0x01       ; 1
    1f1e:       19 f0           breq    .+6             ; 0x1f26 <disk_read+0x84>
        }
        else {                          /* Multiple block read */
                if (send_cmd(CMD18, sector) == 0) {     /* READ_MULTIPLE_BLOCK */
                        do {
                                if (!rcvr_datablock(buff, 512)) break;
                                buff += 512;
    1f20:       c0 50           subi    r28, 0x00       ; 0
    1f22:       de 4f           sbci    r29, 0xFE       ; 254
    1f24:       f4 cf           rjmp    .-24            ; 0x1f0e <disk_read+0x6c>
                        } while (--count);
                        send_cmd(CMD12, 0);                             /* STOP_TRANSMISSION */
    1f26:       40 e0           ldi     r20, 0x00       ; 0
    1f28:       50 e0           ldi     r21, 0x00       ; 0
    1f2a:       60 e0           ldi     r22, 0x00       ; 0
    1f2c:       70 e0           ldi     r23, 0x00       ; 0
    1f2e:       8c e4           ldi     r24, 0x4C       ; 76
    1f30:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
                }
        }

        DESELECT();                     /* CS = H */
    1f34:       2a 9a           sbi     0x05, 2 ; 5
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1f36:       8f ef           ldi     r24, 0xFF       ; 255
    1f38:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1f3a:       0d b4           in      r0, 0x2d        ; 45
    1f3c:       07 fe           sbrs    r0, 7
    1f3e:       fd cf           rjmp    .-6             ; 0x1f3a <disk_read+0x98>
        return SPDR;
    1f40:       8e b5           in      r24, 0x2e       ; 46
        }

        DESELECT();                     /* CS = H */
        rcvr_spi();                     /* Idle (Release DO) */

        return count ? RES_ERROR : RES_OK;
    1f42:       80 e0           ldi     r24, 0x00       ; 0
    1f44:       90 e0           ldi     r25, 0x00       ; 0
    1f46:       00 23           and     r16, r16
    1f48:       29 f0           breq    .+10            ; 0x1f54 <disk_read+0xb2>
    1f4a:       81 e0           ldi     r24, 0x01       ; 1
    1f4c:       90 e0           ldi     r25, 0x00       ; 0
    1f4e:       02 c0           rjmp    .+4             ; 0x1f54 <disk_read+0xb2>
    1f50:       84 e0           ldi     r24, 0x04       ; 4
    1f52:       90 e0           ldi     r25, 0x00       ; 0
    1f54:       df 91           pop     r29
    1f56:       cf 91           pop     r28
    1f58:       0f 91           pop     r16
    1f5a:       08 95           ret

00001f5c <disk_initialize>:
/*-----------------------------------------------------------------------*/

DSTATUS disk_initialize (
        BYTE drv                /* Physical drive nmuber (0) */
)
{
    1f5c:       a4 e0           ldi     r26, 0x04       ; 4
    1f5e:       b0 e0           ldi     r27, 0x00       ; 0
    1f60:       e4 eb           ldi     r30, 0xB4       ; 180
    1f62:       ff e0           ldi     r31, 0x0F       ; 15
    1f64:       0c 94 36 11     jmp     0x226c  ; 0x226c <__prologue_saves__+0x18>
        BYTE n, ty, ocr[4];


        if (drv) return STA_NOINIT;                     /* Supports only single drive */
    1f68:       88 23           and     r24, r24
    1f6a:       19 f0           breq    .+6             ; 0x1f72 <disk_initialize+0x16>
    1f6c:       81 e0           ldi     r24, 0x01       ; 1
    1f6e:       90 e0           ldi     r25, 0x00       ; 0
    1f70:       d0 c0           rjmp    .+416           ; 0x2112 <disk_initialize+0x1b6>
        if (Stat & STA_NODISK) return Stat;     /* No card in the socket */
    1f72:       80 91 04 01     lds     r24, 0x0104
    1f76:       81 fd           sbrc    r24, 1
    1f78:       c9 c0           rjmp    .+402           ; 0x210c <disk_initialize+0x1b0>
    1f7a:       9a e0           ldi     r25, 0x0A       ; 10
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1f7c:       8f ef           ldi     r24, 0xFF       ; 255
    1f7e:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1f80:       0d b4           in      r0, 0x2d        ; 45
    1f82:       07 fe           sbrs    r0, 7
    1f84:       fd cf           rjmp    .-6             ; 0x1f80 <disk_initialize+0x24>
        return SPDR;
    1f86:       8e b5           in      r24, 0x2e       ; 46


        if (drv) return STA_NOINIT;                     /* Supports only single drive */
        if (Stat & STA_NODISK) return Stat;     /* No card in the socket */

        for (n = 10; n; n--) rcvr_spi();        /* 80 dummy clocks */
    1f88:       91 50           subi    r25, 0x01       ; 1
    1f8a:       c1 f7           brne    .-16            ; 0x1f7c <disk_initialize+0x20>

        SELECT();                               /* CS = L */
    1f8c:       2a 98           cbi     0x05, 2 ; 5
        ty = 0;
        if (send_cmd(CMD0, 0) == 1) {                   /* Enter Idle state */
    1f8e:       40 e0           ldi     r20, 0x00       ; 0
    1f90:       50 e0           ldi     r21, 0x00       ; 0
    1f92:       60 e0           ldi     r22, 0x00       ; 0
    1f94:       70 e0           ldi     r23, 0x00       ; 0
    1f96:       80 e4           ldi     r24, 0x40       ; 64
    1f98:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1f9c:       81 30           cpi     r24, 0x01       ; 1
    1f9e:       09 f0           breq    .+2             ; 0x1fa2 <disk_initialize+0x46>
    1fa0:       a0 c0           rjmp    .+320           ; 0x20e2 <disk_initialize+0x186>
                Timer1 = 100;                                           /* Initialization timeout of 1000 msec */
    1fa2:       84 e6           ldi     r24, 0x64       ; 100
    1fa4:       80 93 0f 01     sts     0x010F, r24
                if (send_cmd(CMD8, 0x1AA) == 1) {       /* SDC Ver2+ */
    1fa8:       4a ea           ldi     r20, 0xAA       ; 170
    1faa:       51 e0           ldi     r21, 0x01       ; 1
    1fac:       60 e0           ldi     r22, 0x00       ; 0
    1fae:       70 e0           ldi     r23, 0x00       ; 0
    1fb0:       88 e4           ldi     r24, 0x48       ; 72
    1fb2:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    1fb6:       81 30           cpi     r24, 0x01       ; 1
    1fb8:       09 f0           breq    .+2             ; 0x1fbc <disk_initialize+0x60>
    1fba:       54 c0           rjmp    .+168           ; 0x2064 <disk_initialize+0x108>
    1fbc:       7e 01           movw    r14, r28
    1fbe:       08 94           sec
    1fc0:       e1 1c           adc     r14, r1
    1fc2:       f1 1c           adc     r15, r1
    1fc4:       87 01           movw    r16, r14
                        for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
    1fc6:       9e 01           movw    r18, r28
    1fc8:       2b 5f           subi    r18, 0xFB       ; 251
    1fca:       3f 4f           sbci    r19, 0xFF       ; 255
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    1fcc:       8f ef           ldi     r24, 0xFF       ; 255
    1fce:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    1fd0:       0d b4           in      r0, 0x2d        ; 45
    1fd2:       07 fe           sbrs    r0, 7
    1fd4:       fd cf           rjmp    .-6             ; 0x1fd0 <disk_initialize+0x74>
        return SPDR;
    1fd6:       8e b5           in      r24, 0x2e       ; 46
        SELECT();                               /* CS = L */
        ty = 0;
        if (send_cmd(CMD0, 0) == 1) {                   /* Enter Idle state */
                Timer1 = 100;                                           /* Initialization timeout of 1000 msec */
                if (send_cmd(CMD8, 0x1AA) == 1) {       /* SDC Ver2+ */
                        for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
    1fd8:       f8 01           movw    r30, r16
    1fda:       81 93           st      Z+, r24
    1fdc:       8f 01           movw    r16, r30
    1fde:       e2 17           cp      r30, r18
    1fe0:       f3 07           cpc     r31, r19
    1fe2:       a1 f7           brne    .-24            ; 0x1fcc <disk_initialize+0x70>
                        if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */
    1fe4:       8b 81           ldd     r24, Y+3        ; 0x03
    1fe6:       81 30           cpi     r24, 0x01       ; 1
    1fe8:       09 f0           breq    .+2             ; 0x1fec <disk_initialize+0x90>
    1fea:       7b c0           rjmp    .+246           ; 0x20e2 <disk_initialize+0x186>
    1fec:       8c 81           ldd     r24, Y+4        ; 0x04
    1fee:       8a 3a           cpi     r24, 0xAA       ; 170
    1ff0:       09 f0           breq    .+2             ; 0x1ff4 <disk_initialize+0x98>
    1ff2:       77 c0           rjmp    .+238           ; 0x20e2 <disk_initialize+0x186>
                                do {
                                        if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 1UL << 30) == 0) break;  /* ACMD41 with HCS bit */
    1ff4:       40 e0           ldi     r20, 0x00       ; 0
    1ff6:       50 e0           ldi     r21, 0x00       ; 0
    1ff8:       60 e0           ldi     r22, 0x00       ; 0
    1ffa:       70 e0           ldi     r23, 0x00       ; 0
    1ffc:       87 e7           ldi     r24, 0x77       ; 119
    1ffe:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    2002:       82 30           cpi     r24, 0x02       ; 2
    2004:       48 f4           brcc    .+18            ; 0x2018 <disk_initialize+0xbc>
    2006:       40 e0           ldi     r20, 0x00       ; 0
    2008:       50 e0           ldi     r21, 0x00       ; 0
    200a:       60 e0           ldi     r22, 0x00       ; 0
    200c:       70 e4           ldi     r23, 0x40       ; 64
    200e:       89 e6           ldi     r24, 0x69       ; 105
    2010:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    2014:       88 23           and     r24, r24
    2016:       21 f0           breq    .+8             ; 0x2020 <disk_initialize+0xc4>
                                } while (Timer1);
    2018:       80 91 0f 01     lds     r24, 0x010F
    201c:       88 23           and     r24, r24
    201e:       51 f7           brne    .-44            ; 0x1ff4 <disk_initialize+0x98>
                                if (Timer1 && send_cmd(CMD58, 0) == 0) {        /* Check CCS bit */
    2020:       80 91 0f 01     lds     r24, 0x010F
    2024:       88 23           and     r24, r24
    2026:       09 f4           brne    .+2             ; 0x202a <disk_initialize+0xce>
    2028:       5c c0           rjmp    .+184           ; 0x20e2 <disk_initialize+0x186>
    202a:       40 e0           ldi     r20, 0x00       ; 0
    202c:       50 e0           ldi     r21, 0x00       ; 0
    202e:       60 e0           ldi     r22, 0x00       ; 0
    2030:       70 e0           ldi     r23, 0x00       ; 0
    2032:       8a e7           ldi     r24, 0x7A       ; 122
    2034:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    2038:       88 23           and     r24, r24
    203a:       09 f0           breq    .+2             ; 0x203e <disk_initialize+0xe2>
    203c:       52 c0           rjmp    .+164           ; 0x20e2 <disk_initialize+0x186>
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    203e:       8f ef           ldi     r24, 0xFF       ; 255
    2040:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    2042:       0d b4           in      r0, 0x2d        ; 45
    2044:       07 fe           sbrs    r0, 7
    2046:       fd cf           rjmp    .-6             ; 0x2042 <disk_initialize+0xe6>
        return SPDR;
    2048:       8e b5           in      r24, 0x2e       ; 46
                        if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */
                                do {
                                        if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 1UL << 30) == 0) break;  /* ACMD41 with HCS bit */
                                } while (Timer1);
                                if (Timer1 && send_cmd(CMD58, 0) == 0) {        /* Check CCS bit */
                                        for (n = 0; n < 4; n++) ocr[n] = rcvr_spi();
    204a:       f7 01           movw    r30, r14
    204c:       81 93           st      Z+, r24
    204e:       7f 01           movw    r14, r30
    2050:       e0 17           cp      r30, r16
    2052:       f1 07           cpc     r31, r17
    2054:       a1 f7           brne    .-24            ; 0x203e <disk_initialize+0xe2>
                                        ty = (ocr[0] & 0x40) ? 6 : 2;
    2056:       89 81           ldd     r24, Y+1        ; 0x01
    2058:       86 ff           sbrs    r24, 6
    205a:       02 c0           rjmp    .+4             ; 0x2060 <disk_initialize+0x104>
    205c:       16 e0           ldi     r17, 0x06       ; 6
    205e:       42 c0           rjmp    .+132           ; 0x20e4 <disk_initialize+0x188>
    2060:       12 e0           ldi     r17, 0x02       ; 2
    2062:       40 c0           rjmp    .+128           ; 0x20e4 <disk_initialize+0x188>
                                }
                        }
                } else {                                                        /* SDC Ver1 or MMC */
                        ty = (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 0) <= 1) ? 2 : 1;      /* SDC : MMC */
    2064:       40 e0           ldi     r20, 0x00       ; 0
    2066:       50 e0           ldi     r21, 0x00       ; 0
    2068:       60 e0           ldi     r22, 0x00       ; 0
    206a:       70 e0           ldi     r23, 0x00       ; 0
    206c:       87 e7           ldi     r24, 0x77       ; 119
    206e:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    2072:       82 30           cpi     r24, 0x02       ; 2
    2074:       58 f4           brcc    .+22            ; 0x208c <disk_initialize+0x130>
    2076:       40 e0           ldi     r20, 0x00       ; 0
    2078:       50 e0           ldi     r21, 0x00       ; 0
    207a:       60 e0           ldi     r22, 0x00       ; 0
    207c:       70 e0           ldi     r23, 0x00       ; 0
    207e:       89 e6           ldi     r24, 0x69       ; 105
    2080:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    2084:       82 30           cpi     r24, 0x02       ; 2
    2086:       10 f4           brcc    .+4             ; 0x208c <disk_initialize+0x130>
    2088:       12 e0           ldi     r17, 0x02       ; 2
    208a:       01 c0           rjmp    .+2             ; 0x208e <disk_initialize+0x132>
    208c:       11 e0           ldi     r17, 0x01       ; 1
                        do {
                                if (ty == 2) {
    208e:       12 30           cpi     r17, 0x02       ; 2
    2090:       79 f4           brne    .+30            ; 0x20b0 <disk_initialize+0x154>
                                        if (send_cmd(CMD55, 0) <= 1 && send_cmd(CMD41, 0) == 0) break;  /* ACMD41 */
    2092:       40 e0           ldi     r20, 0x00       ; 0
    2094:       50 e0           ldi     r21, 0x00       ; 0
    2096:       60 e0           ldi     r22, 0x00       ; 0
    2098:       70 e0           ldi     r23, 0x00       ; 0
    209a:       87 e7           ldi     r24, 0x77       ; 119
    209c:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    20a0:       82 30           cpi     r24, 0x02       ; 2
    20a2:       78 f4           brcc    .+30            ; 0x20c2 <disk_initialize+0x166>
    20a4:       40 e0           ldi     r20, 0x00       ; 0
    20a6:       50 e0           ldi     r21, 0x00       ; 0
    20a8:       60 e0           ldi     r22, 0x00       ; 0
    20aa:       70 e0           ldi     r23, 0x00       ; 0
    20ac:       89 e6           ldi     r24, 0x69       ; 105
    20ae:       05 c0           rjmp    .+10            ; 0x20ba <disk_initialize+0x15e>
                                } else {
                                        if (send_cmd(CMD1, 0) == 0) break;                                                              /* CMD1 */
    20b0:       40 e0           ldi     r20, 0x00       ; 0
    20b2:       50 e0           ldi     r21, 0x00       ; 0
    20b4:       60 e0           ldi     r22, 0x00       ; 0
    20b6:       70 e0           ldi     r23, 0x00       ; 0
    20b8:       81 e4           ldi     r24, 0x41       ; 65
    20ba:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    20be:       88 23           and     r24, r24
    20c0:       21 f0           breq    .+8             ; 0x20ca <disk_initialize+0x16e>
                                }
                        } while (Timer1);
    20c2:       80 91 0f 01     lds     r24, 0x010F
    20c6:       88 23           and     r24, r24
    20c8:       11 f7           brne    .-60            ; 0x208e <disk_initialize+0x132>
                        if (!Timer1 || send_cmd(CMD16, 512) != 0)       /* Select R/W block length */
    20ca:       80 91 0f 01     lds     r24, 0x010F
    20ce:       88 23           and     r24, r24
    20d0:       41 f0           breq    .+16            ; 0x20e2 <disk_initialize+0x186>
    20d2:       40 e0           ldi     r20, 0x00       ; 0
    20d4:       52 e0           ldi     r21, 0x02       ; 2
    20d6:       60 e0           ldi     r22, 0x00       ; 0
    20d8:       70 e0           ldi     r23, 0x00       ; 0
    20da:       80 e5           ldi     r24, 0x50       ; 80
    20dc:       0e 94 65 0d     call    0x1aca  ; 0x1aca <send_cmd>
    20e0:       81 11           cpse    r24, r1
    20e2:       10 e0           ldi     r17, 0x00       ; 0
                                ty = 0;
                }
        }
        CardType = ty;
    20e4:       10 93 11 01     sts     0x0111, r17
        DESELECT();                     /* CS = H */
    20e8:       2a 9a           sbi     0x05, 2 ; 5
/*-----------------------------------------------------------------------*/

static
BYTE rcvr_spi (void)
{
        SPDR = 0xFF;
    20ea:       8f ef           ldi     r24, 0xFF       ; 255
    20ec:       8e bd           out     0x2e, r24       ; 46
        loop_until_bit_is_set(SPSR, SPIF);
    20ee:       0d b4           in      r0, 0x2d        ; 45
    20f0:       07 fe           sbrs    r0, 7
    20f2:       fd cf           rjmp    .-6             ; 0x20ee <disk_initialize+0x192>
        return SPDR;
    20f4:       8e b5           in      r24, 0x2e       ; 46
        }
        CardType = ty;
        DESELECT();                     /* CS = H */
        rcvr_spi();                     /* Idle (Release DO) */

        if (ty) {                       /* Initialization succeded */
    20f6:       11 23           and     r17, r17
    20f8:       21 f0           breq    .+8             ; 0x2102 <disk_initialize+0x1a6>
                Stat &= ~STA_NOINIT;            /* Clear STA_NOINIT */
    20fa:       80 91 04 01     lds     r24, 0x0104
    20fe:       8e 7f           andi    r24, 0xFE       ; 254
    2100:       03 c0           rjmp    .+6             ; 0x2108 <disk_initialize+0x1ac>
        } else {                        /* Initialization failed */
                Stat |=  STA_NOINIT;            /* Set STA_NOINIT */
    2102:       80 91 04 01     lds     r24, 0x0104
    2106:       81 60           ori     r24, 0x01       ; 1
    2108:       80 93 04 01     sts     0x0104, r24
        }

        return Stat;
    210c:       80 91 04 01     lds     r24, 0x0104
    2110:       99 27           eor     r25, r25
    2112:       e6 e0           ldi     r30, 0x06       ; 6
    2114:       24 96           adiw    r28, 0x04       ; 4
    2116:       0c 94 52 11     jmp     0x22a4  ; 0x22a4 <__epilogue_restores__+0x18>

0000211a <strcpy_P>:
    211a:       fb 01           movw    r30, r22
    211c:       dc 01           movw    r26, r24
    211e:       05 90           lpm     r0, Z+
    2120:       0d 92           st      X+, r0
    2122:       00 20           and     r0, r0
    2124:       e1 f7           brne    .-8             ; 0x211e <strcpy_P+0x4>
    2126:       08 95           ret

00002128 <memcmp>:
    2128:       fb 01           movw    r30, r22
    212a:       dc 01           movw    r26, r24
    212c:       04 c0           rjmp    .+8             ; 0x2136 <memcmp+0xe>
    212e:       8d 91           ld      r24, X+
    2130:       01 90           ld      r0, Z+
    2132:       80 19           sub     r24, r0
    2134:       21 f4           brne    .+8             ; 0x213e <memcmp+0x16>
    2136:       41 50           subi    r20, 0x01       ; 1
    2138:       50 40           sbci    r21, 0x00       ; 0
    213a:       c8 f7           brcc    .-14            ; 0x212e <memcmp+0x6>
    213c:       88 1b           sub     r24, r24
    213e:       99 0b           sbc     r25, r25
    2140:       08 95           ret

00002142 <memcpy>:
    2142:       fb 01           movw    r30, r22
    2144:       dc 01           movw    r26, r24
    2146:       02 c0           rjmp    .+4             ; 0x214c <memcpy+0xa>
    2148:       01 90           ld      r0, Z+
    214a:       0d 92           st      X+, r0
    214c:       41 50           subi    r20, 0x01       ; 1
    214e:       50 40           sbci    r21, 0x00       ; 0
    2150:       d8 f7           brcc    .-10            ; 0x2148 <memcpy+0x6>
    2152:       08 95           ret

00002154 <memset>:
    2154:       dc 01           movw    r26, r24
    2156:       01 c0           rjmp    .+2             ; 0x215a <memset+0x6>
    2158:       6d 93           st      X+, r22
    215a:       41 50           subi    r20, 0x01       ; 1
    215c:       50 40           sbci    r21, 0x00       ; 0
    215e:       e0 f7           brcc    .-8             ; 0x2158 <memset+0x4>
    2160:       08 95           ret

00002162 <strcpy>:
    2162:       fb 01           movw    r30, r22
    2164:       dc 01           movw    r26, r24
    2166:       01 90           ld      r0, Z+
    2168:       0d 92           st      X+, r0
    216a:       00 20           and     r0, r0
    216c:       e1 f7           brne    .-8             ; 0x2166 <strcpy+0x4>
    216e:       08 95           ret

00002170 <itoa>:
    2170:       fb 01           movw    r30, r22
    2172:       9f 01           movw    r18, r30
    2174:       e8 94           clt
    2176:       42 30           cpi     r20, 0x02       ; 2
    2178:       c4 f0           brlt    .+48            ; 0x21aa <itoa+0x3a>
    217a:       45 32           cpi     r20, 0x25       ; 37
    217c:       b4 f4           brge    .+44            ; 0x21aa <itoa+0x3a>
    217e:       4a 30           cpi     r20, 0x0A       ; 10
    2180:       29 f4           brne    .+10            ; 0x218c <itoa+0x1c>
    2182:       97 fb           bst     r25, 7
    2184:       1e f4           brtc    .+6             ; 0x218c <itoa+0x1c>
    2186:       90 95           com     r25
    2188:       81 95           neg     r24
    218a:       9f 4f           sbci    r25, 0xFF       ; 255
    218c:       64 2f           mov     r22, r20
    218e:       77 27           eor     r23, r23
    2190:       0e 94 61 11     call    0x22c2  ; 0x22c2 <__udivmodhi4>
    2194:       80 5d           subi    r24, 0xD0       ; 208
    2196:       8a 33           cpi     r24, 0x3A       ; 58
    2198:       0c f0           brlt    .+2             ; 0x219c <itoa+0x2c>
    219a:       89 5d           subi    r24, 0xD9       ; 217
    219c:       81 93           st      Z+, r24
    219e:       cb 01           movw    r24, r22
    21a0:       00 97           sbiw    r24, 0x00       ; 0
    21a2:       a1 f7           brne    .-24            ; 0x218c <itoa+0x1c>
    21a4:       16 f4           brtc    .+4             ; 0x21aa <itoa+0x3a>
    21a6:       5d e2           ldi     r21, 0x2D       ; 45
    21a8:       51 93           st      Z+, r21
    21aa:       10 82           st      Z, r1
    21ac:       c9 01           movw    r24, r18
    21ae:       0c 94 d9 10     jmp     0x21b2  ; 0x21b2 <strrev>

000021b2 <strrev>:
    21b2:       dc 01           movw    r26, r24
    21b4:       fc 01           movw    r30, r24
    21b6:       67 2f           mov     r22, r23
    21b8:       71 91           ld      r23, Z+
    21ba:       77 23           and     r23, r23
    21bc:       e1 f7           brne    .-8             ; 0x21b6 <strrev+0x4>
    21be:       32 97           sbiw    r30, 0x02       ; 2
    21c0:       04 c0           rjmp    .+8             ; 0x21ca <strrev+0x18>
    21c2:       7c 91           ld      r23, X
    21c4:       6d 93           st      X+, r22
    21c6:       70 83           st      Z, r23
    21c8:       62 91           ld      r22, -Z
    21ca:       ae 17           cp      r26, r30
    21cc:       bf 07           cpc     r27, r31
    21ce:       c8 f3           brcs    .-14            ; 0x21c2 <strrev+0x10>
    21d0:       08 95           ret

000021d2 <__mulsi3>:
    21d2:       62 9f           mul     r22, r18
    21d4:       d0 01           movw    r26, r0
    21d6:       73 9f           mul     r23, r19
    21d8:       f0 01           movw    r30, r0
    21da:       82 9f           mul     r24, r18
    21dc:       e0 0d           add     r30, r0
    21de:       f1 1d           adc     r31, r1
    21e0:       64 9f           mul     r22, r20
    21e2:       e0 0d           add     r30, r0
    21e4:       f1 1d           adc     r31, r1
    21e6:       92 9f           mul     r25, r18
    21e8:       f0 0d           add     r31, r0
    21ea:       83 9f           mul     r24, r19
    21ec:       f0 0d           add     r31, r0
    21ee:       74 9f           mul     r23, r20
    21f0:       f0 0d           add     r31, r0
    21f2:       65 9f           mul     r22, r21
    21f4:       f0 0d           add     r31, r0
    21f6:       99 27           eor     r25, r25
    21f8:       72 9f           mul     r23, r18
    21fa:       b0 0d           add     r27, r0
    21fc:       e1 1d           adc     r30, r1
    21fe:       f9 1f           adc     r31, r25
    2200:       63 9f           mul     r22, r19
    2202:       b0 0d           add     r27, r0
    2204:       e1 1d           adc     r30, r1
    2206:       f9 1f           adc     r31, r25
    2208:       bd 01           movw    r22, r26
    220a:       cf 01           movw    r24, r30
    220c:       11 24           eor     r1, r1
    220e:       08 95           ret

00002210 <__udivmodsi4>:
    2210:       a1 e2           ldi     r26, 0x21       ; 33
    2212:       1a 2e           mov     r1, r26
    2214:       aa 1b           sub     r26, r26
    2216:       bb 1b           sub     r27, r27
    2218:       fd 01           movw    r30, r26
    221a:       0d c0           rjmp    .+26            ; 0x2236 <__udivmodsi4_ep>

0000221c <__udivmodsi4_loop>:
    221c:       aa 1f           adc     r26, r26
    221e:       bb 1f           adc     r27, r27
    2220:       ee 1f           adc     r30, r30
    2222:       ff 1f           adc     r31, r31
    2224:       a2 17           cp      r26, r18
    2226:       b3 07           cpc     r27, r19
    2228:       e4 07           cpc     r30, r20
    222a:       f5 07           cpc     r31, r21
    222c:       20 f0           brcs    .+8             ; 0x2236 <__udivmodsi4_ep>
    222e:       a2 1b           sub     r26, r18
    2230:       b3 0b           sbc     r27, r19
    2232:       e4 0b           sbc     r30, r20
    2234:       f5 0b           sbc     r31, r21

00002236 <__udivmodsi4_ep>:
    2236:       66 1f           adc     r22, r22
    2238:       77 1f           adc     r23, r23
    223a:       88 1f           adc     r24, r24
    223c:       99 1f           adc     r25, r25
    223e:       1a 94           dec     r1
    2240:       69 f7           brne    .-38            ; 0x221c <__udivmodsi4_loop>
    2242:       60 95           com     r22
    2244:       70 95           com     r23
    2246:       80 95           com     r24
    2248:       90 95           com     r25
    224a:       9b 01           movw    r18, r22
    224c:       ac 01           movw    r20, r24
    224e:       bd 01           movw    r22, r26
    2250:       cf 01           movw    r24, r30
    2252:       08 95           ret

00002254 <__prologue_saves__>:
    2254:       2f 92           push    r2
    2256:       3f 92           push    r3
    2258:       4f 92           push    r4
    225a:       5f 92           push    r5
    225c:       6f 92           push    r6
    225e:       7f 92           push    r7
    2260:       8f 92           push    r8
    2262:       9f 92           push    r9
    2264:       af 92           push    r10
    2266:       bf 92           push    r11
    2268:       cf 92           push    r12
    226a:       df 92           push    r13
    226c:       ef 92           push    r14
    226e:       ff 92           push    r15
    2270:       0f 93           push    r16
    2272:       1f 93           push    r17
    2274:       cf 93           push    r28
    2276:       df 93           push    r29
    2278:       cd b7           in      r28, 0x3d       ; 61
    227a:       de b7           in      r29, 0x3e       ; 62
    227c:       ca 1b           sub     r28, r26
    227e:       db 0b           sbc     r29, r27
    2280:       0f b6           in      r0, 0x3f        ; 63
    2282:       f8 94           cli
    2284:       de bf           out     0x3e, r29       ; 62
    2286:       0f be           out     0x3f, r0        ; 63
    2288:       cd bf           out     0x3d, r28       ; 61
    228a:       09 94           ijmp

0000228c <__epilogue_restores__>:
    228c:       2a 88           ldd     r2, Y+18        ; 0x12
    228e:       39 88           ldd     r3, Y+17        ; 0x11
    2290:       48 88           ldd     r4, Y+16        ; 0x10
    2292:       5f 84           ldd     r5, Y+15        ; 0x0f
    2294:       6e 84           ldd     r6, Y+14        ; 0x0e
    2296:       7d 84           ldd     r7, Y+13        ; 0x0d
    2298:       8c 84           ldd     r8, Y+12        ; 0x0c
    229a:       9b 84           ldd     r9, Y+11        ; 0x0b
    229c:       aa 84           ldd     r10, Y+10       ; 0x0a
    229e:       b9 84           ldd     r11, Y+9        ; 0x09
    22a0:       c8 84           ldd     r12, Y+8        ; 0x08
    22a2:       df 80           ldd     r13, Y+7        ; 0x07
    22a4:       ee 80           ldd     r14, Y+6        ; 0x06
    22a6:       fd 80           ldd     r15, Y+5        ; 0x05
    22a8:       0c 81           ldd     r16, Y+4        ; 0x04
    22aa:       1b 81           ldd     r17, Y+3        ; 0x03
    22ac:       aa 81           ldd     r26, Y+2        ; 0x02
    22ae:       b9 81           ldd     r27, Y+1        ; 0x01
    22b0:       ce 0f           add     r28, r30
    22b2:       d1 1d           adc     r29, r1
    22b4:       0f b6           in      r0, 0x3f        ; 63
    22b6:       f8 94           cli
    22b8:       de bf           out     0x3e, r29       ; 62
    22ba:       0f be           out     0x3f, r0        ; 63
    22bc:       cd bf           out     0x3d, r28       ; 61
    22be:       ed 01           movw    r28, r26
    22c0:       08 95           ret

000022c2 <__udivmodhi4>:
    22c2:       aa 1b           sub     r26, r26
    22c4:       bb 1b           sub     r27, r27
    22c6:       51 e1           ldi     r21, 0x11       ; 17
    22c8:       07 c0           rjmp    .+14            ; 0x22d8 <__udivmodhi4_ep>

000022ca <__udivmodhi4_loop>:
    22ca:       aa 1f           adc     r26, r26
    22cc:       bb 1f           adc     r27, r27
    22ce:       a6 17           cp      r26, r22
    22d0:       b7 07           cpc     r27, r23
    22d2:       10 f0           brcs    .+4             ; 0x22d8 <__udivmodhi4_ep>
    22d4:       a6 1b           sub     r26, r22
    22d6:       b7 0b           sbc     r27, r23

000022d8 <__udivmodhi4_ep>:
    22d8:       88 1f           adc     r24, r24
    22da:       99 1f           adc     r25, r25
    22dc:       5a 95           dec     r21
    22de:       a9 f7           brne    .-22            ; 0x22ca <__udivmodhi4_loop>
    22e0:       80 95           com     r24
    22e2:       90 95           com     r25
    22e4:       bc 01           movw    r22, r24
    22e6:       cd 01           movw    r24, r26
    22e8:       08 95           ret

000022ea <_exit>:
    22ea:       ff cf           rjmp    .-2             ; 0x22ea <_exit>