; .\AT89C51PRO.SRC generated from: AT89C51PRO.C
; COMPILER INVOKED BY:
;        f:\winsoft\Keil\C51\BIN\C51.EXE AT89C51PRO.C WARNINGLEVEL(1) OPTIMIZE(5,SIZE) REGFILE(.\E51Pro.ORC) BROWSE INCDIR(G:\MCU工程\E51Pro\) DEBUG OBJECTEXTEND CODE SRC(.\AT89C51PRO.SRC)

$NOMOD51

NAME	AT89C51PRO

P0	DATA	080H
P1	DATA	090H
P2	DATA	0A0H
P3	DATA	0B0H
AC	BIT	0D0H.6
T0	BIT	0B0H.4
T1	BIT	0B0H.5
EA	BIT	0A8H.7
IE	DATA	0A8H
P0_0	BIT	080H.0
P1_0	BIT	090H.0
P0_1	BIT	080H.1
FL	BIT	0D0H.1
P2_0	BIT	0A0H.0
P1_1	BIT	090H.1
P0_2	BIT	080H.2
P3_0	BIT	0B0H.0
P2_1	BIT	0A0H.1
P1_2	BIT	090H.2
P0_3	BIT	080H.3
P3_1	BIT	0B0H.1
P2_2	BIT	0A0H.2
P1_3	BIT	090H.3
P0_4	BIT	080H.4
P3_2	BIT	0B0H.2
P2_3	BIT	0A0H.3
P1_4	BIT	090H.4
P0_5	BIT	080H.5
RD	BIT	0B0H.7
P3_3	BIT	0B0H.3
P2_4	BIT	0A0H.4
P1_5	BIT	090H.5
P0_6	BIT	080H.6
P3_4	BIT	0B0H.4
P2_5	BIT	0A0H.5
P1_6	BIT	090H.6
P0_7	BIT	080H.7
P3_5	BIT	0B0H.5
ES	BIT	0A8H.4
P2_6	BIT	0A0H.6
P1_7	BIT	090H.7
P3_6	BIT	0B0H.6
P2_7	BIT	0A0H.7
IP	DATA	0B8H
P3_7	BIT	0B0H.7
RI	BIT	098H.0
CY	BIT	0D0H.7
INT0	BIT	0B0H.2
INT1	BIT	0B0H.3
TI	BIT	098H.1
PS	BIT	0B8H.4
SP	DATA	081H
OV	BIT	0D0H.2
WR	BIT	0B0H.6
SBUF	DATA	099H
PCON	DATA	087H
SCON	DATA	098H
TMOD	DATA	089H
TCON	DATA	088H
IE0	BIT	088H.1
IE1	BIT	088H.3
B	DATA	0F0H
ACC	DATA	0E0H
ET0	BIT	0A8H.1
ET1	BIT	0A8H.3
TF0	BIT	088H.5
ET2	BIT	0A8H.5
TF1	BIT	088H.7
RB8	BIT	098H.2
TH0	DATA	08CH
EX0	BIT	0A8H.0
IT0	BIT	088H.0
TH1	DATA	08DH
EX1	BIT	0A8H.2
TB8	BIT	098H.3
IT1	BIT	088H.2
P	BIT	0D0H.0
SM0	BIT	098H.7
TL0	DATA	08AH
SM1	BIT	098H.6
TL1	DATA	08BH
SM2	BIT	098H.5
PT0	BIT	0B8H.1
RS0	BIT	0D0H.3
PT1	BIT	0B8H.3
RS1	BIT	0D0H.4
PT2	BIT	0B8H.5
TR0	BIT	088H.4
TR1	BIT	088H.6
PX0	BIT	0B8H.0
PX1	BIT	0B8H.2
DPH	DATA	083H
DPL	DATA	082H
REN	BIT	098H.4
RXD	BIT	0B0H.0
TXD	BIT	0B0H.1
F0	BIT	0D0H.5
PSW	DATA	0D0H
?PR?SetPro00?AT89C51PRO                  SEGMENT CODE 
?BI?SetPro00?AT89C51PRO                  SEGMENT BIT OVERLAYABLE 
?PR?RstPro00?AT89C51PRO                  SEGMENT CODE 
?PR?ReadSign00?AT89C51PRO                SEGMENT CODE 
?PR?Erase00?AT89C51PRO                   SEGMENT CODE 
?PR?Write00?AT89C51PRO                   SEGMENT CODE 
?PR?Read00?AT89C51PRO                    SEGMENT CODE 
?PR?LockBit00?AT89C51PRO                 SEGMENT CODE 
?PR?Pro00?AT89C51PRO SEGMENT CODE 
	EXTRN	CODE (SendData)
	EXTRN	CODE (_Delay_ms)
	EXTRN	CODE (WaitData)
	EXTRN	CODE (SetVpp12V)
	EXTRN	CODE (SendResp)
	EXTRN	CODE (WaitResp)
	EXTRN	DATA (nAddress)
	EXTRN	DATA (ComBuf)
	EXTRN	DATA (n)
	EXTRN	CODE (SetVpp5V)
	PUBLIC	Pro00
	PUBLIC	LockBit00
	PUBLIC	Read00
	PUBLIC	Write00
	PUBLIC	Erase00
	PUBLIC	ReadSign00
	PUBLIC	RstPro00
	PUBLIC	?SetPro00?BIT
	PUBLIC	SetPro00

	RSEG  ?BI?SetPro00?AT89C51PRO
