
_Blink:

;SD.mpas,30 :: 		begin
;SD.mpas,31 :: 		for ctr := 1 to times do begin
	MOVLW       1
	MOVWF       R1 
L__Blink1:
	MOVF        R1, 0 
	SUBWF       FARG_Blink_times+0, 0 
	BTFSS       STATUS+0, 0 
	GOTO        L__Blink5
;SD.mpas,32 :: 		LED := 1;
	BSF         LATC2_bit+0, 2 
;SD.mpas,33 :: 		delay_ms(500);
	MOVLW       31
	MOVWF       R11, 0
	MOVLW       113
	MOVWF       R12, 0
	MOVLW       30
	MOVWF       R13, 0
L__Blink6:
	DECFSZ      R13, 1, 1
	BRA         L__Blink6
	DECFSZ      R12, 1, 1
	BRA         L__Blink6
	DECFSZ      R11, 1, 1
	BRA         L__Blink6
	NOP
;SD.mpas,34 :: 		LED := 0;
	BCF         LATC2_bit+0, 2 
;SD.mpas,35 :: 		delay_ms(500);
	MOVLW       31
	MOVWF       R11, 0
	MOVLW       113
	MOVWF       R12, 0
	MOVLW       30
	MOVWF       R13, 0
L__Blink7:
	DECFSZ      R13, 1, 1
	BRA         L__Blink7
	DECFSZ      R12, 1, 1
	BRA         L__Blink7
	DECFSZ      R11, 1, 1
	BRA         L__Blink7
	NOP
;SD.mpas,36 :: 		end;
	MOVF        R1, 0 
	XORWF       FARG_Blink_times+0, 0 
	BTFSC       STATUS+0, 2 
	GOTO        L__Blink5
	INCF        R1, 1 
	GOTO        L__Blink1
L__Blink5:
;SD.mpas,37 :: 		end;
L_end_Blink:
	RETURN      0
; end of _Blink

_main:

;SD.mpas,39 :: 		begin
;SD.mpas,40 :: 		OSCCON := %01110000;            //8MHz
	MOVLW       112
	MOVWF       OSCCON+0 
;SD.mpas,41 :: 		PLLEn_bit := 1;                 //Enable PLL (now 48MHz)
	BSF         PLLEN_bit+0, 6 
;SD.mpas,42 :: 		TRISC2_bit := 0;                //Make PortC.2 an output
	BCF         TRISC2_bit+0, 2 
;SD.mpas,43 :: 		LED := 0;                       //Switch the LED off
	BCF         LATC2_bit+0, 2 
;SD.mpas,44 :: 		PCFG10_bit := 1;                //Make PortB.1 digital (not analogue)
	BSF         PCFG10_bit+0, 2 
;SD.mpas,45 :: 		RBPU_bit := 0;                  //Enable weak pull-ups on PortB
	BCF         RBPU_bit+0, 7 
;SD.mpas,46 :: 		MMC_CD_dir := 1;                //Make MMC_CD (PortB.1) an input
	BSF         TRISB1_bit+0, 1 
;SD.mpas,49 :: 		if MMC_CD = 0 then begin
	BTFSC       RB1_bit+0, 1 
	GOTO        L__main10
;SD.mpas,51 :: 		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.mpas,53 :: 		init_result := MMC_FAT_Init();
	CALL        _Mmc_Fat_Init+0, 0
	MOVF        R0, 0 
	MOVWF       _init_result+0 
;SD.mpas,54 :: 		if init_result = 0 then begin
	MOVF        R0, 0 
	XORLW       0
	BTFSS       STATUS+0, 2 
	GOTO        L__main13
