;--------------------------------------------------------
; File Created by ChiponCC : ChipON  inc.
; Version 3.0.4#6752 (Feb 19 2019 20:27:19) (MSVC)
; This file was generated Sun Aug 04 18:03:26 2019
;--------------------------------------------------------
; chipon port for the 16-bit core
;--------------------------------------------------------
;	.file	"../SPI.c"
	.radix dec
	.include "KF8A100EON.inc"
;--------------------------------------------------------
; external declarations
;--------------------------------------------------------
	.extern	_UART_Init
	.extern	_UART_SendBuf
	.extern	_Timer0_Init
	.extern	_Timer1_Init
	.extern	_Timer2_Init
	.extern	_Timer4_Init
	.extern	_PSW_bits
	.extern	_P0_bits
	.extern	_P2_bits
	.extern	_P1_bits
	.extern	_P3_bits
	.extern	_PCH_bits
	.extern	_INTCTL_bits
	.extern	_EIF1_bits
	.extern	_EIF2_bits
	.extern	_T1CTL_bits
	.extern	_T2CTL0_bits
	.extern	_PWMCTL_bits
	.extern	_BANK_bits
	.extern	_ADSCANCTL_bits
	.extern	_C1CTL_bits
	.extern	_VDACS_bits
	.extern	_AMPCTL_bits
	.extern	_ANSEH_bits
	.extern	_ADCCTL0_bits
	.extern	_AMPDT_bits
	.extern	_OPTR_bits
	.extern	_IP0_bits
	.extern	_IP1_bits
	.extern	_IP2_bits
	.extern	_TR0_bits
	.extern	_TR2_bits
	.extern	_TR1_bits
	.extern	_OSCSTA_bits
	.extern	_IP3_bits
	.extern	_VRECTL_bits
	.extern	_EIE1_bits
	.extern	_EIE2_bits
	.extern	_PCTL_bits
	.extern	_OSCCTL_bits
	.extern	_ANSEL_bits
	.extern	_PUR0_bits
	.extern	_IOCL_bits
	.extern	_ADCCTL1_bits
	.extern	_P0LR_bits
	.extern	_P2LR_bits
	.extern	_P1LR_bits
	.extern	_P3LR_bits
	.extern	_TR3_bits
	.extern	_EIE3_bits
	.extern	_EIF3_bits
	.extern	_T3CTL_bits
	.extern	_T3CTL1_bits
	.extern	_PWM5CTL0_bits
	.extern	_PWM5CTL1_bits
	.extern	_P5ASCTL_bits
	.extern	_PSTRCTL_bits
	.extern	_PUR1_bits
	.extern	_PUR2_bits
	.extern	_INTEDGCTL_bits
	.extern	_VBIASCTL_bits
	.extern	_VBIAS1EN_bits
	.extern	_VBIAS2EN_bits
	.extern	_PWM5OC_bits
	.extern	_T2CTL1_bits
	.extern	_VDAC_bits
	.extern	_PWM5CTL2_bits
	.extern	_PWM5PC_bits
	.extern	_RSCTL_bits
	.extern	_BRCTL_bits
	.extern	_TSCTL_bits
	.extern	_SSCICTL0_bits
	.extern	_SSCICTL1_bits
	.extern	_SSCISTA_bits
	.extern	_SSCIMSK_bits
	.extern	_WDTPS_bits
	.extern	_MULCTL_bits
	.extern	_DIVCTL_bits
	.extern	_LEDCTL_bits
	.extern	_LEDPRE_bits
	.extern	_LEDDATA0_bits
	.extern	_LEDDATA1_bits
	.extern	_LEDDATA2_bits
	.extern	_LEDDATA3_bits
	.extern	_LEDDATA4_bits
	.extern	_LEDDATA5_bits
	.extern	_LEDDATA6_bits
	.extern	_LEDDATA7_bits
	.extern	_C1FILTCTL_bits
	.extern	_C1FILTPRE_bits
	.extern	_LEDOMS1_bits
	.extern	_CCPCTL_bits
	.extern	_LEDODS0_bits
	.extern	_LEDOMS0_bits
	.extern	_LEDODS1_bits
	.extern	_LEDLUM_bits
	.extern	_PWM5FC_bits
	.extern	_T4CTL_bits
	.extern	_UART_BUF
	.extern	_T0
	.extern	_PCL
	.extern	_PSW
	.extern	_P0
	.extern	_P2
	.extern	_P1
	.extern	_P3
	.extern	_PCH
	.extern	_INTCTL
	.extern	_EIF1
	.extern	_EIF2
	.extern	_T1L
	.extern	_T1H
	.extern	_T1CTL
	.extern	_T2L
	.extern	_T2CTL0
	.extern	_PWM1L
	.extern	_PWM1H
	.extern	_PWMCTL
	.extern	_PP1
	.extern	_BANK
	.extern	_ADSCANCTL
	.extern	_C1CTL
	.extern	_VDACS
	.extern	_AMPCTL
	.extern	_ANSEH
	.extern	_ADCDATA0H
	.extern	_ADCCTL0
	.extern	_AMPDT
	.extern	_OPTR
	.extern	_IP0
	.extern	_IP1
	.extern	_IP2
	.extern	_TR0
	.extern	_TR2
	.extern	_TR1
	.extern	_OSCSTA
	.extern	_IP3
	.extern	_VRECAL1
	.extern	_VRECTL
	.extern	_EIE1
	.extern	_EIE2
	.extern	_PCTL
	.extern	_OSCCTL
	.extern	_OSCCAL0
	.extern	_ANSEL
	.extern	_PP2
	.extern	_PWM2L
	.extern	_PWM2H
	.extern	_PUR0
	.extern	_IOCL
	.extern	_OSCCAL1
	.extern	_NVMDATAH
	.extern	_NVMDATAL
	.extern	_NVMADDRH
	.extern	_NVMADDRL
	.extern	_NVMCTL0
	.extern	_NVMCTL1
	.extern	_ADCDATA0L
	.extern	_ADCCTL1
	.extern	_T2CCRH
	.extern	_T2H
	.extern	_PP5H
	.extern	_PWM5H0
	.extern	_PWM5H1
	.extern	_P0LR
	.extern	_P2LR
	.extern	_P1LR
	.extern	_P3LR
	.extern	_TR3
	.extern	_EIE3
	.extern	_EIF3
	.extern	_OSCCAL2
	.extern	_OSCCAL3
	.extern	_T3CTL
	.extern	_T3L
	.extern	_PP5L
	.extern	_T3CTL1
	.extern	_T2CCRL
	.extern	_PWM5L0
	.extern	_PWM5L1
	.extern	_PWM5CTL0
	.extern	_PWM5CTL1
	.extern	_P5ASCTL
	.extern	_PSTRCTL
	.extern	_T3H
	.extern	_PUR1
	.extern	_PUR2
	.extern	_INTEDGCTL
	.extern	_VBIASCTL
	.extern	_VBIAS1EN
	.extern	_VBIAS2EN
	.extern	_PWM5OC
	.extern	_T2CTL1
	.extern	_VDAC
	.extern	_PWM5CTL2
	.extern	_PWM5PC
	.extern	_RSCTL
	.extern	_TXSDR
	.extern	_RXSDR
	.extern	_BRCTL
	.extern	_TSCTL
	.extern	_EUBRGL
	.extern	_EUBRGH
	.extern	_SSCICTL0
	.extern	_SSCICTL1
	.extern	_SSCISTA
	.extern	_SSCIBUFR
	.extern	_SSCIADD
	.extern	_SSCIMSK
	.extern	_WDTPS
	.extern	_MULAH
	.extern	_MULAL
	.extern	_MULBH
	.extern	_MULBL
	.extern	_MULCTL
	.extern	_MULRES3
	.extern	_MULRES2
	.extern	_MULRES1
	.extern	_MULRES0
	.extern	_DIVCTL
	.extern	_DIVAH
	.extern	_DIVAL
	.extern	_DIVB
	.extern	_DIVQH
	.extern	_DIVQL
	.extern	_DIVR
	.extern	_LEDCTL
	.extern	_LEDPRE
	.extern	_LEDDATA0
	.extern	_LEDDATA1
	.extern	_LEDDATA2
	.extern	_LEDDATA3
	.extern	_LEDDATA4
	.extern	_LEDDATA5
	.extern	_LEDDATA6
	.extern	_LEDDATA7
	.extern	_C1FILTCTL
	.extern	_C1FILTPRE
	.extern	_LEDOMS1
	.extern	_CCRL
	.extern	_CCPCTL
	.extern	_CCRH
	.extern	_LEDODS0
	.extern	_LEDOMS0
	.extern	_LEDODS1
	.extern	_VRECAL2
	.extern	_VRECAL3
	.extern	_LEDLUM
	.extern	_PWM5FC
	.extern	_T4L
	.extern	_T4H
	.extern	_T4REL
	.extern	_T4REH
	.extern	_T4CTL
	.extern	_RC32KCAL

	.extern I0R1
	.extern I0R7
	.extern I0PSW
	.extern I0PCH
	.extern I1R1
	.extern I1R7
	.extern I1PSW
	.extern I1PCH
	.extern STK11
	.extern STK10
	.extern STK09
	.extern STK08
	.extern STK07
	.extern STK06
	.extern STK05
	.extern STK04
	.extern STK03
	.extern STK02
	.extern STK01
	.extern STK00
;--------------------------------------------------------
; global declarations
;--------------------------------------------------------
	.global	_SPI_RW_DATA
	.global	_SPI_Init

;--------------------------------------------------------
; global definitions
;--------------------------------------------------------
;--------------------------------------------------------
; absolute symbol definitions
;--------------------------------------------------------
;--------------------------------------------------------
; compiler-defined variables
;--------------------------------------------------------
UDL_SPI_0	.udata
r0x1000	.res	1
;--------------------------------------------------------
; initialized data
;--------------------------------------------------------
;--------------------------------------------------------
; overlayable items in internal ram 
;--------------------------------------------------------
;	.udata_ovr


func._SPI_RW_DATA	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _SPI_RW_DATA	;Function start
; 2 exit points
;has an exit
;; Starting PostCode block
;	::->op : LABEL
;	::->op : FUNCTION
_SPI_RW_DATA	;Function start
; 2 exit points
;	::->op : RECEIVE
;	.line	41; "../SPI.c"	uchar SPI_RW_DATA(uchar temp)
	BANKSEL	_SSCIBUFR
	MOV	_SSCIBUFR, R0
;	::->op : LABEL
;	::->op : GET_VALUE_AT_ADDRESS
_00007_DS_
;	.line	44; "../SPI.c"	while(!SSCIIF);
	BANKSEL	_EIF2_bits
	JB	_EIF2_bits, 0
	JMP	_00007_DS_
