;--------------------------------------------------------
; File Created by ChiponCC : aolisn inc.
; Version 3.0.4#6752 (Mar  1 2016 15:13:08) (MSVC)
; This file was generated Sat May 28 15:27:39 2016
;--------------------------------------------------------
; chipon port for the 16-bit core
;--------------------------------------------------------
;	.file	"../main.c"
	.radix dec
	.include "KF8S1011.inc"
;--------------------------------------------------------
; external declarations
;--------------------------------------------------------
	.extern	_PSW_bits
	.extern	_P0_bits
	.extern	_P2_bits
	.extern	_P1_bits
	.extern	_P3_bits
	.extern	_P4_bits
	.extern	_INTCTL_bits
	.extern	_EIF1_bits
	.extern	_EIF2_bits
	.extern	_T1CTL_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	_TR4_bits
	.extern	_EIE1_bits
	.extern	_EIE2_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	_RSCTL_bits
	.extern	_OSCLDOCAL_bits
	.extern	_BRCTL_bits
	.extern	_TSCTL_bits
	.extern	_EUBRGL_bits
	.extern	_EUBRGH_bits
	.extern	_T0
	.extern	_PCL
	.extern	_PSW
	.extern	_P0
	.extern	_P2
	.extern	_P1
	.extern	_P3
	.extern	_P4
	.extern	_PCH
	.extern	_INTCTL
	.extern	_EIF1
	.extern	_EIF2
	.extern	_T1L
	.extern	_T1H
	.extern	_T1CTL
	.extern	_PWMCTL
	.extern	_CMCTL1
	.extern	_VRECAL
	.extern	_ANSEH
	.extern	_ADCDATAH
	.extern	_ADCCTL0
	.extern	_OPTR
	.extern	_TR0
	.extern	_TR2
	.extern	_TR1
	.extern	_TR3
	.extern	_TR4
	.extern	_EIE1
	.extern	_EIE2
	.extern	_PCTL
	.extern	_OSCCTL
	.extern	_OSCCAL0
	.extern	_ANSEL
	.extern	_PUR
	.extern	_IOCL
	.extern	_OSCCAL1
	.extern	_BADDRH
	.extern	_BADDRL
	.extern	_EECTL1
	.extern	_EECTL2
	.extern	_ADCDATAL
	.extern	_ADCCTL1
	.extern	_T3L
	.extern	_CTCTL
	.extern	_RSCTL
	.extern	_TXSDR
	.extern	_RXSDR
	.extern	_OSCLDOCAL
	.extern	_T1U
	.extern	_BRCTL
	.extern	_TSCTL
	.extern	_EUBRGL
	.extern	_EUBRGH
	.extern	_startup
	.extern	__sdcc_gsinit_startup
;--------------------------------------------------------
; global declarations
;--------------------------------------------------------
	.global	_Delay_ms
	.global	_init_mcu
	.global	_init_usart
	.global	_usart_function
	.global	_main
	.global	_int_fun
	.global	_Timer_Count
	.global	_Send_Date
	.global	_Send_Flag
	.global	_Rev_Temp
	.global	_Rev_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
_Timer_Count	.res	1

UD_main_1	.udata
_Send_Date	.res	1

UD_main_2	.udata
_Send_Flag	.res	1

UD_main_3	.udata
_Rev_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
;--------------------------------------------------------
; initialized data
;--------------------------------------------------------

ID_main_0	.idata
_Rev_Temp
	.db	0x00

;--------------------------------------------------------
; 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
;; 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	167; "../main.c"	if(RXIF)
	JB	_EIF2_bits, 5
	JMP	_00064_DS_
;	op : GET_VALUE_AT_ADDRESS
;	.line	169; "../main.c"	if(OVFER || FRER)
	JNB	_RSCTL_bits, 1
	JMP	_00059_DS_
;	op : GET_VALUE_AT_ADDRESS
	JB	_RSCTL_bits, 2
	JMP	_00060_DS_