;SD.mpas,56 :: 		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.mpas,58 :: 		if MMC_Fat_Assign('test.txt', 0x80) = 1 then begin
	MOVLW       116
	MOVWF       ?LocalText_main+0 
	MOVLW       101
	MOVWF       ?LocalText_main+1 
	MOVLW       115
	MOVWF       ?LocalText_main+2 
	MOVLW       116
	MOVWF       ?LocalText_main+3 
	MOVLW       46
	MOVWF       ?LocalText_main+4 
	MOVLW       116
	MOVWF       ?LocalText_main+5 
	MOVLW       120
	MOVWF       ?LocalText_main+6 
	MOVLW       116
	MOVWF       ?LocalText_main+7 
	CLRF        ?LocalText_main+8 
	MOVLW       ?LocalText_main+0
	MOVWF       FARG_Mmc_Fat_Assign_name+0 
	MOVLW       hi_addr(?LocalText_main+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__main16
;SD.mpas,60 :: 		MMC_Fat_Append();
	CALL        _Mmc_Fat_Append+0, 0
;SD.mpas,62 :: 		Mmc_Fat_Write('www.dizzy.co.za' + chr(13) + chr(10), 17);
	MOVLW       119
	MOVWF       ?LocalText_main+0 
	MOVLW       119
	MOVWF       ?LocalText_main+1 
	MOVLW       119
	MOVWF       ?LocalText_main+2 
	MOVLW       46
	MOVWF       ?LocalText_main+3 
	MOVLW       100
	MOVWF       ?LocalText_main+4 
	MOVLW       105
	MOVWF       ?LocalText_main+5 
	MOVLW       122
	MOVWF       ?LocalText_main+6 
	MOVLW       122
	MOVWF       ?LocalText_main+7 
	MOVLW       121
	MOVWF       ?LocalText_main+8 
	MOVLW       46
	MOVWF       ?LocalText_main+9 
	MOVLW       99
	MOVWF       ?LocalText_main+10 
	MOVLW       111
	MOVWF       ?LocalText_main+11 
	MOVLW       46
	MOVWF       ?LocalText_main+12 
	MOVLW       122
	MOVWF       ?LocalText_main+13 
	MOVLW       97
	MOVWF       ?LocalText_main+14 
	MOVLW       13
	MOVWF       ?LocalText_main+15 
	MOVLW       10
	MOVWF       ?LocalText_main+16 
	MOVLW       0
	MOVWF       ?LocalText_main+17 
	MOVLW       ?LocalText_main+0
	MOVWF       FARG_Mmc_Fat_Write_fdata+0 
	MOVLW       hi_addr(?LocalText_main+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.mpas,64 :: 		MMC_Fat_Close();
	CALL        _Mmc_Fat_Close+0, 0
;SD.mpas,66 :: 		LED := 1;
	BSF         LATC2_bit+0, 2 
;SD.mpas,67 :: 		end else begin
	GOTO        L__main17
L__main16:
;SD.mpas,68 :: 		Blink(4); //File opening/creation error
	MOVLW       4
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.mpas,69 :: 		end;
L__main17:
;SD.mpas,70 :: 		end else begin
	GOTO        L__main14
L__main13:
;SD.mpas,71 :: 		if init_result = 255 then begin
	MOVF        _init_result+0, 0 
	XORLW       255
	BTFSS       STATUS+0, 2 
	GOTO        L__main19
;SD.mpas,72 :: 		Blink(2); //Initialisation error
	MOVLW       2
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.mpas,73 :: 		end else begin
	GOTO        L__main20
L__main19:
;SD.mpas,74 :: 		Blink(3); //FAT16 error
	MOVLW       3
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.mpas,75 :: 		end;
L__main20:
;SD.mpas,76 :: 		end;
L__main14:
;SD.mpas,77 :: 		end else begin
	GOTO        L__main11
L__main10:
;SD.mpas,78 :: 		Blink(1); //Card not inserted
	MOVLW       1
	MOVWF       FARG_Blink_times+0 
	CALL        _Blink+0, 0
;SD.mpas,79 :: 		end;
L__main11:
;SD.mpas,80 :: 		end.
L_end_main:
	GOTO        $+0
; end of _main