?SetPro00?BIT:
       bPro?040:   DBIT   1
; //FID=00--AT89C51系列的烧片程序
; #include <e51pro.h>
; 
; extern BYTE ComBuf[18];//串口通讯数据缓存，包括发送接收
; extern UINT nAddress;//地址计数
; extern UINT nTimeOut;
; extern UINT n;
; extern void Delay_ms(BYTE nMs);//延时函数
; extern void Delay_us(BYTE n2Us);
; extern BOOL WaitComm();//等待上位机的命令或数据
; extern BOOL WaitResp();
; extern BOOL WaitData();
; extern void SendData();//发送数据或回应命令 
; extern void SendResp();
; extern void SetVpp5V();//设置VPP=5V
; extern void SetVpp0V();//Vpp=0V
; extern void SetVpp12V();//Vpp=12V
; 
; 
; void SetPro00(BOOL bPro)//设置状态是编程状态还是运行状态

	RSEG  ?PR?SetPro00?AT89C51PRO
SetPro00:
	USING	0
			; SOURCE LINE # 20
; {
			; SOURCE LINE # 21
; 	if(bPro)//编程状态
			; SOURCE LINE # 22
	JNB  	bPro?040,?C0001
; 	{
			; SOURCE LINE # 23
; 		SetVpp5V();
			; SOURCE LINE # 24
	LCALL	SetVpp5V
; 		P3_5=1;//p3.5接RST
			; SOURCE LINE # 25
	SETB 	P3_5
; 		P3_2=1;//p3.2接#prog
			; SOURCE LINE # 26
	SETB 	P3_2
; 		P0=0xff;
			; SOURCE LINE # 27
	MOV  	P0,#0FFH
; 		P1=0xff;
			; SOURCE LINE # 28
	MOV  	P1,#0FFH
; 		P2=0xff;
			; SOURCE LINE # 29
	MOV  	P2,#0FFH
; 		P2_6=0;//先置成读模式
			; SOURCE LINE # 30
	CLR  	P2_6
; 		P2_7=0;
			; SOURCE LINE # 31
	CLR  	P2_7
; 		P3_6=1;
			; SOURCE LINE # 32
	SETB 	P3_6
; 		P3_7=1;
			; SOURCE LINE # 33
	SETB 	P3_7
; 		nAddress=0x0000;
			; SOURCE LINE # 34
	CLR  	A
	MOV  	nAddress,A
	MOV  	nAddress+01H,A
; 	}
			; SOURCE LINE # 35
	RET  	
?C0001:
; 	else//运行状态
; 	{
			; SOURCE LINE # 37
; 		SetVpp5V();
			; SOURCE LINE # 38
	LCALL	SetVpp5V
; 		P0=0xff;
			; SOURCE LINE # 39
	MOV  	P0,#0FFH
; 		P1=0xff;
			; SOURCE LINE # 40
	MOV  	P1,#0FFH
; 		P2=0xff;
			; SOURCE LINE # 41
	MOV  	P2,#0FFH
; 		P3_6=1;
			; SOURCE LINE # 42
	SETB 	P3_6
; 		P3_7=1;
			; SOURCE LINE # 43
	SETB 	P3_7
; 		P3_5=0;
			; SOURCE LINE # 44
	CLR  	P3_5
; 		P3_2=0;
			; SOURCE LINE # 45
	CLR  	P3_2
; 	}
			; SOURCE LINE # 46
; }
			; SOURCE LINE # 47
?C0003:
	RET  	
; END OF SetPro00

; 
; 
; void RstPro00()

	RSEG  ?PR?RstPro00?AT89C51PRO
RstPro00:
	USING	0
			; SOURCE LINE # 50
; {
			; SOURCE LINE # 51
; 	SetPro00(0);
			; SOURCE LINE # 52
	CLR  	?SetPro00?BIT
	LCALL	SetPro00
; 	SendData();
			; SOURCE LINE # 53
	LCALL	SendData
; }
			; SOURCE LINE # 54
	RET  	
; END OF RstPro00

; 
; void ReadSign00()

	RSEG  ?PR?ReadSign00?AT89C51PRO
ReadSign00:
	USING	0
			; SOURCE LINE # 56
; {
			; SOURCE LINE # 57
; 	SetPro00(1);
			; SOURCE LINE # 58
	SETB 	?SetPro00?BIT
	LCALL	SetPro00
; 	Delay_ms(1);
			; SOURCE LINE # 59
	MOV  	R7,#01H
	LCALL	_Delay_ms
; 	P2_6=0;
			; SOURCE LINE # 60
	CLR  	P2_6
; 	P2_7=0;
			; SOURCE LINE # 61
	CLR  	P2_7
; 	P3_6=0;
			; SOURCE LINE # 62
	CLR  	P3_6
; 	P3_7=0;
			; SOURCE LINE # 63
	CLR  	P3_7
; 	nAddress=0x0030;
			; SOURCE LINE # 64
	MOV  	nAddress,#00H
	MOV  	nAddress+01H,#030H
; 	P1=((BYTE*)(&nAddress))[1];
			; SOURCE LINE # 65
	MOV  	P1,nAddress+01H
; 	P2=((BYTE*)(&nAddress))[0];
			; SOURCE LINE # 66
	MOV  	P2,nAddress
; 	ComBuf[2]=P0;
			; SOURCE LINE # 67
	MOV  	ComBuf+02H,P0
; 	nAddress=0x0031;
			; SOURCE LINE # 68
	MOV  	nAddress,#00H
	MOV  	nAddress+01H,#031H
; 	P1=((BYTE*)(&nAddress))[1];
			; SOURCE LINE # 69
	MOV  	P1,nAddress+01H
; 	P2=((BYTE*)(&nAddress))[0];
			; SOURCE LINE # 70
	MOV  	P2,nAddress
; 	ComBuf[3]=P0;
			; SOURCE LINE # 71
	MOV  	ComBuf+03H,P0
; 	nAddress=0x0032;
			; SOURCE LINE # 72
	MOV  	nAddress,#00H
	MOV  	nAddress+01H,#032H
; 	P1=((BYTE*)(&nAddress))[1];
			; SOURCE LINE # 73
	MOV  	P1,nAddress+01H
; 	P2=((BYTE*)(&nAddress))[0];
			; SOURCE LINE # 74
	MOV  	P2,nAddress
; 	ComBuf[4]=P0;
			; SOURCE LINE # 75
	MOV  	ComBuf+04H,P0
; 	SetPro00(0);
			; SOURCE LINE # 76
	CLR  	?SetPro00?BIT
	LCALL	SetPro00
; 	SendData();
			; SOURCE LINE # 77
	LCALL	SendData
; }
			; SOURCE LINE # 78
	RET  	
; END OF ReadSign00

