⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppp.s

📁 在串口上PPP拨号上网的源程序(实现PPP协议栈)
💻 S
📖 第 1 页 / 共 4 页
字号:
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	ldd R0,y+62
	ldd R1,y+63
	std z+1,R1
	std z+0,R0
	.dbline 290
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	movw R30,R0
	adiw R30,1
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	clr R3
	movw R30,R28
	subi R30,192  ; addi 64
	sbci R31,255
	ldd R0,z+0
	ldd R1,z+1
	sub R0,R2
	sbc R1,R3
	movw R30,R28
	subi R30,192  ; addi 64
	sbci R31,255
	std z+1,R1
	std z+0,R0
	.dbline 291
	ldd R30,y+62
	ldd R31,y+63
	adiw R30,1
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	clr R3
	ldd R0,y+62
	ldd R1,y+63
	add R0,R2
	adc R1,R3
	std y+63,R1
	std y+62,R0
	.dbline 292
	inc R10
	.dbline 293
L123:
	.dbline 286
; 		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; 		case LCP_CONFIG_ACK:
; 
; 		     while(length0)
	movw R30,R28
	subi R30,192  ; addi 64
	sbci R31,255
	ldd R0,z+0
	ldd R1,z+1
	tst R0
	breq X28
	xjmp L122
X28:
	tst R1
	breq X29
	xjmp L122
X29:
X8:
	.dbline 294
; 			  {
; 			    temp_buffer1[j]=InBuffer[length1];
; 				temp_buffer2[j]=length1;
; 				length0-=InBuffer[length1+1];
; 				length1+=InBuffer[length1+1];
; 				j++;
; 			  }//end of while(length0)
; 			  if((temp_buffer1[i]==LCP_OPT_MRU))
	movw R24,R28
	adiw R24,42
	mov R30,R22
	clr R31
	add R30,R24
	adc R31,R25
	ldd R24,z+0
	cpi R24,1
	brne L125
	.dbline 295
; 			    {
	.dbline 296
; 				 MRU=((((WORD)InBuffer[temp_buffer2[i]+2])<<8)+InBuffer [temp_buffer2[i]+3]);
	ldi R24,2
	mul R24,R22
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	movw R30,R2
	adiw R30,3
	add R30,R24
	adc R31,R25
	ldd R4,z+0
	movw R30,R2
	adiw R30,2
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	mov R3,R2
	mov R2,R4
	sts _MRU+1,R3
	sts _MRU,R2
	.dbline 297
; 				}
L125:
	.dbline 298
; 			 IPAssignPacket();
	xcall _IPAssignPacket
	.dbline 300
; 			 		
; 		break;
	xjmp L62
L127:
	.dbline 304
; 
; 		//++++++++++++++++++++++++++++++++++++++++++++++++++++
; 		case LCP_CONFIG_NAK:	
; 		           local_magic_num[0]=InBuffer[10];
	lds R2,_InBuffer+10
	sts _local_magic_num,R2
	.dbline 305
; 			       local_magic_num[1]=InBuffer[11];
	lds R2,_InBuffer+11
	sts _local_magic_num+1,R2
	.dbline 306
; 			       local_magic_num[2]=InBuffer[12];
	lds R2,_InBuffer+12
	sts _local_magic_num+2,R2
	.dbline 307
; 	               local_magic_num[3]=InBuffer[13];
	lds R2,_InBuffer+13
	sts _local_magic_num+3,R2
	.dbline 308
; 			   Move (InBuffer, OutBuffer, InBuffer[7]+4);
	lds R24,_InBuffer+7
	clr R25
	adiw R24,4
	std y+1,R25
	std y+0,R24
	ldi R18,<_OutBuffer
	ldi R19,>_OutBuffer
	ldi R16,<_InBuffer
	ldi R17,>_InBuffer
	xcall _Move
	.dbline 309
; 			   OutBuffer[4]=LCP_CONFIG_REQUEST;
	ldi R24,1
	sts _OutBuffer+4,R24
	.dbline 310
; 			   ProcPPPSend ((BYTE *)OutBuffer, OutBuffer[7] + 6);
	lds R18,_OutBuffer+7
	subi R18,250    ; addi 6
	ldi R16,<_OutBuffer
	ldi R17,>_OutBuffer
	xcall _ProcPPPSend
	.dbline 311
; 		break;
	xjmp L62
X9:
	.dbline 315