;	op : LABEL
;	op : =
_00059_DS_
;	.line	171; "../main.c"	Rev_Flag=0;
	BANKSEL	_Rev_Flag
	CLR	_Rev_Flag
;	op : GOTO
	JMP	_00061_DS_
;	op : LABEL
;	op : =
_00060_DS_
;	.line	175; "../main.c"	Rev_Flag=1;
	MOV	R0,# 0x01
	BANKSEL	_Rev_Flag
	MOV	_Rev_Flag, R0
;	op : LABEL
;	op : =
_00061_DS_
;	.line	178; "../main.c"	Rev_Temp=RXSDR;  // 清零 RXIF
	MOVZ	R0, _RXSDR
	BANKSEL	_Rev_Temp
	MOV	_Rev_Temp, R0
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
_00064_DS_
;	.line	181; "../main.c"	if(T0IF)
	JB	_INTCTL_bits, 2
	JMP	_00077_DS_
;	op : =
;	.line	183; "../main.c"	T0IF = 0;
	CLR	_INTCTL_bits, 2
;	op : =
;	.line	184; "../main.c"	T0 = 0x64;
	MOV	R0,# 0x64
	MOV	_T0, R0
;	op : +
;	.line	185; "../main.c"	Timer_Count++;
	BANKSEL	_Timer_Count
	INC	_Timer_Count
;	op : >
;swapping arguments (AOP_TYPEs 1/3)
;unsigned compare: left >= lit(0x65=101), size=1
;	.line	187; "../main.c"	if(Timer_Count>100)
	MOV	R0,# 0x65
;	.line	189; "../main.c"	Timer_Count=0;
	BANKSEL	_Timer_Count
	SUB	R0, _Timer_Count
	JB	PSW, 0
	JMP	_00077_DS_
	BANKSEL	_Timer_Count
	CLR	_Timer_Count
_00077_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
;   _init_usart
;   _Delay_ms
;   _usart_function
;   _init_mcu
;   _init_usart
;   _Delay_ms
;   _usart_function
;1 compiler assigned register :
;   STK00
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_main	;Function start
; 2 exit points
;	op : CALL
;	.line	154; "../main.c"	init_mcu();
	PAGESEL	_init_mcu
	CALL	_init_mcu
	PAGESEL	$
;	op : CALL
;	.line	155; "../main.c"	init_usart();
	PAGESEL	_init_usart
	CALL	_init_usart
	PAGESEL	$
;	op : SEND
;	op : CALL
;	.line	156; "../main.c"	Delay_ms(10);
	MOV	R0,# 0x0a
	BANKSEL	STK00
	MOV	STK00, R0
	MOV	R0,# 0x00
	PAGESEL	_Delay_ms
	CALL	_Delay_ms
	PAGESEL	$
;	op : LABEL
;	op : CALL
_00054_DS_
;	.line	160; "../main.c"	usart_function();
	PAGESEL	_usart_function
	CALL	_usart_function
	PAGESEL	$
;	op : GOTO
	JMP	_00054_DS_
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _main



func._usart_function	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _usart_function	;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
;   r0x1003
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_usart_function	;Function start
; 2 exit points
;	op : IFX
;	.line	112; "../main.c"	if(Rev_Flag)
	MOV	R0,# 0x00
	BANKSEL	_Rev_Flag
	ORL	R0, _Rev_Flag
	JNB	PSW, 2
	JMP	_00031_DS_
;	op : =
;	.line	114; "../main.c"	Rev_Flag=0;
	BANKSEL	_Rev_Flag
	CLR	_Rev_Flag
;	op : <
;unsigned compare: left < lit(0x1=1), size=1
;	.line	116; "../main.c"	switch(Rev_Temp)
	MOV	R0,# 0x01
	BANKSEL	_Rev_Temp
	SUB	R0, _Rev_Temp
;comparing bytes at offset 0
	JB	PSW, 0
	JMP	_00024_DS_
;	op : >
;swapping arguments (AOP_TYPEs 1/3)
;unsigned compare: left >= lit(0x7=7), size=1
	MOV	R0,# 0x07
	BANKSEL	_Rev_Temp
	SUB	R0, _Rev_Temp
;comparing bytes at offset 0
	JNB	PSW, 0
	JMP	_00024_DS_
;	op : -
	BANKSEL	_Rev_Temp
	DECR	_Rev_Temp
	BANKSEL	r0x1003
	MOV	r0x1003, R0
;	op : JUMPTABLE
	MOV	R0,#high _00040_DS_
	MOV	PCH, R0
	MOV	R0,#_00040_DS_
	BANKSEL	r0x1003
	ADD	R0, r0x1003
	JNB	PSW, 0
	INC	PCH
	MOV	PCL, R0
_00040_DS_
	JMP	_00018_DS_
	JMP	_00019_DS_
	JMP	_00020_DS_
	JMP	_00021_DS_
	JMP	_00022_DS_
	JMP	_00023_DS_
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00018_DS_
;	.line	118; "../main.c"	case 1:P37=!P37;break;
	JB	_P3_bits, 7
	JMP	_00041_DS_
	CLR	_P3_bits, 7
	JMP	_00042_DS_
_00041_DS_
	SET	_P3_bits, 7
;	op : GOTO
_00042_DS_
	JMP	_00025_DS_
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00019_DS_
;	.line	119; "../main.c"	case 2:P36=!P36;break;
	JB	_P3_bits, 6
	JMP	_00043_DS_
	CLR	_P3_bits, 6
	JMP	_00044_DS_
_00043_DS_
	SET	_P3_bits, 6
;	op : GOTO
_00044_DS_
	JMP	_00025_DS_
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00020_DS_
;	.line	120; "../main.c"	case 3:P35=!P35;break;
	JB	_P3_bits, 5
	JMP	_00045_DS_
	CLR	_P3_bits, 5
	JMP	_00046_DS_
_00045_DS_
	SET	_P3_bits, 5
;	op : GOTO
_00046_DS_
	JMP	_00025_DS_
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00021_DS_
;	.line	121; "../main.c"	case 4:P34=!P34;break;
	JB	_P3_bits, 4
	JMP	_00047_DS_
	CLR	_P3_bits, 4
	JMP	_00048_DS_
_00047_DS_
	SET	_P3_bits, 4
;	op : GOTO
_00048_DS_
	JMP	_00025_DS_
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00022_DS_
;	.line	122; "../main.c"	case 5:P33=!P33;break;
	JB	_P3_bits, 3
	JMP	_00049_DS_
	CLR	_P3_bits, 3
	JMP	_00050_DS_
_00049_DS_
	SET	_P3_bits, 3
;	op : GOTO
_00050_DS_
	JMP	_00025_DS_
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
;	op : !
;	op : =
_00023_DS_
;	.line	123; "../main.c"	case 6:P30=!P30;break;
	JB	_P3_bits, 0
	JMP	_00051_DS_
	CLR	_P3_bits, 0
	JMP	_00052_DS_
_00051_DS_
	SET	_P3_bits, 0
;	op : GOTO
_00052_DS_
	JMP	_00025_DS_
;	op : LABEL
;	op : =
_00024_DS_
;	.line	124; "../main.c"	default:P37=1;P36=1;P35=1;P34=1;P33=1;P30=1;break;
	SET	_P3_bits, 7
;	op : =
	SET	_P3_bits, 6
;	op : =
	SET	_P3_bits, 5
;	op : =
	SET	_P3_bits, 4
;	op : =
	SET	_P3_bits, 3
;	op : =
	SET	_P3_bits, 0
;	op : LABEL
;	op : =
_00025_DS_
;	.line	127; "../main.c"	RXIF=0;
	CLR	_EIF2_bits, 5
;	op : =
;	.line	128; "../main.c"	RXIE=0;
	CLR	_EIE2_bits, 5
