;--------------------------------------------------------
; File Created by ChiponCC : aolisn inc.
; Version 3.0.4#6752 (Jun  6 2016 11:07:59) (MSVC)
; This file was generated Mon Jul 04 11:14:23 2016
;--------------------------------------------------------
; chipon port for the 16-bit core
;--------------------------------------------------------
;	.file	"../main.c"
	.radix dec
	.include "KF8S1022.inc"
;--------------------------------------------------------
; external declarations
;--------------------------------------------------------
	.extern	_init_mcu
	.extern	__KF8S_Get_Ver_Waterproof_
	.extern	__KF8S_Lib_Set_Waterproof_Parameter
	.extern	__KF8S_Init_Touch_Waterproof_
	.extern	__KF8S_Touch_Process_Waterproof_
	.extern	__KF8S_Touch_TEST_Waterproof_
	.extern	__R2PCL
	.extern	_TOUCH_DEBUG_TRS_DEAL
	.extern	_TOUCH_DEBUG_SEND_OUT
	.extern	_PSW_bits
	.extern	_P0_bits
	.extern	_P2_bits
	.extern	_P1_bits
	.extern	_INTCTL_bits
	.extern	_EIF1_bits
	.extern	_T1CTL_bits
	.extern	_T2CTL_bits
	.extern	_PWMCTL_bits
	.extern	_CMCTL1_bits
	.extern	_ANSEH_bits
	.extern	_ADCCTL0_bits
	.extern	_OPTR_bits
	.extern	_TR0_bits
	.extern	_TR2_bits
	.extern	_TR1_bits
	.extern	_TR3_bits
	.extern	_EIE1_bits
	.extern	_PCTL_bits
	.extern	_OSCCTL_bits
	.extern	_ANSEL_bits
	.extern	_PUR_bits
	.extern	_IOCL_bits
	.extern	_ADCCTL1_bits
	.extern	_T3L_bits
	.extern	_CTCTL_bits
	.extern	_OSCLDOCAL_bits
	.extern	__KF8_LIBi_channel_flag_
	.extern	__KF8_LIBc_channel_
	.extern	__KF8_LIBc_channel_Buf
	.extern	__KF8_LIBi_Date_Change_
	.extern	__KF8_LIBc_baseline_count_
	.extern	__KF8_LIBi_buff_hit_
	.extern	__KF8_LIBi_buff_baseline_
	.extern	__KF8_LIBc_touch_count_
	.extern	_sentbuf1
	.extern	_sentbuf2
	.extern	_sentbuf3
	.extern	_sentbuf4
	.extern	_CHS_AMOUNT
	.extern	_TCS_AMOUNT
	.extern	__KF8_Disturb_Protect_Circle_
	.extern	__KF8_DoubleKey_Compages_Limitable_Circle_
	.extern	__KF8_Key_Max_Pressed_Limitable_Circle_
	.extern	__KF8_BaseLine_Update_Circle_Count_For_UP_
	.extern	__KF8_BaseLine_Update_Circle_Count_For_Down_
	.extern	__KF8_Define_Disturb_Channels_Amount_
	.extern	__KF8_BasicLine_UP_Noise_Threshold_
	.extern	__KF8_BasicLine_Down_Noise_Threshold_
	.extern	__KF8_Data_Steady_Threshold_Set_
	.extern	__KF8_Inside_Reference_Channel_Disturb_Threshold_Set_
	.extern	__KF8_Inside_Reference_Channel_Declare_
	.extern	__KF8_Config_Finger_Threshold
	.extern	__KF8_Water_Monitor_
	.extern	__KF8_CONFIG_FINGER_THRESHOLD_IN_WATER_
	.extern	_Double_Key_SET_EN_1
	.extern	_Double_Key_SET_EN_2
	.extern	_Double_Key_SET_EN_3
	.extern	__KF8_TOUCH_CH_EN
	.extern	_T0
	.extern	_PCL
	.extern	_PSW
	.extern	_P0
	.extern	_P2
	.extern	_P1
	.extern	_PCH
	.extern	_INTCTL
	.extern	_EIF1
	.extern	_T1L
	.extern	_T1H
	.extern	_T1CTL
	.extern	_T2
	.extern	_T2CTL
	.extern	_PWMCTL
	.extern	_CMCTL1
	.extern	_VRECAL
	.extern	_ANSEH
	.extern	_ADCDATAH
	.extern	_ADCCTL0
	.extern	_OPTR
	.extern	_TR0
	.extern	_TR2
	.extern	_TR1
	.extern	_TR3
	.extern	_EIE1
	.extern	_PCTL
	.extern	_OSCCTL
	.extern	_OSCCAL0
	.extern	_ANSEL
	.extern	_PUR
	.extern	_IOCL
	.extern	_OSCCAL1
	.extern	_ADCDATAL
	.extern	_ADCCTL1
	.extern	_T3L
	.extern	_CTCTL
	.extern	_T2CCR
	.extern	_OSCLDOCAL
	.extern	_T1U
	.extern	_startup
	.extern	__sdcc_gsinit_startup