; 
; 		//++++++++++++++++++++++++++++++++++++++++++++++++++++
; 		case LCP_CONFIG_REJECT:
; 		break;
L139:
	.dbline 319
; 		
; 		//++++++++++++++++++++++++++++++++++++++++++++++++++++
; 		case LCP_TERMINATE_ACK:			// Terminate ACK!
; 			PPPStatus &= ~LinkOn;
	lds R24,_PPPStatus
	andi R24,223
	sts _PPPStatus,R24
	.dbline 320
; 		break;
	.dbline 322
; 	}
; 	return;
	.dbline -2
L62:
	adiw R28,63
	adiw R28,3  ; offset = 66
	xcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym r nak 14 c
	.dbsym r rej 20 c
	.dbsym l length0 64 i
	.dbsym l temp_buffer1 42 A[20:20]c
	.dbsym r j 10 c
	.dbsym l temp_buffer2 2 A[40:20]i
	.dbsym l length1 62 i
	.dbsym r i 22 c
	.dbend
	.dbfunc s HandleIPCPOptions _HandleIPCPOptions fV
;            nak -> R20
;            rej -> R22
;   temp_buffer1 -> y+42
;   temp_buffer2 -> y+2
;        length0 -> y+62
;              j -> R12
;              i -> R14
;        length1 -> R10,R11
	.even
_HandleIPCPOptions:
	xcall push_gset5
	sbiw R28,63
	sbiw R28,1  ; offset = 64
	.dbline -1
	.dbline 325