;	op : =
;	.line	130; "../main.c"	SRXEN=0;		//从机模式无关位
	CLR	_RSCTL_bits, 5
;	op : =
;	.line	131; "../main.c"	CRXEN=0;		//禁止连续接收
	CLR	_RSCTL_bits, 4
;	op : =
;	.line	133; "../main.c"	TXEN=1;			//使能发送
	SET	_TSCTL_bits, 5
;	op : =
;	.line	135; "../main.c"	Sent_Vaule_To_UART(Rev_Temp);
	BANKSEL	_Rev_Temp
	MOVZ	R0, _Rev_Temp
	MOV	_TXSDR, R0
;	op : LABEL
;	op : GET_VALUE_AT_ADDRESS
_00026_DS_
	JB	_TSCTL_bits, 1
	JMP	_00026_DS_
;	op : =
;	.line	137; "../main.c"	TXEN=0;			//禁止发送
	CLR	_TSCTL_bits, 5
;	op : =
;	.line	138; "../main.c"	RXIF=0;
	CLR	_EIF2_bits, 5
;	op : =
;	.line	139; "../main.c"	RXIE=1;			//开启接收中断
	SET	_EIE2_bits, 5
;	op : =
;	.line	141; "../main.c"	SRXEN=0;		//从机模式无关位
	CLR	_RSCTL_bits, 5
;	op : =
;	.line	142; "../main.c"	CRXEN=1;		//使能连续接收
	SET	_RSCTL_bits, 4
;	op : LABEL
;	op : ENDFUNCTION
_00031_DS_
	CRET	
; exit point of _usart_function



func._init_usart	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _init_usart	;Function start
; 2 exit points
;has an exit
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_init_usart	;Function start
; 2 exit points
;	op : =
;	.line	83; "../main.c"	BRCTL=0x00;		// 	接收空闲  使用8位计数器，不考虑唤醒是使能和自动波特率检测
	CLR	_BRCTL
;	op : =
;	.line	85; "../main.c"	EUBRGH=0x00;	// 波特率公式=SCLK/(m*y+1),其中SCLK系统时钟，如这里8M，m为倍频数，见手册，y为8位或16位波特率计数值
	CLR	_EUBRGH
;	op : =
;	.line	86; "../main.c"	EUBRGL=0x0C; 	// SYNC=0(全双工异步模式),BRG16=0(使用8位波特率发生器),HBRG=0(低速)，Baud=8000000/(64*(12+1))=9615
	MOV	R0,# 0x0c
	MOV	_EUBRGL, R0
;	op : =
;	.line	88; "../main.c"	SYNC=1;			//半双工同步模式
	SET	_TSCTL_bits, 4
;	op : =
;	.line	89; "../main.c"	CSRS=0;			//从模式
	CLR	_TSCTL_bits, 7
;	op : =
;	.line	90; "../main.c"	SPEN=1;			//使能串行口
	SET	_RSCTL_bits, 7
;	op : =
;	.line	92; "../main.c"	SRXEN=0;		//从机模式无关位
	CLR	_RSCTL_bits, 5
;	op : =
;	.line	93; "../main.c"	CRXEN=1;		//使能连续接收
	SET	_RSCTL_bits, 4
;	op : =
;	.line	95; "../main.c"	TXIF=0;
	CLR	_EIF2_bits, 4
;	op : =
;	.line	96; "../main.c"	TXIE=0;
	CLR	_EIE2_bits, 4
;	op : =
;	.line	97; "../main.c"	RXIF=0;
	CLR	_EIF2_bits, 5
;	op : =
;	.line	98; "../main.c"	RXIE=1;		// 开启接收中断，发送不中断
	SET	_EIE2_bits, 5
;	op : =
;	.line	100; "../main.c"	INTCTL = 0XE0;     // 使能外部中断 PUIE 使能总中断 AIE  T0IE
	MOV	R0,# 0xe0
	MOV	_INTCTL, R0
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _init_usart



