;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 2.8.0 #5117 (Aug  1 2016) (UNIX)
; This file was generated Mon Aug  1 17:09:27 2016
;--------------------------------------------------------
; PIC16 port for the Microchip 16-bit core micros
;--------------------------------------------------------
	list	p=18f452

	radix dec

;--------------------------------------------------------
; public variables in this module
;--------------------------------------------------------
	global _crc16
	global _crc_table

;--------------------------------------------------------
; extern variables in this module
;--------------------------------------------------------
	extern __gptrget1
	extern __mulint
;--------------------------------------------------------
;	Equates to used internal registers
;--------------------------------------------------------
STATUS	equ	0xfd8
WREG	equ	0xfe8
TBLPTRL	equ	0xff6
TBLPTRH	equ	0xff7
TBLPTRU	equ	0xff8
TABLAT	equ	0xff5
FSR0L	equ	0xfe9
FSR1L	equ	0xfe1
FSR2L	equ	0xfd9
POSTDEC1	equ	0xfe5
PREINC1	equ	0xfe4
PLUSW2	equ	0xfdb
PRODL	equ	0xff3


; Internal registers
.registers	udata_ovr	0x0000
r0x00	res	1
r0x01	res	1
r0x02	res	1
r0x03	res	1
r0x04	res	1
r0x05	res	1
r0x06	res	1
r0x07	res	1
r0x08	res	1
r0x09	res	1
r0x0a	res	1
r0x0b	res	1
r0x0c	res	1

;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; I code from now on!
; ; Starting pCode block
; ;ic:1:  _entry($5) :
; ;ic:2: 	proc _crc16 [k1 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int function    ( unsigned-char generic* , unsigned-long-int, unsigned-int) }
S_crc16__crc16	code
_crc16:
;	.line	95; crc16.c	uint16_t crc16(uint8_t *data, uint32_t size, uint16_t crc)
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVFF	r0x05, POSTDEC1
	MOVFF	r0x06, POSTDEC1
	MOVFF	r0x07, POSTDEC1
	MOVFF	r0x08, POSTDEC1
	MOVFF	r0x09, POSTDEC1
	MOVFF	r0x0a, POSTDEC1
	MOVFF	r0x0b, POSTDEC1
	MOVFF	r0x0c, POSTDEC1
; ;ic:3: iTemp0 [k2 lr3:8 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-char generic* }{ sir@ _crc16_data_1_1}[r0x00 r0x01 r0x02 ] = recv _crc16 [k1 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int function    ( unsigned-char generic* , unsigned-long-int, unsigned-int) }
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	MOVLW	0x03
	MOVFF	PLUSW2, r0x01
	MOVLW	0x04
	MOVFF	PLUSW2, r0x02
; ;ic:4: iTemp1 [k4 lr4:9 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-long-int}{ sir@ _crc16_size_1_1}[r0x03 r0x04 r0x05 r0x06 ] = recv _crc16 [k1 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int function    ( unsigned-char generic* , unsigned-long-int, unsigned-int) }
	MOVLW	0x05
	MOVFF	PLUSW2, r0x03
	MOVLW	0x06
	MOVFF	PLUSW2, r0x04
	MOVLW	0x07
	MOVFF	PLUSW2, r0x05
	MOVLW	0x08
	MOVFF	PLUSW2, r0x06
; ;ic:5: iTemp2 [k6 lr5:30 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-int}{ sir@ _crc16_crc_1_1}[r0x07 r0x08 ] = recv _crc16 [k1 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int function    ( unsigned-char generic* , unsigned-long-int, unsigned-int) }
	MOVLW	0x09
	MOVFF	PLUSW2, r0x07
	MOVLW	0x0a
	MOVFF	PLUSW2, r0x08