;	::->op :*  =
;	.line	45; "../SPI.c"	SSCIIF=0;
	BANKSEL	_EIF2_bits
	CLR	_EIF2_bits, 0
;	::->op : RETURN
;	.line	46; "../SPI.c"	return SSCIBUFR;
	BANKSEL	_SSCIBUFR
	MOVZ	R0, _SSCIBUFR
;	::->op : LABEL
;	::->op : ENDFUNCTION
	CRET	
; exit point of _SPI_RW_DATA



func._SPI_Init	.code
;***
;  PostBlock Stats: dbName = C
;***
;entry:  _SPI_Init	;Function start
; 2 exit points
;has an exit
;1 compiler assigned register :
;   r0x1000
;; Starting PostCode block
;	::->op : LABEL
;	::->op : FUNCTION
_SPI_Init	;Function start
; 2 exit points
;	::->op : RECEIVE
;	.line	9; "../SPI.c"	void SPI_Init(unsigned char MODE)
	BANKSEL	r0x1000
	MOV	r0x1000, R0
;	::->op : EQ_OP
;	.line	12; "../SPI.c"	if(MODE == MODE_Master)
	BANKSEL	r0x1000
	MOVZ	R0, r0x1000
	XOR	R0,# 0x01
	JB	PSW, 2
	JMP	_00002_DS_
;	::->op :*  =
;	.line	14; "../SPI.c"	TR10=0;	TR11=1;	TR37=0;	TR35=0;
	BANKSEL	_TR1_bits
	CLR	_TR1_bits, 0
;	::->op :*  =
	BANKSEL	_TR1_bits
	SET	_TR1_bits, 1
;	::->op :*  =
	BANKSEL	_TR3_bits
	CLR	_TR3_bits, 7
;	::->op :*  =
	BANKSEL	_TR3_bits
	CLR	_TR3_bits, 5
;	::->op :*  =
;	.line	15; "../SPI.c"	SPI_SS_PIN=1;
	BANKSEL	_P3LR_bits
	SET	_P3LR_bits, 5