; 
; void Erase00()

	RSEG  ?PR?Erase00?AT89C51PRO
Erase00:
	USING	0
			; SOURCE LINE # 80
; {
			; SOURCE LINE # 81
; 	SetPro00(1);
			; SOURCE LINE # 82
	SETB 	?SetPro00?BIT
	LCALL	SetPro00
; 	P2_6=1;
			; SOURCE LINE # 83
	SETB 	P2_6
; 	P2_7=0;
			; SOURCE LINE # 84
	CLR  	P2_7
; 	P3_6=0;
			; SOURCE LINE # 85
	CLR  	P3_6
; 	P3_7=0;
			; SOURCE LINE # 86
	CLR  	P3_7
; 	Delay_ms(1);
			; SOURCE LINE # 87
	MOV  	R7,#01H
	LCALL	_Delay_ms
; 	SetVpp12V();
			; SOURCE LINE # 88
	LCALL	SetVpp12V
; 	Delay_ms(1);
			; SOURCE LINE # 89
	MOV  	R7,#01H
	LCALL	_Delay_ms
; 	P3_2=0;
			; SOURCE LINE # 90
	CLR  	P3_2
; 	Delay_ms(10);
			; SOURCE LINE # 91
	MOV  	R7,#0AH
	LCALL	_Delay_ms
; 	P3_2=1;
			; SOURCE LINE # 92
	SETB 	P3_2
; 	Delay_ms(1);
			; SOURCE LINE # 93
	MOV  	R7,#01H
	LCALL	_Delay_ms
; 	SetPro00(0);
			; SOURCE LINE # 94
	CLR  	?SetPro00?BIT
	LCALL	SetPro00
; 	SendData();
			; SOURCE LINE # 95
	LCALL	SendData
; }
			; SOURCE LINE # 96
	RET  	
; END OF Erase00

; 
; void Write00()

	RSEG  ?PR?Write00?AT89C51PRO
Write00:
	USING	0
			; SOURCE LINE # 98
; {
			; SOURCE LINE # 99
; 	SetPro00(1);
			; SOURCE LINE # 100
	SETB 	?SetPro00?BIT
	LCALL	SetPro00
; 	SendData();
			; SOURCE LINE # 101
	LCALL	SendData
?C0007:
; 	while(1)
			; SOURCE LINE # 102
; 	{
			; SOURCE LINE # 103
; 		if(WaitData())
			; SOURCE LINE # 104
	LCALL	WaitData
	JNC  	?C0008
; 		{
			; SOURCE LINE # 105
; 			if(ComBuf[0]==0x07)
			; SOURCE LINE # 106
	MOV  	A,ComBuf
	XRL  	A,#07H
	JNZ  	?C0008
; 			{
			; SOURCE LINE # 107
; 				for(n=0;n<=0x0f;n++)
			; SOURCE LINE # 108
	MOV  	n,A
	MOV  	n+01H,A
?C0011:
	SETB 	C
	MOV  	A,n+01H
	SUBB 	A,#0FH
	MOV  	A,n
	SUBB 	A,#00H
	JNC  	?C0012
; 				{
			; SOURCE LINE # 109
; 					P1=((BYTE*)(&nAddress))[1];
			; SOURCE LINE # 110
	MOV  	P1,nAddress+01H
; 					P2=((BYTE*)(&nAddress))[0];
			; SOURCE LINE # 111
	MOV  	P2,nAddress
; 					P2_6=0;
			; SOURCE LINE # 112
	CLR  	P2_6
; 					P2_7=1;
			; SOURCE LINE # 113
	SETB 	P2_7
; 					P3_6=1;
			; SOURCE LINE # 114
	SETB 	P3_6
; 					P3_7=1;
			; SOURCE LINE # 115
	SETB 	P3_7
; 					P3_2=1;
			; SOURCE LINE # 116
	SETB 	P3_2
; 					P0=ComBuf[n+2];
			; SOURCE LINE # 117
	MOV  	A,#LOW (ComBuf+02H)
	ADD  	A,n+01H
	MOV  	R0,A
	MOV  	A,@R0
	MOV  	P0,A
; 					SetVpp12V();
			; SOURCE LINE # 118
	LCALL	SetVpp12V
; 					//Delay_us(10);
; 					//P3_2=0;
; 					//Delay_us(10);
; 					//P3_2=1;
; 					//Delay_us(10);
; 					//SetVpp5V();
; 					//Delay_us(10);
; 					//P3_2=1;
; 					//Delay_us(200);
; 					//nTimeOut=0;
; 					//while(P0!=ComBuf[n+2])
; 					//{
; 					//	nTimeOut++;
; 					//	if(nTimeOut>=10000)
; 					//	{
; 					//		ComBuf[0]=0xff;
; 					//		SendResp();
; 					//		Delay_ms(10);
; 					//		ComBuf[0]=0;
; 					//		SendData();
; 					//		return;
; 					//	}
; 					//}
; 					nAddress++;
			; SOURCE LINE # 142
	INC  	nAddress+01H
	MOV  	A,nAddress+01H
	JNZ  	?C0037
	INC  	nAddress
?C0037:
; 					
; 				}
			; SOURCE LINE # 144
	INC  	n+01H
	MOV  	A,n+01H
	JNZ  	?C0038
	INC  	n
?C0038:
	SJMP 	?C0011
?C0012:
; 				ComBuf[0]=1;
			; SOURCE LINE # 145
	MOV  	ComBuf,#01H
; 				SendResp();
			; SOURCE LINE # 146
	LCALL	SendResp
; 			}
			; SOURCE LINE # 147
	SJMP 	?C0007
; 			else
; 				break;
			; SOURCE LINE # 149
; 		}
			; SOURCE LINE # 150
; 		else
; 			break;
			; SOURCE LINE # 152
; 	}
			; SOURCE LINE # 153
?C0008:
; 	ComBuf[0]=0;
			; SOURCE LINE # 154
	CLR  	A
	MOV  	ComBuf,A
; 	SendData();
			; SOURCE LINE # 155
	LCALL	SendData
; }
			; SOURCE LINE # 156
	RET  	