; }
; 
; static void HandleIPCPOptions (void) {
	.dbline 327
; 
; WORD length0=0;
	clr R0
	clr R1
	std y+63,R1
	std y+62,R0
	.dbline 328
; WORD length1=8;
	ldi R24,8
	ldi R25,0
	movw R10,R24
	.dbline 329
; BYTE rej=0;
	clr R22
	.dbline 330
; BYTE nak=0;
	clr R20
	.dbline 331
; BYTE i=0;
	clr R14
	.dbline 332
; BYTE j=0;
	clr R12
	.dbline 336
	lds R20,_InBuffer+4
	clr R21
	cpi R20,1
	ldi R30,0
	cpc R21,R30
	breq L145
	cpi R20,2
	ldi R30,0
	cpc R21,R30
	brne X32
	xjmp L175
X32:
	cpi R20,3
	ldi R30,0
	cpc R21,R30
	brne X33
	xjmp L186
X33:
	cpi R20,4
	ldi R30,0
	cpc R21,R30
	brne X34
	xjmp L142
X34:
	xjmp L141
X30:
	.dbline 336
; BYTE temp_buffer1[20];
; WORD temp_buffer2[20];
; 
; 	switch (InBuffer [4] ) {
L145:
	.dbline 338
; 		case IPCP_CONFIG_REQUEST:
; 		     length0=InBuffer[7]-4;
	lds R24,_InBuffer+7
	clr R25
	sbiw R24,4
	std y+63,R25
	std y+62,R24
	xjmp L148
L147:
	.dbline 340
	.dbline 341
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	movw R30,R10
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	movw R24,R28
	adiw R24,42
	mov R30,R12
	clr R31
	add R30,R24
	adc R31,R25
	std z+0,R2
	.dbline 342
	ldi R24,2
	mul R24,R12
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	std z+1,R11
	std z+0,R10
	.dbline 343
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	movw R30,R10
	adiw R30,1
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	clr R3
	ldd R0,y+62
	ldd R1,y+63
	sub R0,R2
	sbc R1,R3
	std y+63,R1
	std y+62,R0
	.dbline 344
	movw R30,R10
	adiw R30,1
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	clr R3
	add R10,R2
	adc R11,R3
	.dbline 345
	inc R12
	.dbline 346
L148:
	.dbline 339
; 			  while(length0)
	ldd R0,y+62
	ldd R1,y+63
	tst R0
	breq X35
	xjmp L147
X35:
	tst R1
	breq X36
	xjmp L147
X36:
X31:
	.dbline 347
; 			  {
; 			    temp_buffer1[j]=InBuffer[length1];
; 				temp_buffer2[j]=length1;
; 				length0-=InBuffer[length1+1];
; 				length1+=InBuffer[length1+1];
; 				j++;
; 			  }//end of while(length0)
; 			  Move (InBuffer, OutBuffer, 8);
	ldi R24,8
	ldi R25,0
	std y+1,R25
	std y+0,R24
	ldi R18,<_OutBuffer
	ldi R19,>_OutBuffer
	ldi R16,<_InBuffer
	ldi R17,>_InBuffer
	xcall _Move
	.dbline 348
; 			  length1=8;
	ldi R24,8
	ldi R25,0
	movw R10,R24
	.dbline 349
; 			  OutBuffer[7]=4;
	ldi R24,4
	sts _OutBuffer+7,R24
	.dbline 350
; 		     for(i=0;i<j;i++)
	clr R14
	xjmp L154
L151:
	.dbline 351
; 			 {
	.dbline 352
; 			   if(temp_buffer1[i]!=0x03)
	movw R24,R28
	adiw R24,42
	mov R30,R14
	clr R31
	add R30,R24
	adc R31,R25
	ldd R24,z+0
	cpi R24,3
	brne X37
	xjmp L155
X37:
	.dbline 353
; 			   {
	.dbline 354
; 			    Move (&InBuffer[temp_buffer2[i]],&OutBuffer[length1],InBuffer[temp_buffer2[i]+1]);
	ldi R24,2
	mul R24,R14
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	movw R30,R2
	adiw R30,1
	add R30,R24
	adc R31,R25
	ldd R4,z+0
	clr R5
	std y+1,R5
	std y+0,R4
	ldi R24,<_OutBuffer
	ldi R25,>_OutBuffer
	movw R18,R10
	add R18,R24
	adc R19,R25
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	movw R16,R2
	add R16,R24
	adc R17,R25
	xcall _Move
	.dbline 355
; 			    OutBuffer[7]+=InBuffer[temp_buffer2[i]+1];
	ldi R24,2
	mul R24,R14
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	push R26
	push R27
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	pop R27
	pop R26
	adiw R30,1
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	lds R3,_OutBuffer+7
	add R3,R2
	sts _OutBuffer+7,R3
	.dbline 356
; 				length1+=InBuffer[temp_buffer2[i]+1];    
	ldi R24,2
	mul R24,R14
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	push R26
	push R27
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	pop R27
	pop R26
	adiw R30,1
	ldi R24,<_InBuffer
	ldi R25,>_InBuffer
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	clr R3
	add R10,R2
	adc R11,R3
	.dbline 357
; 			    rej = 1;
	ldi R22,1
	.dbline 358
; 			   }
L155:
	.dbline 359
L152:
	.dbline 350
	inc R14
L154:
	.dbline 350
	cp R14,R12
	brsh X38
	xjmp L151
X38:
	.dbline 360
; 			 }
; 			   if(rej == 1)
	cpi R22,1
	brne L158
	.dbline 361
; 			   {
	.dbline 362
; 			    OutBuffer [4] = LCP_CONFIG_REJECT;
	ldi R24,4
	sts _OutBuffer+4,R24
	.dbline 363
; 			    ProcPPPSend ((BYTE *)OutBuffer, OutBuffer[7] + 6);	
	lds R18,_OutBuffer+7
	subi R18,250    ; addi 6
	ldi R16,<_OutBuffer
	ldi R17,>_OutBuffer
	xcall _ProcPPPSend
	.dbline 364
; 				return;
	xjmp L140
L158:
	.dbline 367
; 			   }//end of if(rej == 1)
; 			   
; 		     if (InBuffer [8] == 0x03) {			// Reply of the only IPCP Request we can send
	lds R24,_InBuffer+8
	cpi R24,3
	breq X39
	xjmp L142
X39:
	.dbline 367
	.dbline 368
; 				remote_IPAddress [0] = InBuffer [10];		// ISP assigned IP address
	lds R2,_InBuffer+10
	sts _remote_IPAddress,R2
	.dbline 369
; 				remote_IPAddress [1] = InBuffer [11];		
	lds R2,_InBuffer+11
	sts _remote_IPAddress+1,R2
	.dbline 370
; 				remote_IPAddress [2] = InBuffer [12];
	lds R2,_InBuffer+12
	sts _remote_IPAddress+2,R2
	.dbline 371
; 				remote_IPAddress [3] = InBuffer [13];
	lds R2,_InBuffer+13
	sts _remote_IPAddress+3,R2
	.dbline 372
; 				Move (InBuffer, OutBuffer, InBuffer[7]+4);
	lds R24,_InBuffer+7
	clr R25
	adiw R24,4
	std y+1,R25
	std y+0,R24
	ldi R18,<_OutBuffer
	ldi R19,>_OutBuffer
	ldi R16,<_InBuffer
	ldi R17,>_InBuffer
	xcall _Move
	.dbline 373
; 				OutBuffer[4]=IPCP_CONFIG_ACK;
	ldi R24,2
	sts _OutBuffer+4,R24
	.dbline 374
; 				ProcPPPSend ((BYTE *)OutBuffer, OutBuffer[7] + 6);
	lds R18,_OutBuffer+7
	subi R18,250    ; addi 6
	ldi R16,<_OutBuffer
	ldi R17,>_OutBuffer
	xcall _ProcPPPSend
	.dbline 375
; 				PPPStatus |= LinkOn;			// PPP Link is now up
	lds R24,_PPPStatus
	ori R24,32
	sts _PPPStatus,R24
	.dbline 376
; 			} 	
	.dbline 378
; 			
; 		break;
	xjmp L142
L175:
	.dbline 381
; 
; 		case IPCP_CONFIG_ACK:
; 			if (InBuffer [8] == 3) {			// Reply of the only IPCP Request we can send
	lds R24,_InBuffer+8
	cpi R24,3
	brne L142
	.dbline 381
	.dbline 382
; 				local_IPAddress [0] = InBuffer [10];		// ISP assigned IP address
	lds R2,_InBuffer+10
	sts _local_IPAddress,R2
	.dbline 383
; 				local_IPAddress [1] = InBuffer [11];		
	lds R2,_InBuffer+11
	sts _local_IPAddress+1,R2
	.dbline 384
; 				local_IPAddress [2] = InBuffer [12];
	lds R2,_InBuffer+12
	sts _local_IPAddress+2,R2
	.dbline 385
; 				local_IPAddress [3] = InBuffer [13];
	lds R2,_InBuffer+13
	sts _local_IPAddress+3,R2
	.dbline 387
; 				
; 			}
	.dbline 388
; 		break;
	xjmp L142
L186:
	.dbline 391
; 
; 		case IPCP_CONFIG_NAK:
; 			if (InBuffer [8] == 0x03) {
	lds R24,_InBuffer+8
	cpi R24,3
	brne L142
	.dbline 391
	.dbline 393
; 					/// Request IP Address ////
; 					Move (InBuffer, OutBuffer, InBuffer[7]+6);
	lds R24,_InBuffer+7
	clr R25
	adiw R24,6
	std y+1,R25
	std y+0,R24
	ldi R18,<_OutBuffer
	ldi R19,>_OutBuffer
	ldi R16,<_InBuffer
	ldi R17,>_InBuffer
	xcall _Move
	.dbline 394
; 					OutBuffer [4] = IPCP_CONFIG_REQUEST;
	ldi R24,1
	sts _OutBuffer+4,R24
	.dbline 395
; 					ProcPPPSend ((BYTE *)OutBuffer, OutBuffer[7] + 6);
	lds R18,_OutBuffer+7
	subi R18,250    ; addi 6
	ldi R16,<_OutBuffer
	ldi R17,>_OutBuffer
	xcall _ProcPPPSend
	.dbline 396
; 			}
	.dbline 397
; 		break;
	.dbline 400
; 		
; 		case IPCP_CONFIG_REJECT:
; 		break;
L141:
L142:
	.dbline -2
	.dbline 403
; 	}
; 
; }
L140:
	adiw R28,63
	adiw R28,1  ; offset = 64
	xcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym r nak 20 c
	.dbsym r rej 22 c
	.dbsym l temp_buffer1 42 A[20:20]c
	.dbsym l temp_buffer2 2 A[40:20]i
	.dbsym l length0 62 i
	.dbsym r j 12 c
	.dbsym r i 14 c
	.dbsym r length1 10 i
	.dbend
	.area bss(ram, con, rel)
	.dbfile G:\sppp\PPP.C
_remote_IPAddress::
	.blkb 4
	.dbsym e remote_IPAddress _remote_IPAddress A[4:4]c
_local_IPAddress::
	.blkb 4
	.dbsym e local_IPAddress _local_IPAddress A[4:4]c
_OutBuffer::
	.blkb 1201
	.dbsym e OutBuffer _OutBuffer A[1201:1201]c
_InBuffer::
	.blkb 1201
	.dbsym e InBuffer _InBuffer A[1201:1201]c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -