
_Blink:

;SD.mbas,27 :: 		dim ctr as byte
;SD.mbas,28 :: 		for ctr = 1 to times
	MOVLW       1
	MOVWF       R1 
L__Blink1:
	MOVF        R1, 0 
	SUBWF       FARG_Blink_times+0, 0 
	BTFSS       STATUS+0, 0 
	GOTO        L__Blink5
;SD.mbas,29 :: 		LED = 1
	BSF         LATC2_bit+0, BitPos(LATC2_bit+0) 
;SD.mbas,30 :: 		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.mbas,31 :: 		LED = 0
	BCF         LATC2_bit+0, BitPos(LATC2_bit+0) 
;SD.mbas,32 :: 		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.mbas,33 :: 		next ctr
	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.mbas,34 :: 		end sub
L_end_Blink:
	RETURN      0
; end of _Blink

_main:

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