; END OF Write00

; 
; void Read00()

	RSEG  ?PR?Read00?AT89C51PRO
Read00:
	USING	0
			; SOURCE LINE # 158
; {
			; SOURCE LINE # 159
; 
; 	SetPro00(1);
			; SOURCE LINE # 161
	SETB 	?SetPro00?BIT
	LCALL	SetPro00
; 	SendData();
			; SOURCE LINE # 162
	LCALL	SendData
?C0017:
; 	while(1)
			; SOURCE LINE # 163
; 	{
			; SOURCE LINE # 164
; 		if(WaitResp())
			; SOURCE LINE # 165
	LCALL	WaitResp
	JNC  	?C0018
; 		{
			; SOURCE LINE # 166
; 			if(ComBuf[0])
			; SOURCE LINE # 167
	MOV  	A,ComBuf
	JZ   	?C0018
; 			{
			; SOURCE LINE # 168
; 				for(n=0;n<=0x0f;n++)
			; SOURCE LINE # 169
	CLR  	A
	MOV  	n,A
	MOV  	n+01H,A
?C0021:
	SETB 	C
	MOV  	A,n+01H
	SUBB 	A,#0FH
	MOV  	A,n
	SUBB 	A,#00H
	JNC  	?C0022
; 				{
			; SOURCE LINE # 170
; 						P1=((BYTE*)(&nAddress))[1];
			; SOURCE LINE # 171
	MOV  	P1,nAddress+01H
; 						P2=((BYTE*)(&nAddress))[0];
			; SOURCE LINE # 172
	MOV  	P2,nAddress
; 						P2_6=0;
			; SOURCE LINE # 173
	CLR  	P2_6
; 						P2_7=0;
			; SOURCE LINE # 174
	CLR  	P2_7
; 						P3_6=1;
			; SOURCE LINE # 175
	SETB 	P3_6
; 						P3_7=1;
			; SOURCE LINE # 176
	SETB 	P3_7
; 						ComBuf[n+2]=P0;	
			; SOURCE LINE # 177
	MOV  	A,#LOW (ComBuf+02H)
	ADD  	A,n+01H
	MOV  	R0,A
	MOV  	@R0,P0
; 						nAddress++;
			; SOURCE LINE # 178
	INC  	nAddress+01H
	MOV  	A,nAddress+01H
	JNZ  	?C0039
	INC  	nAddress
?C0039:
; 				}
			; SOURCE LINE # 179
	INC  	n+01H
	MOV  	A,n+01H
	JNZ  	?C0040
	INC  	n
?C0040:
	SJMP 	?C0021
?C0022:
; 				ComBuf[0]=6;
			; SOURCE LINE # 180
	MOV  	ComBuf,#06H
; 				SendData();
			; SOURCE LINE # 181
	LCALL	SendData
; 			}
			; SOURCE LINE # 182
	SJMP 	?C0017
; 			else
; 				break;
			; SOURCE LINE # 184
; 		}
			; SOURCE LINE # 185
; 		else
; 		{
			; SOURCE LINE # 187
; 			break;	
			; SOURCE LINE # 188
; 		}	
			; SOURCE LINE # 189
; 	}
			; SOURCE LINE # 190
?C0018:
; 	ComBuf[0]=0;
			; SOURCE LINE # 191
	CLR  	A
	MOV  	ComBuf,A
; 	SendData();
			; SOURCE LINE # 192
	LCALL	SendData
; }
			; SOURCE LINE # 193
	RET  	