;--------------------------------------------------------
; global declarations
;--------------------------------------------------------
	.global	_delay_us
	.global	_delay_ms
	.global	_display
	.global	_INT_FUN
	.global	_main
	.global	_Touch_Watch
	.global	_flag

	.global STK12
	.global STK11
	.global STK10
	.global STK09
	.global STK08
	.global STK07
	.global STK06
	.global STK05
	.global STK04
	.global STK03
	.global STK02
	.global STK01
	.global STK00

sharebank .udata
STK12	.res 1
	.type STK12, 108
STK11	.res 1
	.type STK11, 108
STK10	.res 1
	.type STK10, 108
STK09	.res 1
	.type STK09, 108
STK08	.res 1
	.type STK08, 108
STK07	.res 1
	.type STK07, 108
STK06	.res 1
	.type STK06, 108
STK05	.res 1
	.type STK05, 108
STK04	.res 1
	.type STK04, 108
STK03	.res 1
	.type STK03, 108
STK02	.res 1
	.type STK02, 108
STK01	.res 1
	.type STK01, 108
STK00	.res 1
	.type STK00, 108

;--------------------------------------------------------
; global definitions
;--------------------------------------------------------
UD_main_0	.udata
_Touch_Watch	.res	2

UD_main_1	.udata
_flag	.res	1

;--------------------------------------------------------
; absolute symbol definitions
;--------------------------------------------------------
;--------------------------------------------------------
; compiler-defined variables
;--------------------------------------------------------
UDL_main_0	.udata
r0x1004	.res	1
UDL_main_1	.udata
r0x1003	.res	1
UDL_main_2	.udata
r0x1005	.res	1
UDL_main_3	.udata
r0x1006	.res	1
UDL_main_4	.udata
r0x1007	.res	1
UDL_main_5	.udata
r0x1008	.res	1
UDL_main_6	.udata
r0x100E	.res	1
UDL_main_7	.udata
r0x100D	.res	1
UDL_main_8	.udata
r0x100F	.res	1
UDL_main_9	.udata
r0x1010	.res	1
UDL_main_10	.udata
r0x1009	.res	1
UDL_main_11	.udata
r0x100A	.res	1
UDL_main_12	.udata
r0x100B	.res	1
;--------------------------------------------------------
; initialized data
;--------------------------------------------------------
;--------------------------------------------------------
; overlayable items in internal ram 
;--------------------------------------------------------
;	.udata_ovr
;--------------------------------------------------------
; reset vector 
;--------------------------------------------------------
STARTUP	.code 0x0000
	NOP
	PAGESEL	init_imp
	JMP		init_imp

	.global	init_imp
INIT_IMP	.code
init_imp
	PAGESEL	_startup
	CALL	_startup
	PAGESEL	__sdcc_gsinit_startup
	CALL	__sdcc_gsinit_startup
	PAGESEL	_main
	JMP		_main
;--------------------------------------------------------
; interrupt and initialization code
;--------------------------------------------------------
c_interrupt	.code	0x4
	MOV		R3,R0
	MOV		R4,PSW
	MOV		R5,PCH
	MOV		R2,R1
	PAGESEL	__sdcc_interrupt
	JMP		__sdcc_interrupt



func._INT_FUN	.code
;***
;  PostBlock Stats: dbName = I
;***
;entry:  _INT_FUN	;Function start
; 0 exit points
;functions called:
;   __KF8S_Touch_Process_Waterproof_
;   __KF8S_Touch_Process_Waterproof_
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_INT_FUN	;Function start
; 0 exit points
;	op : GET_VALUE_AT_ADDRESS
; R3 resprent for wsave,R4 resprent for ssave, R5 resprent for psave
__sdcc_interrupt
;	.line	129; "../main.c"	if(T1IF||CTIF)
	JNB	_EIF1_bits, 0
	JMP	_00023_DS_
;	op : GET_VALUE_AT_ADDRESS
	JB	_EIF1_bits, 7
	JMP	_00026_DS_
;	op : LABEL
;	op : =
_00023_DS_
;	.line	131; "../main.c"	T1IF=0;
	CLR	_EIF1_bits, 0
;	op : =
;	.line	132; "../main.c"	CTIF=0;
	CLR	_EIF1_bits, 7
;	op : =
;	.line	133; "../main.c"	Touch_Watch=0;
	BANKSEL	_Touch_Watch
	CLR	_Touch_Watch
	BANKSEL	_Touch_Watch
	CLR	(_Touch_Watch + 1)
;	op : =
;	.line	134; "../main.c"	flag = 1;
	MOV	R0,# 0x01
	BANKSEL	_flag
	MOV	_flag, R0
;	op : CALL
;	.line	137; "../main.c"	_KF8S_Touch_Process_Waterproof_(); //更新按键标志
	PAGESEL	__KF8S_Touch_Process_Waterproof_
	CALL	__KF8S_Touch_Process_Waterproof_
	PAGESEL	$
;	op : LABEL
;	op : ENDFUNCTION
_00026_DS_
	MOV	R1, R2
	MOV	PCH, R5
	MOV	PSW, R4
	MOV	R0, R3
	IRET	



func._main	.code
;***
;  PostBlock Stats: dbName = M
;***
;entry:  _main	;Function start
; 2 exit points
;has an exit
;functions called:
;   _init_mcu
;   _delay_ms
;   __KF8S_Init_Touch_Waterproof_
;   _display
;   __KF8S_Init_Touch_Waterproof_
;   _init_mcu
;   _delay_ms
;   __KF8S_Init_Touch_Waterproof_
;   _display
;   __KF8S_Init_Touch_Waterproof_
;5 compiler assigned registers:
;   STK00
;   r0x1009
;   r0x100A
;   r0x100B
;   r0x100C
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_main	;Function start
; 2 exit points
;	op : CALL
;	.line	151; "../main.c"	init_mcu();						//初始化MCU寄存器
	PAGESEL	_init_mcu
	CALL	_init_mcu
	PAGESEL	$
;	op : SEND
;	op : CALL
;	.line	152; "../main.c"	delay_ms(300);					//延时一会，防止上电误触发触摸通道
	MOV	R0,# 0x2c
	BANKSEL	STK00
	MOV	STK00, R0
	MOV	R0,# 0x01
	PAGESEL	_delay_ms
	CALL	_delay_ms
	PAGESEL	$
;	op : =
;	.line	153; "../main.c"	CMCTL1 = 0x90;    //设置触摸分频和基准电压
	MOV	R0,# 0x90
	MOV	_CMCTL1, R0
;	op : INLINEASM
	CWDT 
;	op : CALL
;	.line	157; "../main.c"	_KF8S_Init_Touch_Waterproof_();		//调用电容触摸库函数的初始化
	PAGESEL	__KF8S_Init_Touch_Waterproof_
	CALL	__KF8S_Init_Touch_Waterproof_
	PAGESEL	$
;	op : INLINEASM
	CWDT 
;	op : LABEL
;	op : INLINEASM
_00032_DS_
	CWDT 
;	op : CALL
;	.line	164; "../main.c"	display();					//显示LED灯
	PAGESEL	_display
	CALL	_display
	PAGESEL	$
;	op : +
;	.line	176; "../main.c"	Touch_Watch++;
	BANKSEL	_Touch_Watch
	INC	_Touch_Watch
	JB	PSW, 2
	JMP	_00039_DS_
	BANKSEL	_Touch_Watch
	INC	(_Touch_Watch + 1)
;	op : CAST
_00039_DS_
;	.line	177; "../main.c"	if(Touch_Watch>50000)
	BANKSEL	_Touch_Watch
	MOVZ	R0, _Touch_Watch
	BANKSEL	r0x1009
	MOV	r0x1009, R0
	BANKSEL	_Touch_Watch
	MOVZ	R0, (_Touch_Watch + 1)
	BANKSEL	r0x100A
	MOV	r0x100A, R0
	BANKSEL	r0x100B
	CLR	r0x100B
;;1	CLR	r0x100C
;	op : >
;swapping arguments (AOP_TYPEs 1/2)
;signed compare: left >= lit(0xC351=50001), size=4, mask=ffffffff
	MOV	R0,# 0x00
	ADD	R0,# 0x80
	ADD	R0,# 0x80
;comparing bytes at offset 3
	JB	PSW, 2
	JMP	_00038_DS_
	MOV	R0,# 0x00
	BANKSEL	r0x100B
	SUB	R0, r0x100B
	JB	PSW, 2
	JMP	_00038_DS_
	MOV	R0,# 0xc3
	BANKSEL	r0x100A
	SUB	R0, r0x100A
	JB	PSW, 2
	JMP	_00038_DS_
	MOV	R0,# 0x51
	BANKSEL	r0x1009
	SUB	R0, r0x1009
_00038_DS_
	JB	PSW, 0
	JMP	_00032_DS_
;	op : =
;	.line	179; "../main.c"	Touch_Watch=0;
	BANKSEL	_Touch_Watch
	CLR	_Touch_Watch
	BANKSEL	_Touch_Watch
	CLR	(_Touch_Watch + 1)
;	op : CALL
;	.line	180; "../main.c"	_KF8S_Init_Touch_Waterproof_();
	PAGESEL	__KF8S_Init_Touch_Waterproof_
	CALL	__KF8S_Init_Touch_Waterproof_
	PAGESEL	$
;	op : GOTO
	JMP	_00032_DS_
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _main



func._delay_us	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _delay_us	;Function start
; 2 exit points
;has an exit
;5 compiler assigned registers:
;   r0x100D
;   STK00
;   r0x100E
;   r0x100F
;   r0x1010
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_delay_us	;Function start
; 2 exit points
;	op : RECEIVE
;	.line	90; "../main.c"	void delay_us(uint us_data)
	BANKSEL	r0x100D
	MOV	r0x100D, R0
	BANKSEL	STK00
	MOVZ	R0, STK00
	BANKSEL	r0x100E
	MOV	r0x100E, R0
;	op : =
;	op : LABEL
;	op : =
_00016_DS_
;	.line	92; "../main.c"	while(us_data--);
	BANKSEL	r0x100E
	MOVZ	R0, r0x100E
	BANKSEL	r0x100F
	MOV	r0x100F, R0
	BANKSEL	r0x100D
	MOVZ	R0, r0x100D
	BANKSEL	r0x1010
	MOV	r0x1010, R0