; ;ic:7: 	iTemp5 [k11 lr7:27 so:0]{ ia0 a2p0 re0 rm1 nos0 ru0 dp0}{const-unsigned-int code-code* }[remat] = &[_crc_table [k10 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{const-unsigned-int code-[256] }]
; ;ic:8: 	iTemp8 [k14 lr8:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-char generic* }[r0x00 r0x01 r0x02 ] := iTemp0 [k2 lr3:8 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-char generic* }{ sir@ _crc16_data_1_1}[r0x00 r0x01 r0x02 ]
; ;ic:9: 	iTemp4 [k9 lr9:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-long-int}[r0x03 r0x04 r0x05 r0x06 ] := iTemp1 [k4 lr4:9 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-long-int}{ sir@ _crc16_size_1_1}[r0x03 r0x04 r0x05 r0x06 ]
; ;ic:10:  _whilecontinue_0($1) :
; ;ic:11: 	iTemp3 [k8 lr11:13 so:0]{ ia0 a2p0 re0 rm0 nos1 ru0 dp0}{unsigned-long-int}[r0x09 r0x0a r0x0b r0x0c ] := iTemp4 [k9 lr9:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-long-int}[r0x03 r0x04 r0x05 r0x06 ]
_00105_DS_:
;	.line	97; crc16.c	while (size--)
	MOVFF	r0x03, r0x09
	MOVFF	r0x04, r0x0a
	MOVFF	r0x05, r0x0b
	MOVFF	r0x06, r0x0c
; ;ic:12: 	iTemp4 [k9 lr9:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-long-int}[r0x03 r0x04 r0x05 r0x06 ] = iTemp4 [k9 lr9:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-long-int}[r0x03 r0x04 r0x05 r0x06 ] - 0x1 {literal-unsigned-char}
	MOVLW	0xff
	ADDWF	r0x03, F
	ADDWFC	r0x04, F
	ADDWFC	r0x05, F
	ADDWFC	r0x06, F
; ;ic:13: 	if iTemp3 [k8 lr11:13 so:0]{ ia0 a2p0 re0 rm0 nos1 ru0 dp0}{unsigned-long-int}[r0x09 r0x0a r0x0b r0x0c ] == 0 goto _whilebreak_0($3)
	MOVF	r0x09, W
	IORWF	r0x0a, W
	IORWF	r0x0b, W
	IORWF	r0x0c, W
	BZ	_00107_DS_
; ;ic:14: 	iTemp6 [k12 lr14:18 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ] = iTemp2 [k6 lr5:30 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-int}{ sir@ _crc16_crc_1_1}[r0x07 r0x08 ] >> 0x8 {literal-unsigned-char}
;	.line	98; crc16.c	crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8);
	MOVF	r0x08, W
	MOVWF	r0x09
; ;ic:15: 	iTemp9 [k15 lr15:17 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-char}[r0x0b ] = @[iTemp8 [k14 lr8:27 so:0]{ ia1 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-char generic* }[r0x00 r0x01 r0x02 ]]
	MOVFF	r0x00, FSR0L
	MOVFF	r0x01, PRODL
	MOVF	r0x02, W
	CALL	__gptrget1
	MOVWF	r0x0b
; ;ic:16: 	iTemp8 [k14 lr8:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-char generic* }[r0x00 r0x01 r0x02 ] = iTemp8 [k14 lr8:27 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-char generic* }[r0x00 r0x01 r0x02 ] + 0x1 {literal-unsigned-char}
	INCF	r0x00, F
	BTFSC	STATUS, 0
	INCF	r0x01, F
	BTFSC	STATUS, 0
	INCF	r0x02, F
; ;ic:17: 	iTemp10 [k16 lr17:18 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x0b r0x0c ] = (unsigned-int)iTemp9 [k15 lr15:17 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-char}[r0x0b ]
; ;ic:18: 	iTemp11 [k17 lr18:19 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ] = iTemp6 [k12 lr14:18 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ] ^ iTemp10 [k16 lr17:18 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x0b r0x0c ]
	MOVF	r0x0b, W
	XORWF	r0x09, F