; END OF Read00

; 
; void LockBit00()

	RSEG  ?PR?LockBit00?AT89C51PRO
LockBit00:
	USING	0
			; SOURCE LINE # 195
; {
			; SOURCE LINE # 196
; 	SendData();
			; SOURCE LINE # 197
	LCALL	SendData
; }
			; SOURCE LINE # 198
	RET  	
; END OF LockBit00

; 
; void Pro00()

	RSEG  ?PR?Pro00?AT89C51PRO
Pro00:
	USING	0
			; SOURCE LINE # 200
; {
			; SOURCE LINE # 201
; 	switch(ComBuf[0])
			; SOURCE LINE # 202
	MOV  	A,ComBuf
	DEC  	A
	JZ   	?C0030
	DEC  	A
	JZ   	?C0031
	DEC  	A
	JZ   	?C0032
	DEC  	A
	JZ   	?C0033
	DEC  	A
	JZ   	?C0034
	ADD  	A,#05H
	JNZ  	?C0036
; 	{
			; SOURCE LINE # 203
; 		case 0x00:
			; SOURCE LINE # 204
?C0029:
; 			RstPro00();
			; SOURCE LINE # 205
	LCALL	RstPro00
; 			break;
			; SOURCE LINE # 206
	RET  	
; 		case 0x01:
			; SOURCE LINE # 207
?C0030:
; 			ReadSign00();
			; SOURCE LINE # 208
	LCALL	ReadSign00
; 			break;
			; SOURCE LINE # 209
	RET  	
; 		case 0x02:
			; SOURCE LINE # 210
?C0031:
; 			Erase00();
			; SOURCE LINE # 211
	LCALL	Erase00
; 			break;
			; SOURCE LINE # 212
	RET  	
; 		case 0x03:
			; SOURCE LINE # 213
?C0032:
; 			Write00();
			; SOURCE LINE # 214
	LCALL	Write00
; 			break;
			; SOURCE LINE # 215
	RET  	
; 		case 0x04:
			; SOURCE LINE # 216
?C0033:
; 			Read00();
			; SOURCE LINE # 217
	LCALL	Read00
; 			break;
			; SOURCE LINE # 218
	RET  	
; 		case 0x05:
			; SOURCE LINE # 219
?C0034:
; 			LockBit00();
			; SOURCE LINE # 220
	LCALL	LockBit00
; 			break;
			; SOURCE LINE # 221
; 		default:
			; SOURCE LINE # 222
; 		break;
			; SOURCE LINE # 223
; 	}
			; SOURCE LINE # 224
; }
			; SOURCE LINE # 225
?C0036:
	RET  	
; END OF Pro00

	END