;	op : -
	MOV	R0,# 0xff
	BANKSEL	r0x100E
	ADD	r0x100E, R0
	JNB	PSW, 0
	JMP	_00040_DS_
	BANKSEL	r0x100D
	DEC	r0x100D
;	op : IFX
_00040_DS_
	BANKSEL	r0x100F
	MOVZ	R0, r0x100F
	BANKSEL	r0x1010
	ORL	R0, r0x1010
	JB	PSW, 2
	JMP	_00016_DS_
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _delay_us



func._delay_ms	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _delay_ms	;Function start
; 2 exit points
;has an exit
;7 compiler assigned registers:
;   r0x1003
;   STK00
;   r0x1004
;   r0x1005
;   r0x1006
;   r0x1007
;   r0x1008
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_delay_ms	;Function start
; 2 exit points
;	op : RECEIVE
;	.line	70; "../main.c"	void delay_ms(uint ms_data)
	BANKSEL	r0x1003
	MOV	r0x1003, R0
	BANKSEL	STK00
	MOVZ	R0, STK00
	BANKSEL	r0x1004
	MOV	r0x1004, R0
;	op : =
;	op : LABEL
;	op : =
_00006_DS_
;	.line	73; "../main.c"	while(ms_data--)
	BANKSEL	r0x1004
	MOVZ	R0, r0x1004
	BANKSEL	r0x1005
	MOV	r0x1005, R0
	BANKSEL	r0x1003
	MOVZ	R0, r0x1003
	BANKSEL	r0x1006
	MOV	r0x1006, R0
;	op : -
	MOV	R0,# 0xff
	BANKSEL	r0x1004
	ADD	r0x1004, R0
	JNB	PSW, 0
	JMP	_00041_DS_
	BANKSEL	r0x1003
	DEC	r0x1003
;	op : IFX
_00041_DS_
	BANKSEL	r0x1005
	MOVZ	R0, r0x1005
	BANKSEL	r0x1006
	ORL	R0, r0x1006
	JNB	PSW, 2
	JMP	_00009_DS_
;	op : INLINEASM
	CWDT 
;	op : =
;	.line	77; "../main.c"	while(j--)
	MOV	R0,# 0xc8
	BANKSEL	r0x1005
	MOV	r0x1005, R0
	BANKSEL	r0x1006
	CLR	r0x1006
;	op : LABEL
;	op : =
_00003_DS_
	BANKSEL	r0x1005
	MOVZ	R0, r0x1005
	BANKSEL	r0x1007
	MOV	r0x1007, R0
	BANKSEL	r0x1006
	MOVZ	R0, r0x1006
	BANKSEL	r0x1008
	MOV	r0x1008, R0
;	op : -
	MOV	R0,# 0xff
	BANKSEL	r0x1005
	ADD	r0x1005, R0
	JNB	PSW, 0
	JMP	_00042_DS_
	BANKSEL	r0x1006
	DEC	r0x1006
;	op : IFX
_00042_DS_
	BANKSEL	r0x1007
	MOVZ	R0, r0x1007
	BANKSEL	r0x1008
	ORL	R0, r0x1008
	JNB	PSW, 2
	JMP	_00006_DS_
;	op : INLINEASM
	CWDT 
;	op : GOTO
	JMP	_00003_DS_
;	op : LABEL
;	op : ENDFUNCTION
_00009_DS_
	CRET	
; exit point of _delay_ms



func._display	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _display	;Function start
; 2 exit points
;has an exit
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_display	;Function start
; 2 exit points
;	op : LABEL
;	op : ENDFUNCTION
;	.line	53; "../main.c"	if(_KF8_LIBi_channel_flag_&0x0020)		//通道5
	CRET	
; exit point of _display


;	code size estimation:
;	  120+   48 =   168 instructions (  432 byte)


	.end