; ;ic:19: 	iTemp12 [k18 lr19:21 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ] = iTemp11 [k17 lr18:19 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ] & 0xff {literal-unsigned-int}
; ;ic:20: 	send 0x2 {literal-unsigned-int}{argreg = 1}
; ;ic:21: 	send iTemp12 [k18 lr19:21 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ]{argreg = 2}
; ;ic:22: 	iTemp13 [k19 lr22:23 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ] = call __mulint [k24 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{int function    ( int, int) }
	CLRF	POSTDEC1
	MOVF	r0x09, W
	MOVWF	POSTDEC1
	CLRF	POSTDEC1
	MOVLW	0x02
	MOVWF	POSTDEC1
	CALL	__mulint
	MOVWF	r0x09
	MOVFF	PRODL, r0x0a
	MOVLW	0x04
	ADDWF	FSR1L, F
; ;ic:23: 	iTemp14 [k20 lr23:24 so:0]{ ia1 a2p0 re0 rm0 nos0 ru0 dp0}{const-unsigned-int code-code* }[r0x09 r0x0a r0x0b ] = iTemp5 [k11 lr7:27 so:0]{ ia0 a2p0 re0 rm1 nos0 ru0 dp0}{const-unsigned-int code-code* }[remat] + iTemp13 [k19 lr22:23 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x09 r0x0a ]
	CLRF	r0x0b
	MOVLW	LOW(_crc_table)
	ADDWF	r0x09, F
	MOVLW	HIGH(_crc_table)
	ADDWFC	r0x0a, F
	MOVLW	UPPER(_crc_table)
	ADDWFC	r0x0b, F
; ;ic:24: 	iTemp15 [k21 lr24:26 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{code-const-unsigned-int}[r0x09 r0x0a ] = @[iTemp14 [k20 lr23:24 so:0]{ ia1 a2p0 re0 rm0 nos0 ru0 dp0}{const-unsigned-int code-code* }[r0x09 r0x0a r0x0b ]]
	MOVFF	r0x09, TBLPTRL
	MOVFF	r0x0a, TBLPTRH
	MOVFF	r0x0b, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x09
	TBLRD*+	
	MOVFF	TABLAT, r0x0a
; ;ic:25: 	iTemp16 [k22 lr25:26 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x0b r0x0c ] = iTemp2 [k6 lr5:30 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-int}{ sir@ _crc16_crc_1_1}[r0x07 r0x08 ] << 0x8 {literal-unsigned-char}
	MOVF	r0x07, W
	MOVWF	r0x0c
	CLRF	r0x0b
; ;ic:26: 	iTemp2 [k6 lr5:30 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-int}{ sir@ _crc16_crc_1_1}[r0x07 r0x08 ] = iTemp15 [k21 lr24:26 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{code-const-unsigned-int}[r0x09 r0x0a ] ^ iTemp16 [k22 lr25:26 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int}[r0x0b r0x0c ]
	MOVF	r0x0b, W
	XORWF	r0x09, W
	MOVWF	r0x07
	MOVF	r0x0c, W
	XORWF	r0x0a, W
	MOVWF	r0x08
; ;ic:27: 	 goto _whilecontinue_0($1)
	BRA	_00105_DS_
; ;ic:29:  _whilebreak_0($3) :
; ;ic:30: 	ret iTemp2 [k6 lr5:30 so:0]{ ia0 a2p0 re1 rm0 nos0 ru0 dp0}{unsigned-int}{ sir@ _crc16_crc_1_1}[r0x07 r0x08 ]
_00107_DS_:
;	.line	100; crc16.c	return crc;
	MOVFF	r0x08, PRODL
	MOVF	r0x07, W
; ;ic:31:  _return($4) :
; ;ic:32: 	eproc _crc16 [k1 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{unsigned-int function    ( unsigned-char generic* , unsigned-long-int, unsigned-int) }
	MOVFF	PREINC1, r0x0c
	MOVFF	PREINC1, r0x0b
	MOVFF	PREINC1, r0x0a
	MOVFF	PREINC1, r0x09
	MOVFF	PREINC1, r0x08
	MOVFF	PREINC1, r0x07
	MOVFF	PREINC1, r0x06
	MOVFF	PREINC1, r0x05
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block for Ival
	code
_crc_table:
	DB	0x00, 0x00, 0x21, 0x10, 0x42, 0x20, 0x63, 0x30, 0x84, 0x40, 0xa5, 0x50
	DB	0xc6, 0x60, 0xe7, 0x70, 0x08, 0x81, 0x29, 0x91, 0x4a, 0xa1, 0x6b, 0xb1
	DB	0x8c, 0xc1, 0xad, 0xd1, 0xce, 0xe1, 0xef, 0xf1, 0x31, 0x12, 0x10, 0x02
	DB	0x73, 0x32, 0x52, 0x22, 0xb5, 0x52, 0x94, 0x42, 0xf7, 0x72, 0xd6, 0x62
	DB	0x39, 0x93, 0x18, 0x83, 0x7b, 0xb3, 0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DB	0xc0, 0x18, 0xe1, 0x08, 0x82, 0x38, 0xa3, 0x28, 0x7d, 0xcb, 0x5c, 0xdb
	DB	0x3f, 0xeb, 0x1e, 0xfb, 0xf9, 0x8b, 0xd8, 0x9b, 0xbb, 0xab, 0x9a, 0xbb
	DB	0x75, 0x4a, 0x54, 0x5a, 0x37, 0x6a, 0x16, 0x7a, 0xf1, 0x0a, 0xd0, 0x1a
	DB	0xb3, 0x2a, 0x92, 0x3a, 0x2e, 0xfd, 0x0f, 0xed, 0x6c, 0xdd, 0x4d, 0xcd
	DB	0xaa, 0xbd, 0x8b, 0xad, 0xe8, 0x9d, 0xc9, 0x8d, 0x26, 0x7c, 0x07, 0x6c
	DB	0x64, 0x5c, 0x45, 0x4c, 0xa2, 0x3c, 0x83, 0x2c, 0xe0, 0x1c, 0xc1, 0x0c
	DB	0x1f, 0xef, 0x3e, 0xff, 0x5d, 0xcf, 0x7c, 0xdf, 0x9b, 0xaf, 0xba, 0xbf
	DB	0xd9, 0x8f, 0xf8, 0x9f, 0x17, 0x6e, 0x36, 0x7e, 0x55, 0x4e, 0x74, 0x5e
	DB	0x93, 0x2e, 0xb2, 0x3e, 0xd1, 0x0e, 0xf0, 0x1e


; Statistics:
; code size:	  420 (0x01a4) bytes ( 0.32%)
;           	  210 (0x00d2) words
; udata size:	    0 (0x0000) bytes ( 0.00%)
; access size:	   13 (0x000d) bytes


	end
