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

📄 ppp.s

📁 AVR单片机系统开发经典实例部分源程序
💻 S
📖 第 1 页 / 共 5 页
字号:
	.even
_PPP_WeRejectedStr::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 205
; }
; 
; bool PPP_WeRejectedStr(u8 type)
; {
	.dbline 206
; 	if (!SendDebugRStr(ppp_str3)) return false;
	ldi R16,<_ppp_str3
	ldi R17,>_ppp_str3
	xcall _SendDebugRStr
	tst R16
	brne L32
	.dbline 206
	clr R16
	xjmp L31
L32:
	.dbline 207
; 	sprintf((char*)ScratchPad, "%u\n", type);
	mov R2,R20
	clr R3
	std y+1,R3
	std y+0,R2
	ldi R18,<L27
	ldi R19,>L27
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _sprintf
	.dbline 208
; 	return SendDebugStr((char*)ScratchPad);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	.dbline -2
L31:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r type 20 c
	.dbend
	.dbfunc e PPP_DisplayPacket _PPP_DisplayPacket fc
;             dw -> y+6
;              j -> R22,R23
;     CodeHeader -> R20,R21
;           type -> R12
;       Protocol -> R14,R15
;            len -> R10
;              i -> y+10
;          Bytes -> y+22
;             Tx -> R20
	.even
_PPP_DisplayPacket::
	st -y,r19
	st -y,r18
	xcall push_gset5
	mov R20,R16
	sbiw R28,12
	.dbline -1
	.dbline 212
; }
; 
; bool PPP_DisplayPacket(bool Tx, u16 Bytes)
; {
	.dbline 218
; 	u8				type, len;
; 	u16				i, j, Protocol;
; 	u32				dw;
; 	T_CodeHeader	*CodeHeader;
; 
; 	i = 0;
	clr R0
	clr R1
	std y+11,R1
	std y+10,R0
	.dbline 219
; 	j = ntohs(*(u16*)(MainBuffer + i));				//
	ldi R24,<_MainBuffer
	ldi R25,>_MainBuffer
	movw R30,R0
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	ldd R17,z+1
	xcall _ntohs
	movw R22,R16
	.dbline 220
; 	if (j == 0xff03) i += 2;						// the address/control fields are present (no ACFC)
	cpi R16,3
	ldi R30,255
	cpc R17,R30
	brne L35
	.dbline 220
	ldd R24,y+10
	ldd R25,y+11
	adiw R24,2
	std y+11,R25
	std y+10,R24
L35:
	.dbline 222
; 													//
; 	if (MainBuffer[i] & 0x01)						//
	ldi R24,<_MainBuffer
	ldi R25,>_MainBuffer
	ldd R30,y+10
	ldd R31,y+11
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sbrs R2,0
	rjmp L37
	.dbline 223
; 		Protocol = (u16)MainBuffer[i++];			// the protocol field has been compressed
	ldd R2,y+10
	ldd R3,y+11
	movw R24,R2
	adiw R24,1
	std y+11,R25
	std y+10,R24
	ldi R24,<_MainBuffer
	ldi R25,>_MainBuffer
	movw R30,R2
	add R30,R24
	adc R31,R25
	ldd R14,z+0
	clr R15
	xjmp L38
L37:
	.dbline 225
; 	else											//
; 	{												//
	.dbline 226
; 		Protocol = ntohs(*(u16*)(MainBuffer + i));	// no PFC
	ldi R24,<_MainBuffer
	ldi R25,>_MainBuffer
	ldd R30,y+10
	ldd R31,y+11
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	ldd R17,z+1
	xcall _ntohs
	movw R14,R16
	.dbline 227
; 		i += 2;										//
	ldd R24,y+10
	ldd R25,y+11
	adiw R24,2
	std y+11,R25
	std y+10,R24
	.dbline 228
; 	}												//
L38:
	.dbline 230
; 													//
; 	if (Protocol == PPP_IP) return true;			// let the IP routine display the packet
	movw R24,R14
	cpi R24,33
	ldi R30,0
	cpc R25,R30
	brne L39
	.dbline 230
	ldi R16,1
	xjmp L34
L39:
	.dbline 235
; 
; 	// ********************
; 	// display the protocol
; 
; 	if (Tx)
	tst R20
	breq L41
	.dbline 236
; 		strcpy((char*)ScratchPad, "\nT");
	ldi R18,<L43
	ldi R19,>L43
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strcpy
	xjmp L42
L41:
	.dbline 238
; 	else
; 		strcpy((char*)ScratchPad, "\nR");
	ldi R18,<L44
	ldi R19,>L44
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strcpy
L42:
	.dbline 239
; 	strcat((char*)ScratchPad, "X: Protocol: ");
	ldi R18,<L45
	ldi R19,>L45
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strcat
	.dbline 240
; 	switch (Protocol)
	movw R24,R14
	cpi R24,33
	ldi R30,128
	cpc R25,R30
	breq L49
	cpi R24,33
	ldi R30,128
	cpc R25,R30
	brlt L46
L52:
	movw R24,R14
	cpi R24,33
	ldi R30,192
	cpc R25,R30
	breq L48
	cpi R24,35
	ldi R30,192
	cpc R25,R30
	breq L50
	xjmp L46
X0:
	.dbline 241
; 	{
L48:
	.dbline 242
; 		case PPP_LCP	:	rstrcpy((char*)ScratchPad + strlen((char*)ScratchPad), LCPStr);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strlen
	ldi R18,<_LCPStr
	ldi R19,>_LCPStr
	ldi R24,<_ScratchPad
	ldi R25,>_ScratchPad
	add R16,R24
	adc R17,R25
	xcall _rstrcpy
	.dbline 243
; 							break;
	xjmp L47
L49:
	.dbline 244
; 		case PPP_IPCP	:	rstrcpy((char*)ScratchPad + strlen((char*)ScratchPad), IPCPStr);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strlen
	ldi R18,<_IPCPStr
	ldi R19,>_IPCPStr
	ldi R24,<_ScratchPad
	ldi R25,>_ScratchPad
	add R16,R24
	adc R17,R25
	xcall _rstrcpy
	.dbline 245
; 							break;
	xjmp L47
L50:
	.dbline 246
; 		case PPP_PAP	:	rstrcpy((char*)ScratchPad + strlen((char*)ScratchPad), PAPStr);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strlen
	ldi R18,<_PAPStr
	ldi R19,>_PAPStr
	ldi R24,<_ScratchPad
	ldi R25,>_ScratchPad
	add R16,R24
	adc R17,R25
	xcall _rstrcpy
	.dbline 247
; 							break;
	xjmp L47
L46:
	.dbline 248
; 		default			:	sprintf((char*)ScratchPad + strlen((char*)ScratchPad), "%04x\n", Protocol);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strlen
	std y+1,R15
	std y+0,R14
	ldi R18,<L51
	ldi R19,>L51
	ldi R24,<_ScratchPad
	ldi R25,>_ScratchPad
	add R16,R24
	adc R17,R25
	xcall _sprintf
	.dbline 249
; 							return SendDebugStr((char*)ScratchPad);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	xjmp L34
L47:
	.dbline 251
; 	}
; 	sprintf((char*)ScratchPad + strlen((char*)ScratchPad), " [%04x]", Protocol);
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strlen
	std y+1,R15
	std y+0,R14
	ldi R18,<L53
	ldi R19,>L53
	ldi R24,<_ScratchPad
	ldi R25,>_ScratchPad
	add R16,R24
	adc R17,R25
	xcall _sprintf
	.dbline 252
; 	if (!SendDebugStr((char*)ScratchPad)) return false;
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	tst R16
	brne L54
	.dbline 252
	clr R16
	xjmp L34
L54:
	.dbline 257
; 
; 	// ********************
; 	// display the code header
; 
; 	CodeHeader = (T_CodeHeader *)(MainBuffer + i);
	ldi R24,<_MainBuffer
	ldi R25,>_MainBuffer
	ldd R20,y+10
	ldd R21,y+11
	add R20,R24
	adc R21,R25
	.dbline 258
; 	i += sizeof(T_CodeHeader);
	ldd R24,y+10
	ldd R25,y+11
	adiw R24,4
	std y+11,R25
	std y+10,R24
	.dbline 260
; 
; 	if (!SendDebugRStr(CodeStr)) return false;
	ldi R16,<_CodeStr
	ldi R17,>_CodeStr
	xcall _SendDebugRStr
	tst R16
	brne L56
	.dbline 260
	clr R16
	xjmp L34
L56:
	.dbline 261
; 	switch (CodeHeader->Code)
	movw R30,R20
	ldd R10,z+0
	clr R11
	movw R24,R10
	cpi R24,1
	ldi R30,0
	cpc R25,R30
	brne X3
	xjmp L61
X3:
	cpi R24,2
	ldi R30,0
	cpc R25,R30
	brne X4
	xjmp L62
X4:
	cpi R24,3
	ldi R30,0
	cpc R25,R30
	brne X5
	xjmp L63
X5:
	cpi R24,4
	ldi R30,0
	cpc R25,R30
	brne X6
	xjmp L64
X6:
	cpi R24,5
	ldi R30,0
	cpc R25,R30
	brne X7
	xjmp L65
X7:
	cpi R24,6
	ldi R30,0
	cpc R25,R30
	brne X8
	xjmp L66
X8:
	cpi R24,7
	ldi R30,0
	cpc R25,R30
	brne X9
	xjmp L67
X9:
	cpi R24,8
	ldi R30,0
	cpc R25,R30
	brne X10
	xjmp L68
X10:
	cpi R24,9
	ldi R30,0
	cpc R25,R30
	brne X11
	xjmp L69
X11:
	cpi R24,10
	ldi R30,0
	cpc R25,R30
	brne X12
	xjmp L70
X12:
	xjmp L58
X1:
	.dbline 262
; 	{
L61:
	.dbline 263
; 		case PPP_CREQ	:	rstrcpy((char*)ScratchPad, CREQStr);
	ldi R18,<_CREQStr
	ldi R19,>_CREQStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 264
; 							break;
	xjmp L59
L62:
	.dbline 265
; 		case PPP_CACK	:	rstrcpy((char*)ScratchPad, CACKStr);
	ldi R18,<_CACKStr
	ldi R19,>_CACKStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 266
; 							break;
	xjmp L59
L63:
	.dbline 267
; 		case PPP_CNAK	:	rstrcpy((char*)ScratchPad, CNAKStr);
	ldi R18,<_CNAKStr
	ldi R19,>_CNAKStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 268
; 							break;
	xjmp L59
L64:
	.dbline 269
; 		case PPP_CREJ	:	rstrcpy((char*)ScratchPad, CREJStr);
	ldi R18,<_CREJStr
	ldi R19,>_CREJStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 270
; 							break;
	xjmp L59
L65:
	.dbline 271
; 		case PPP_TREQ	:	rstrcpy((char*)ScratchPad, TREQStr);
	ldi R18,<_TREQStr
	ldi R19,>_TREQStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 272
; 							break;
	xjmp L59
L66:
	.dbline 273
; 		case PPP_TACK	:	rstrcpy((char*)ScratchPad, TACKStr);
	ldi R18,<_TACKStr
	ldi R19,>_TACKStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 274
; 							break;
	xjmp L59
L67:
	.dbline 275
; 		case PPP_CodeREJ:	rstrcpy((char*)ScratchPad, CodeREJStr);
	ldi R18,<_CodeREJStr
	ldi R19,>_CodeREJStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 276
; 							break;
	xjmp L59
L68:
	.dbline 277
; 		case PPP_PREJ	:	rstrcpy((char*)ScratchPad, PREJStr);
	ldi R18,<_PREJStr
	ldi R19,>_PREJStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 278
; 							break;
	xjmp L59
L69:
	.dbline 279
; 		case PPP_EREQ	:	rstrcpy((char*)ScratchPad, EREQStr);
	ldi R18,<_EREQStr
	ldi R19,>_EREQStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 280
; 							break;
	xjmp L59
L70:
	.dbline 281
; 		case PPP_ERPY	:	rstrcpy((char*)ScratchPad, ERPYStr);
	ldi R18,<_ERPYStr
	ldi R19,>_ERPYStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 282
; 							break;
	xjmp L59
L58:
	.dbline 283
; 		default			:	rstrcpy((char*)ScratchPad, UnknownCodeStr);
	ldi R18,<_UnknownCodeStr
	ldi R19,>_UnknownCodeStr
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _rstrcpy
	.dbline 284
; 							break;
L59:
	.dbline 286
; 	}
; 	sprintf((char*)ScratchPad + strlen((char*)ScratchPad), " [%u]  ID:%u   Len:%u\n",  CodeHeader->Code, CodeHeader->ID, ntohs(CodeHeader->Len));
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _strlen
	movw R2,R16
	movw R30,R20
	ldd R16,z+2
	ldd R17,z+3
	push R2
	push R3
	xcall _ntohs
	pop R3
	pop R2
	std y+5,R17
	std y+4,R16
	movw R30,R20
	ldd R4,z+1
	clr R5
	std y+3,R5
	std y+2,R4
	movw R30,R20
	ldd R4,z+0
	clr R5
	std y+1,R5
	std y+0,R4
	ldi R18,<L71
	ldi R19,>L71
	ldi R24,<_ScratchPad
	ldi R25,>_ScratchPad
	movw R16,R2
	add R16,R24
	adc R17,R25
	xcall _sprintf
	.dbline 287
; 	if (!SendDebugStr((char*)ScratchPad)) return false;
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	tst R16
	brne L72
	.dbline 287
	clr R16
	xjmp L34
L72:
	.dbline 292
; 
; 	// ********************
; 	// display the options (if any)
; 
; 	if ((Protocol == PPP_LCP) || (Protocol == PPP_IPCP))
	movw R24,R14
	cpi R24,33
	ldi R30,192
	cpc R25,R30
	breq L76
	cpi R24,33
	ldi R30,128
	cpc R25,R30
	breq X13
	xjmp L74
X13:
L76:
	.dbline 293
; 	{
	.dbline 294
; 		if ((CodeHeader->Code == PPP_CREQ) || (CodeHeader->Code == PPP_CACK) || (CodeHeader->Code == PPP_CNAK) || (CodeHeader->Code == PPP_CREJ))
	movw R30,R20
	ldd R2,z+0
	clr R3
	mov R24,R2
	cpi R24,1
	breq L81
	cpi R24,2
	breq L81
	cpi R24,3
	breq L81
	cpi R24,4
	breq X14
	xjmp L77
X14:
L81:
	.dbline 295
; 		{
	xjmp L83
L82:
	.dbline 297
; 			while ((i + 2) <= Bytes)
; 			{
	.dbline 298

⌨️ 快捷键说明

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