;	::->op :*  =
;	.line	17; "../SPI.c"	SSCIEN=0;				//关闭SPI模块，初始化完之后再打开
	BANKSEL	_SSCICTL0_bits
	CLR	_SSCICTL0_bits, 5
;	::->op : =
;	.line	18; "../SPI.c"	SSCICTL0=0x02;			//SPI 主控模式，时钟 = 工作时钟/64
	MOV	R0,# 0x02
	BANKSEL	_SSCICTL0
	MOV	_SSCICTL0, R0
;	::->op : =
;	.line	19; "../SPI.c"	SSCICTL1=0x00;
	BANKSEL	_SSCICTL1
	CLR	_SSCICTL1
;	::->op : =
;	.line	20; "../SPI.c"	SSCISTA=0x00;
	BANKSEL	_SSCISTA
	CLR	_SSCISTA
;	::->op :*  =
;	.line	21; "../SPI.c"	MODE4
	BANKSEL	_SSCICTL0_bits
	SET	_SSCICTL0_bits, 4
;	::->op :*  =
	BANKSEL	_SSCISTA_bits
	SET	_SSCISTA_bits, 6
;	::->op :*  =
;	.line	22; "../SPI.c"	SSCIEN=1;
	BANKSEL	_SSCICTL0_bits
	SET	_SSCICTL0_bits, 5
;	::->op :*  =
;	.line	23; "../SPI.c"	SSCIIE=0;				//关闭SPI中断
	BANKSEL	_EIE2_bits
	CLR	_EIE2_bits, 0
;	::->op :*  =
;	.line	24; "../SPI.c"	SSCIIF=0;				//清零SPI中断标志
	BANKSEL	_EIF2_bits
	CLR	_EIF2_bits, 0
;	::->op : GOTO
	JMP	_00004_DS_
;	::->op : LABEL
;	::->op :*  =
_00002_DS_
;	.line	28; "../SPI.c"	TR10=1;	TR11=1;	TR37=0;	TR36=1;
	BANKSEL	_TR1_bits
	SET	_TR1_bits, 0
;	::->op :*  =
	BANKSEL	_TR1_bits
	SET	_TR1_bits, 1
;	::->op :*  =
	BANKSEL	_TR3_bits
	CLR	_TR3_bits, 7
;	::->op :*  =
	BANKSEL	_TR3_bits
	SET	_TR3_bits, 6
;	::->op :*  =
;	.line	30; "../SPI.c"	SSCIEN=0;				//关闭SPI模块，初始化完之后再打开
	BANKSEL	_SSCICTL0_bits
	CLR	_SSCICTL0_bits, 5
;	::->op : =
;	.line	31; "../SPI.c"	SSCICTL0=0x04;			//SPI 从动模式，时钟 = SCK 引脚。使能SS引脚控制。
	MOV	R0,# 0x04
	BANKSEL	_SSCICTL0
	MOV	_SSCICTL0, R0
;	::->op : =
;	.line	32; "../SPI.c"	SSCICTL1=0x00;
	BANKSEL	_SSCICTL1
	CLR	_SSCICTL1
;	::->op : =
;	.line	33; "../SPI.c"	SSCISTA=0x00;
	BANKSEL	_SSCISTA
	CLR	_SSCISTA
;	::->op :*  =
;	.line	34; "../SPI.c"	MODE4
	BANKSEL	_SSCICTL0_bits
	SET	_SSCICTL0_bits, 4
;	::->op :*  =
	BANKSEL	_SSCISTA_bits
	SET	_SSCISTA_bits, 6
;	::->op :*  =
;	.line	35; "../SPI.c"	SSCIEN=1;
	BANKSEL	_SSCICTL0_bits
	SET	_SSCICTL0_bits, 5
;	::->op :*  =
;	.line	36; "../SPI.c"	SSCIIE=0;				//打开SPI中断
	BANKSEL	_EIE2_bits
	CLR	_EIE2_bits, 0
;	::->op :*  =
;	.line	37; "../SPI.c"	SSCIIF=0;				//清零SPI中断标志
	BANKSEL	_EIF2_bits
	CLR	_EIF2_bits, 0
;	::->op : LABEL
;	::->op : ENDFUNCTION
_00004_DS_
	CRET	
; exit point of _SPI_Init


;	code size estimation:
;	   42+   33 =    75 instructions (  216 byte)


	.end
