
_Blink:

;SD.c,26 :: 		void Blink(char times) {
;SD.c,28 :: 		for (ctr=1;ctr<=times;ctr++) {
	MOVLW       1
	MOVWF       R1 
L_Blink0:
	MOVF        R1, 0 
	SUBWF       FARG_Blink_times+0, 0 
	BTFSS       STATUS+0, 0 
	GOTO        L_Blink1
;SD.c,29 :: 		LED = 1;
	BSF         LATC2_bit+0, BitPos(LATC2_bit+0) 
;SD.c,30 :: 		delay_ms(500);
	MOVLW       31
	MOVWF       R11, 0
	MOVLW       113
	MOVWF       R12, 0
	MOVLW       30
	MOVWF       R13, 0
L_Blink3:
	DECFSZ      R13, 1, 1
	BRA         L_Blink3
	DECFSZ      R12, 1, 1
	BRA         L_Blink3
	DECFSZ      R11, 1, 1
	BRA         L_Blink3
	NOP
;SD.c,31 :: 		LED = 0;
	BCF         LATC2_bit+0, BitPos(LATC2_bit+0) 
;SD.c,32 :: 		delay_ms(500);
	MOVLW       31
	MOVWF       R11, 0
	MOVLW       113
	MOVWF       R12, 0
	MOVLW       30
	MOVWF       R13, 0
L_Blink4:
	DECFSZ      R13, 1, 1
	BRA         L_Blink4
	DECFSZ      R12, 1, 1
	BRA         L_Blink4
	DECFSZ      R11, 1, 1
	BRA         L_Blink4
	NOP
;SD.c,28 :: 		for (ctr=1;ctr<=times;ctr++) {
	INCF        R1, 1 
;SD.c,33 :: 		}
	GOTO        L_Blink0
L_Blink1:
;SD.c,34 :: 		}
L_end_Blink:
	RETURN      0
; end of _Blink

_main:

;SD.c,36 :: 		void main() {
;SD.c,37 :: 		OSCCON = 0b01110000;          //8MHz
	MOVLW       112
	MOVWF       OSCCON+0 
;SD.c,38 :: 		PLLEn_bit = 1;                //Enable PLL (now 48MHz)
	BSF         PLLEN_bit+0, BitPos(PLLEN_bit+0) 
;SD.c,39 :: 		TRISC2_bit = 0;               //Make PortC.2 an output
	BCF         TRISC2_bit+0, BitPos(TRISC2_bit+0) 
;SD.c,40 :: 		LED = 0;                      //Switch the LED off
	BCF         LATC2_bit+0, BitPos(LATC2_bit+0) 
;SD.c,41 :: 		PCFG10_bit = 1;               //Make PortB.1 digital (not analogue)
	BSF         PCFG10_bit+0, BitPos(PCFG10_bit+0) 
;SD.c,42 :: 		RBPU_bit = 0;                 //Enable weak pull-ups on PortB
	BCF         RBPU_bit+0, BitPos(RBPU_bit+0) 
;SD.c,43 :: 		MMC_CD_dir = 1;               //Make MMC_CD (PortB.1) an input
	BSF         TRISB1_bit+0, BitPos(TRISB1_bit+0) 
;SD.c,46 :: 		if (MMC_CD == 0) {
	BTFSC       RB1_bit+0, BitPos(RB1_bit+0) 
	GOTO        L_main5
;SD.c,48 :: 		SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
	MOVLW       2
	MOVWF       FARG_SPI1_Init_Advanced_master+0 
	CLRF        FARG_SPI1_Init_Advanced_data_sample+0 
	CLRF        FARG_SPI1_Init_Advanced_clock_idle+0 
	MOVLW       1
	MOVWF       FARG_SPI1_Init_Advanced_transmit_edge+0 
	CALL        _SPI1_Init_Advanced+0, 0
;SD.c,50 :: 		init_result = MMC_FAT_Init();
	CALL        _Mmc_Fat_Init+0, 0
	MOVF        R0, 0 
	MOVWF       _init_result+0 
;SD.c,51 :: 		if (init_result == 0) {
	MOVF        R0, 0 
	XORLW       0
	BTFSS       STATUS+0, 2 
	GOTO        L_main6
;SD.c,53 :: 		SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
	CLRF        FARG_SPI1_Init_Advanced_master+0 
	CLRF        FARG_SPI1_Init_Advanced_data_sample+0 
	CLRF        FARG_SPI1_Init_Advanced_clock_idle+0 
	MOVLW       1
	MOVWF       FARG_SPI1_Init_Advanced_transmit_edge+0 
	CALL        _SPI1_Init_Advanced+0, 0
;SD.c,55 :: 		if (MMC_Fat_Assign("test.txt", 0x80) == 1) {
	MOVLW       ?lstr1_SD+0
	MOVWF       FARG_Mmc_Fat_Assign_name+0 
	MOVLW       hi_addr(?lstr1_SD+0)
	MOVWF       FARG_Mmc_Fat_Assign_name+1 
	MOVLW       128
	MOVWF       FARG_Mmc_Fat_Assign_attrib+0 
	CALL        _Mmc_Fat_Assign+0, 0
	MOVF        R0, 0 
	XORLW       1
	BTFSS       STATUS+0, 2 
	GOTO        L_main7
;SD.c,57 :: 		MMC_Fat_Append();
	CALL        _Mmc_Fat_Append+0, 0
;SD.c,59 :: 		Mmc_Fat_Write("www.dizzy.co.za" "\x0D" "\x0A", 17);
	MOVLW       ?lstr2_SD+0
	MOVWF       FARG_Mmc_Fat_Write_fdata+0 
	MOVLW       hi_addr(?lstr2_SD+0)
	MOVWF       FARG_Mmc_Fat_Write_fdata+1 
	MOVLW       17
	MOVWF       FARG_Mmc_Fat_Write_len+0 
	MOVLW       0
	MOVWF       FARG_Mmc_Fat_Write_len+1 
	CALL        _Mmc_Fat_Write+0, 0
;SD.c,63 :: 		LED = 1;
	BSF         LATC2_bit+0, BitPos(LATC2_bit+0) 
;SD.c,64 :: 		} else {
	GOTO        L_main8
L_main7:
;SD.c,65 :: 		Blink(4); //File opening/creation error
	MOVLW       4
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.c,66 :: 		}
L_main8:
;SD.c,67 :: 		} else {
	GOTO        L_main9
L_main6:
;SD.c,68 :: 		if (init_result == 255) {
	MOVF        _init_result+0, 0 
	XORLW       255
	BTFSS       STATUS+0, 2 
	GOTO        L_main10
;SD.c,69 :: 		Blink(2); //Initialisation error
	MOVLW       2
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.c,70 :: 		} else {
	GOTO        L_main11
L_main10:
;SD.c,71 :: 		Blink(3); //FAT16 error
	MOVLW       3
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.c,72 :: 		}
L_main11:
;SD.c,73 :: 		}
L_main9:
;SD.c,74 :: 		} else {
	GOTO        L_main12
L_main5:
;SD.c,75 :: 		Blink(1); //Card not inserted
	MOVLW       1
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.c,76 :: 		}
L_main12:
;SD.c,77 :: 		}
L_end_main:
	GOTO        $+0
; end of _main
