;--------------------------------------------------------
; File Created by ChiponCC : aolisn inc.
; Version 3.0.4#6752 (Nov 19 2015 16:48:50) (MSVC)
; This file was generated Mon Jun 06 15:37:50 2016
;--------------------------------------------------------
; chipon port for the 16-bit core
;--------------------------------------------------------
;	.file	"../main.c"
	.list	p=KF8V216
	.radix dec
	.include "KF8V216.inc"
;--------------------------------------------------------
; external declarations
;--------------------------------------------------------
	.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	_CM1CTL_bits
	.extern	_AMPCTL_bits
	.extern	_ANSEH_bits
	.extern	_ADCCTL0_bits
	.extern	_AMPDT_bits
	.extern	_OPTR_bits
	.extern	_IP0_bits
	.extern	_IP1_bits
	.extern	_TR0_bits
	.extern	_TR2_bits
	.extern	_TR1_bits
	.extern	_VRECTL1_bits
	.extern	_EIE1_bits
	.extern	_PCTL_bits
	.extern	_OSCCTL_bits
	.extern	_ANSEL_bits
	.extern	_PUR_bits
	.extern	_IOCL_bits
	.extern	_ADCCTL1_bits
	.extern	_P0LR_bits
	.extern	_P2LR_bits
	.extern	_P1LR_bits
	.extern	_PWM4CTL0_bits
	.extern	_PWM4CTL1_bits
	.extern	_P4ASCTL_bits
	.extern	_PATRCTL_bits
	.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	_T2L
	.extern	_T2CTL
	.extern	_PWM1L
	.extern	_PWM1H
	.extern	_PWMCTL
	.extern	_PP1
	.extern	_CM1CTL
	.extern	_AMPCTL
	.extern	_VRECAL1
	.extern	_ANSEH
	.extern	_ADCDATAH
	.extern	_ADCCTL0
	.extern	_AMPDT
	.extern	_OPTR
	.extern	_IP0
	.extern	_IP1
	.extern	_TR0
	.extern	_TR2
	.extern	_TR1
	.extern	_VRECAL2
	.extern	_VRECTL1
	.extern	_EIE1
	.extern	_PCTL
	.extern	_OSCCTL
	.extern	_OSCCAL0
	.extern	_ANSEL
	.extern	_PP2
	.extern	_PWM2L
	.extern	_PWM2H
	.extern	_PUR
	.extern	_IOCL
	.extern	_OSCCAL1
	.extern	_ADCDATAL
	.extern	_ADCCTL1
	.extern	_T2CCRH
	.extern	_T2H
	.extern	_PP4H
	.extern	_PWM4L1
	.extern	_PWM4H1
	.extern	_P0LR
	.extern	_P2LR
	.extern	_P1LR
	.extern	_OSCCAL2
	.extern	_OSCCAL3
	.extern	_PP4L
	.extern	_T2CCRL
	.extern	_PWM4L0
	.extern	_PWM4H0
	.extern	_PWM4CTL0
	.extern	_PWM4CTL1
	.extern	_P4ASCTL
	.extern	_PATRCTL
	.extern	_startup
	.extern	__sdcc_gsinit_startup
;--------------------------------------------------------
; global declarations
;--------------------------------------------------------
	.global	_Init_fun
	.global	_Delay
	.global	_main
	.global	_int_fun0
	.global	_int_fun1

	.global I0R1
	.global I0PCH
	.global I1R1
	.global I1PCH
	.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 0x0080
I0R1		.res 1
I0PCH		.res 1
I1R1		.res 1
I1PCH		.res 1
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
;--------------------------------------------------------
;--------------------------------------------------------
; absolute symbol definitions
;--------------------------------------------------------
;--------------------------------------------------------
; compiler-defined variables
;--------------------------------------------------------
UDL_main_0	.udata
r0x1000	.res	1
UDL_main_1	.udata
r0x1001	.res	1
UDL_main_2	.udata
r0x1002	.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
;--------------------------------------------------------
interrupt_0x04	.code	0x4
	MOV		R2,R0
	MOV		R3,PSW
	MOV		R0,PCH
	BANKSEL	I0PCH
	MOV		I0PCH,R0
	MOV		I0R1,R1
	PAGESEL	interrupt_service_routine_0x04
	JMP		interrupt_service_routine_0x04



func._int_fun0	.code
;***
;  PostBlock Stats: dbName = I
;***
;entry:  _int_fun0	;Function start
; 0 exit points
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_int_fun0	;Function start
; 0 exit points
;	op : GET_VALUE_AT_ADDRESS
; R3 resprent for wsave,R4 resprent for ssave, R5 resprent for psave
interrupt_service_routine_0x04
;	.line	116; "../main.c"	if (INT2IF)
	JB	_EIF1_bits, 5
	JMP	_00028_DS_
;	op : =
;	.line	118; "../main.c"	INT2IF = 0;                 // 清中断标志
	CLR	_EIF1_bits, 5
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
;	.line	119; "../main.c"	LED1 = !LED1;               // 更改 D3 显示状态
	JB	_P1LR_bits, 4
	JMP	_00031_DS_
	CLR	_P1LR_bits, 4
	JMP	_00028_DS_
_00031_DS_
	SET	_P1LR_bits, 4
;	op : LABEL
;	op : ENDFUNCTION
_00028_DS_
	BANKSEL	I0R1
	MOV	R1, I0R1
	BANKSEL	I0PCH
	MOV	R0, I0PCH
	MOV	PCH, R0
	MOV	PSW, R3
	MOV	R0, R2
	IRET	



func._int_fun1	.code
;***
;  PostBlock Stats: dbName = I
;***
;entry:  _int_fun1	;Function start
; 0 exit points
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_int_fun1	;Function start
; 0 exit points
;	op : LABEL
;	op : ENDFUNCTION
; R3 resprent for wsave,R4 resprent for ssave, R5 resprent for psave
interrupt_service_routine_0x14
_00033_DS_
;	.line	128; "../main.c"	}
	IRET	



func._main	.code
;***
;  PostBlock Stats: dbName = M
;***
;entry:  _main	;Function start
; 2 exit points
;has an exit
;functions called:
;   _Init_fun
;   _Delay
;   _Init_fun
;   _Delay
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_main	;Function start
; 2 exit points
;	op : CALL
;	.line	87; "../main.c"	Init_fun();
	PAGESEL	_Init_fun
	CALL	_Init_fun
	PAGESEL	$
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00019_DS_
;	.line	91; "../main.c"	P1LR1 = !P1LR1;                 //  改变P11口电平
	JB	_P1LR_bits, 1
	JMP	_00024_DS_
	CLR	_P1LR_bits, 1
	JMP	_00025_DS_
_00024_DS_
	SET	_P1LR_bits, 1
;	op : CALL
_00025_DS_
;	.line	92; "../main.c"	Delay();
	PAGESEL	_Delay
	CALL	_Delay
	PAGESEL	$
;	op : GOTO
	JMP	_00019_DS_
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _main



func._Delay	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _Delay	;Function start
; 2 exit points
;has an exit
;3 compiler assigned registers:
;   r0x1000
;   r0x1001
;   r0x1002
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_Delay	;Function start
; 2 exit points
;	op : =
;	.line	81; "../main.c"	for (i = 0;i < 200;i++)
	BANKSEL	r0x1000
	CLR	r0x1000
;	op : LABEL
;	op : <
;unsigned compare: left < lit(0xC8=200), size=1
_00006_DS_
	MOV	R0,# 0xc8
	BANKSEL	r0x1000
	SUB	R0, r0x1000
;comparing bytes at offset 0
	JNB	PSW, 0
	JMP	_00010_DS_
;	op : =
;	.line	82; "../main.c"	for (j = 0;j < 200;j++);
	MOV	R0,# 0xc8
	BANKSEL	r0x1001
	MOV	r0x1001, R0
;	op : LABEL
;	op : CAST
_00005_DS_
	BANKSEL	r0x1001
	MOVZ	R0, r0x1001
	BANKSEL	r0x1002
	MOV	r0x1002, R0
;	op : -
	BANKSEL	r0x1002
	DEC	r0x1002
;	op : CAST
	BANKSEL	r0x1002
	MOVZ	R0, r0x1002
	BANKSEL	r0x1001
	MOV	r0x1001, R0
;	op : IFX
	MOV	R0,# 0x00
	BANKSEL	r0x1001
	ORL	R0, r0x1001
	JB	PSW, 2
	JMP	_00005_DS_
;	op : +
;	.line	81; "../main.c"	for (i = 0;i < 200;i++)
	BANKSEL	r0x1000
	INC	r0x1000
;	op : GOTO
	JMP	_00006_DS_
;	op : LABEL
;	op : ENDFUNCTION
_00010_DS_
	CRET	
; exit point of _Delay



func._Init_fun	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _Init_fun	;Function start
; 2 exit points
;has an exit
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_Init_fun	;Function start
; 2 exit points
;	op : =
;	.line	28; "../main.c"	OSCCTL = 0x60;                           //设置系统时钟为8M
	MOV	R0,# 0x60
	MOV	_OSCCTL, R0
;	op : =
;	.line	31; "../main.c"	TR0 = 0x0c;				                 //设置P03 P02(INT0) 端口只能设置为输入
	MOV	R0,# 0x0c
	MOV	_TR0, R0
;	op : =
;	.line	32; "../main.c"	TR1 = 0x0c;				                 //P12(INT1)/P13(INT2)口为外部中断引脚，需配置为数字输入口设置P1端口为输出
	MOV	R0,# 0x0c
	MOV	_TR1, R0
;	op : =
;	.line	33; "../main.c"	TR2 = 0x00;				                 //设置P2端口为输出
	CLR	_TR2
;	op : =
;	.line	35; "../main.c"	P0 = 0x00;
	CLR	_P0
;	op : =
;	.line	36; "../main.c"	P1 = 0x00;
	CLR	_P1
;	op : =
;	.line	37; "../main.c"	P2 = 0x00;
	CLR	_P2
;	op : =
;	.line	39; "../main.c"	P0LR = 0;
	CLR	_P0LR
;	op : =
;	.line	40; "../main.c"	P1LR = 0;
	CLR	_P1LR
;	op : =
;	.line	41; "../main.c"	P2LR = 0;
	CLR	_P2LR
;	op : =
;	.line	43; "../main.c"	ANSEL = 0;                               //配置P12口为数字口
	CLR	_ANSEL
;	op : =
;	.line	44; "../main.c"	ANSEH = 0;
	CLR	_ANSEH
;	op : =
;	.line	61; "../main.c"	INT2IF = 0;   //  清中断标志位
	CLR	_EIF1_bits, 5
;	op : =
;	.line	62; "../main.c"	INT2SE = 0;   //  0 ：下降沿             1：上升沿
	CLR	_PWMCTL_bits, 7
;	op : =
;	.line	63; "../main.c"	INT2IE = 1;   //  使能中断
	SET	_EIE1_bits, 5
;	op : =
;	.line	64; "../main.c"	PUIE = 1;     //  INT2 属于外部中断
	SET	_INTCTL_bits, 6
;	op : =
;	.line	66; "../main.c"	PCTL = 0;     // 禁止中断优先级
	CLR	_PCTL
;	op : =
;	.line	67; "../main.c"	AIE = 1;      // 使能总中断
	SET	_INTCTL_bits, 7
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _Init_fun


;	code size estimation:
;	   69+   12 =    81 instructions (  186 byte)


	.end