func._init_mcu	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _init_mcu	;Function start
; 2 exit points
;has an exit
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_init_mcu	;Function start
; 2 exit points
;	op : =
;	.line	55; "../main.c"	OSCCTL = 0x60;          //设置为8M
	MOV	R0,# 0x60
	MOV	_OSCCTL, R0
;	op : =
;	.line	58; "../main.c"	TR0 = 0x0B;				//设置P03端口为输入，P0其他I/O口为输出
	MOV	R0,# 0x0b
	MOV	_TR0, R0
;	op : =
;	.line	59; "../main.c"	TR1 = 0x00;				//设置P1端口为输出
	CLR	_TR1
;	op : =
;	.line	60; "../main.c"	TR2 = 0x00;				//设置P2端口为输出
	CLR	_TR2
;	op : =
;	.line	61; "../main.c"	TR3 = 0x00;				//设置P3端口为输出
	CLR	_TR3
;	op : =
;	.line	62; "../main.c"	TR4 = 0x00;				//设置P4端口为输出
	CLR	_TR4
;	op : =
;	.line	64; "../main.c"	P0  = 0;				//P0口输出低电平
	CLR	_P0
;	op : =
;	.line	65; "../main.c"	P1  = 0;				//P1口输出低电平
	CLR	_P1
;	op : =
;	.line	66; "../main.c"	P2  = 0;				//P2口输出低电平
	CLR	_P2
;	op : =
;	.line	67; "../main.c"	P3  = 0;				//P3口输出低电平
	CLR	_P3
;	op : =
;	.line	68; "../main.c"	P4  = 0;				//P4口输出低电平
	CLR	_P4
;	op : =
;	.line	70; "../main.c"	OPTR = 0x05;	//定时器0,定时发送数据到端口 计时64分频
	MOV	R0,# 0x05
	MOV	_OPTR, R0
;	op : =
;	.line	71; "../main.c"	T0 = 0x64;		// 可计时156个周期，结合分频64和时钟8M实现时间间隔定时 约  5ms
	MOV	R0,# 0x64
	MOV	_T0, R0
;	op : LABEL
;	op : ENDFUNCTION
	CRET	
; exit point of _init_mcu



func._Delay_ms	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _Delay_ms	;Function start
; 2 exit points
;has an exit
;5 compiler assigned registers:
;   r0x1003
;   STK00
;   r0x1004
;   r0x1005
;   r0x1006
;; Starting PostCode block
;	op : LABEL
;	op : FUNCTION
_Delay_ms	;Function start
; 2 exit points
;	op : RECEIVE
;	.line	36; "../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 : =
_00004_DS_
;	.line	39; "../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	_00076_DS_
	BANKSEL	r0x1003
	DEC	r0x1003
;	op : IFX
_00076_DS_
	BANKSEL	r0x1005
	MOVZ	R0, r0x1005
	BANKSEL	r0x1006
	ORL	R0, r0x1006
	JNB	PSW, 2
	JMP	_00007_DS_
;	op : =
;	.line	42; "../main.c"	while(i--);
	MOV	R0,# 0x7c
	BANKSEL	r0x1005
	MOV	r0x1005, R0
;	op : LABEL
;	op : =
_00001_DS_
	BANKSEL	r0x1005
	MOVZ	R0, r0x1005
	BANKSEL	r0x1006
	MOV	r0x1006, R0
;	op : -
	BANKSEL	r0x1005
	DEC	r0x1005
;	op : IFX
	MOV	R0,# 0x00
	BANKSEL	r0x1006
	ORL	R0, r0x1006
	JNB	PSW, 2
	JMP	_00004_DS_
;	op : GOTO
	JMP	_00001_DS_
;	op : LABEL
;	op : ENDFUNCTION
_00007_DS_
	CRET	
; exit point of _Delay_ms


;	code size estimation:
;	  191+   31 =   222 instructions (  506 byte)


	.end
