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

📄 httpd.s

📁 uIP是免费的TCP/IP协议栈,我们将它移植到我们的AVR以太网开发板中
💻 S
📖 第 1 页 / 共 2 页
字号:
	ldd R2,z+0
	movw R24,R28
	movw R30,R10
	sbiw R30,6
	add R30,R24
	adc R31,R25
	std z+0,R2
	.dbline 307
	movw R24,R10
	adiw R24,1
	movw R10,R24
	.dbline 308
L56:
	.dbline 304
; 		  while((uip_appdata[i] != ISO_dot) && (uip_appdata[i] != ISO_space))
	lds R2,_uip_appdata
	lds R3,_uip_appdata+1
	movw R4,R10
	add R4,R2
	adc R5,R3
	movw R30,R4
	ldd R24,z+0
	cpi R24,46
	breq L58
	cpi R24,32
	brne L55
L58:
	.dbline 309
; 		  {
; 		   opfn[i-6]=uip_appdata[i];
; 		   i++;
; 		  }
; 		  opfn[i-6]='\r';	 
	movw R24,R28
	movw R30,R10
	sbiw R30,6
	add R30,R24
	adc R31,R25
	ldi R24,13
	std z+0,R24
	.dbline 310
; 		  fs_open(opfn, &fsfile);
	movw R18,R28
	subi R18,248  ; offset = 8
	sbci R19,255
	movw R16,R28
	xcall _fs_open
	.dbline 311
; 		if(!fs_open((char *)&uip_appdata[5], &fsfile))
	movw R18,R28
	subi R18,248  ; offset = 8
	sbci R19,255
	lds R16,_uip_appdata
	lds R17,_uip_appdata+1
	subi R16,251  ; offset = 5
	sbci R17,255
	xcall _fs_open
	cpi R16,0
	cpc R16,R17
	brne L41
X2:
	.dbline 312
; 		{
	.dbline 313
; 		  PRINTLN("couldn't open file");
	.dbline 315
; 		  //fs_open(file_404_html.name, &fsfile);
; 		}
	.dbline 317
; 		
;       } 
	.dbline 318
; 	 }
	xjmp L41
L40:
	.dbline 320
; 	 else
; 	 {
	.dbline 322
; 	  /* If it isn't a GET,*/
; 	 uip_abort();
	ldi R24,32
	sts _uip_flags,R24
	.dbline 323
; 	 return;
	xjmp L8
L41:
L22:
	.dbline 328
; 	 }
; 	  
; 	  
; 	 
;       if(uip_appdata[4] == ISO_slash &&
	lds R30,_uip_appdata
	lds R31,_uip_appdata+1
	ldd R24,z+4
	cpi R24,47
	brne L61
	lds R30,_uip_appdata
	lds R31,_uip_appdata+1
	ldd R24,z+5
	cpi R24,99
	brne L61
	lds R30,_uip_appdata
	lds R31,_uip_appdata+1
	ldd R24,z+6
	cpi R24,103
	brne L61
	lds R30,_uip_appdata
	lds R31,_uip_appdata+1
	ldd R24,z+7
	cpi R24,105
	brne L61
	lds R30,_uip_appdata
	lds R31,_uip_appdata+1
	ldd R24,z+8
	cpi R24,47
	brne L61
	.dbline 332
; 	  uip_appdata[5] == ISO_c &&
; 	  uip_appdata[6] == ISO_g &&
; 	  uip_appdata[7] == ISO_i &&
; 	  uip_appdata[8] == ISO_slash) {
	.dbline 335
; 	/* If the request is for a file that starts with "/cgi/", we
;            prepare for invoking a script. */	
; 	 hs->script = fsfile.data;
	ldd R2,y+8
	ldd R3,y+9
	lds R30,_hs
	lds R31,_hs+1
	std z+6,R3
	std z+5,R2
	.dbline 336
; 	 next_scriptstate();
	xcall _next_scriptstate
	.dbline 337
	xjmp L62
L61:
	.dbline 337
;       } else {
	.dbline 338
; 	hs->script = NULL;
	clr R2
	clr R3
	lds R30,_hs
	lds R31,_hs+1
	std z+6,R3
	std z+5,R2
	.dbline 342
; 	/* The web server is now no longer in the HTTP_NOGET state, but
; 	   in the HTTP_FILE state since is has now got the GET from
; 	   the client and will start transmitting the file. */
; 	hs->state = HTTP_FILE;
	ldi R24,1
	std z+0,R24
	.dbline 346
; 
; 	/* Point the file pointers in the connection state to point to
; 	   the first byte of the file. */
; 	hs->dataptr = fsfile.data;
	ldd R2,y+8
	ldd R3,y+9
	lds R30,_hs
	lds R31,_hs+1
	std z+4,R3
	std z+3,R2
	.dbline 347
; 	hs->count = fsfile.len;	
	ldd R2,y+10
	ldd R3,y+11
	std z+2,R3
	std z+1,R2
	.dbline 348
;       }     
L62:
	.dbline 349
;     }
L19:
	.dbline 352
; 
;     
;     if(hs->state != HTTP_FUNC) {
	lds R30,_hs
	lds R31,_hs+1
	ldd R24,z+0
	cpi R24,3
	brne X18
	xjmp L64
X18:
	.dbline 352
	.dbline 357
;       /* Check if the client (remote end) has acknowledged any data that
; 	 we've previously sent. If so, we move the file pointer further
; 	 into the file and send back more data. If we are out of data to
; 	 send, we close the connection. */
;       if(uip_acked()) {
	lds R2,_uip_flags
	sbrs R2,0
	rjmp L65
	.dbline 357
	.dbline 358
; 	if(hs->count >= uip_conn->len) {
	lds R30,_uip_conn
	lds R31,_uip_conn+1
	ldd R2,z+16
	ldd R3,z+17
	lds R30,_hs
	lds R31,_hs+1
	ldd R4,z+1
	ldd R5,z+2
	cp R4,R2
	cpc R5,R3
	brlo L68
	.dbline 358
	.dbline 359
; 	  hs->count -= uip_conn->len;
	movw R24,R30
	adiw R24,1
	lds R30,_uip_conn
	lds R31,_uip_conn+1
	ldd R4,z+16
	ldd R5,z+17
	movw R30,R24
	ldd R6,z+0
	ldd R7,z+1
	sub R6,R4
	sbc R7,R5
	std z+1,R7
	std z+0,R6
	.dbline 360
; 	  hs->dataptr += uip_conn->len;
	lds R24,_hs
	lds R25,_hs+1
	adiw R24,3
	movw R30,R24
	ldd R4,z+0
	ldd R5,z+1
	lds R30,_uip_conn
	lds R31,_uip_conn+1
	ldd R6,z+16
	ldd R7,z+17
	add R6,R4
	adc R7,R5
	movw R30,R24
	std z+1,R7
	std z+0,R6
	.dbline 361
	xjmp L69
L68:
	.dbline 361
; 	} else {
	.dbline 362
; 	  hs->count = 0;
	clr R2
	clr R3
	lds R30,_hs
	lds R31,_hs+1
	std z+2,R3
	std z+1,R2
	.dbline 363
; 	}
L69:
	.dbline 365
; 	
; 	if(hs->count == 0) {
	lds R30,_hs
	lds R31,_hs+1
	ldd R2,z+1
	ldd R3,z+2
	tst R2
	brne L65
	tst R3
	brne L65
X3:
	.dbline 365
	.dbline 366
; 	  if(hs->script != NULL) {
	lds R30,_hs
	lds R31,_hs+1
	ldd R2,z+5
	ldd R3,z+6
	tst R2
	brne X4
	tst R3
	breq L72
X4:
	.dbline 366
	.dbline 367
; 	    next_scriptline();
	xcall _next_scriptline
	.dbline 368
; 	    next_scriptstate();
	xcall _next_scriptstate
	.dbline 369
	xjmp L65
L72:
	.dbline 369
; 	  } else {
	.dbline 370
; 	    uip_close();
	ldi R24,16
	sts _uip_flags,R24
	.dbline 371
; 	  }
	.dbline 372
; 	}
	.dbline 373
;       }         
	.dbline 374
	xjmp L65
L64:
	.dbline 374
;     } else {
	.dbline 376
;       /* Call the CGI function. */
;       if(cgitab[hs->script[2] - ISO_a](uip_acked())) {
	lds R16,_uip_flags
	andi R16,1
	lds R30,_hs
	lds R31,_hs+1
	push R26
	push R27
	ldd R26,z+5
	ldd R27,z+6
	movw R30,R26
	pop R27
	pop R26
	ldd R2,z+2
	ldi R24,2
	mul R24,R2
	movw R30,R0
	ldi R24,<_cgitab-194
	ldi R25,>_cgitab-194
	add R30,R24
	adc R31,R25
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	xcall xicall
	tst R16
	breq L74
	.dbline 376
	.dbline 379
; 	/* If the function returns non-zero, we jump to the next line
;            in the script. */
; 	next_scriptline();
	xcall _next_scriptline
	.dbline 380
; 	next_scriptstate();
	xcall _next_scriptstate
	.dbline 381
;       }
L74:
	.dbline 382
;     }
L65:
	.dbline 384
; 
;     if(hs->state != HTTP_FUNC && !uip_poll()) {
	lds R30,_hs
	lds R31,_hs+1
	ldd R24,z+0
	cpi R24,3
	breq L8
	lds R2,_uip_flags
	sbrc R2,3
	rjmp L8
	.dbline 384
L79:
	.dbline 387
;       /* Send a piece of data, but not more than the MSS of the
; 	 connection. */
;       uip_send(hs->dataptr, hs->count);
	.dbline 387
	lds R30,_hs
	lds R31,_hs+1
	ldd R2,z+3
	ldd R3,z+4
	sts _uip_sappdata+1,R3
	sts _uip_sappdata,R2
	.dbline 387
	ldd R2,z+1
	ldd R3,z+2
	sts _uip_slen+1,R3
	sts _uip_slen,R2
	.dbline 387
	.dbline 387
	.dbline 388
;     }
	.dbline 393
; 
; 	
;     /* Finally, return to uIP. Our outgoing packet will soon be on its
;        way... */
;     return;
	xjmp L8
L9:
	.dbline 397
	ldi R24,32
	sts _uip_flags,R24
	.dbline 398
L10:
	.dbline -2
L8:
	adiw R28,12
	xcall pop_gset4x
	.dbline 0 ; func end
	ret
	.dbsym l fsfile 8 S[fs_file]
	.dbsym l opfn 0 A[8:8]c
	.dbsym r i 10 s
	.dbsym r j 10 I
	.dbsym r post_data 12 c
	.dbend
	.dbfunc s next_scriptline _next_scriptline fV
	.even
_next_scriptline:
	.dbline -1
	.dbline 407
; 
;   default:
;     /* Should never happen. */
;     uip_abort();
;     break;
;   }  
; }
; /*-----------------------------------------------------------------------------------*/
; /* next_scriptline():
;  *
;  * Reads the script until it finds a newline. */
; static void
; next_scriptline(void)
; {
L83:
	.dbline 409
;   /* Loop until we find a newline character. */
;   do {
	.dbline 410
;     ++(hs->script);
	lds R24,_hs
	lds R25,_hs+1
	adiw R24,5
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	adiw R24,1
	std z+1,R25
	std z+0,R24
	.dbline 411
L84:
	.dbline 411
;   } while(hs->script[0] != ISO_nl);
	lds R30,_hs
	lds R31,_hs+1
	ldd R26,z+5
	ldd R27,z+6
	ld R24,x
	cpi R24,10
	brne L83
	.dbline 414
; 
;   /* Eat up the newline as well. */
;   ++(hs->script);
	adiw R30,5
	ldd R24,z+0
	ldd R25,z+1
	adiw R24,1
	std z+1,R25
	std z+0,R24
	.dbline -2
L82:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc s next_scriptstate _next_scriptstate fV
;         fsfile -> y+0
;              i -> R12
	.even
_next_scriptstate:
	xcall push_gset4x
	sbiw R28,4
	.dbline -1
	.dbline 423
; }
; /*-----------------------------------------------------------------------------------*/
; /* next_sciptstate:
;  *
;  * Reads one line of script and decides what to do next.
;  */
; static void
; next_scriptstate(void)
; {
L87:
	.dbline 428
;   struct fs_file fsfile;
;   u8_t i;
; 
;  again:
;   switch(hs->script[0]) {
	lds R30,_hs
	lds R31,_hs+1
	ldd R26,z+5
	ldd R27,z+6
	ld R10,x
	clr R11
	movw R24,R10
	cpi R24,99
	ldi R30,0
	cpc R25,R30
	brne X22
	xjmp L96
X22:
	ldi R24,99
	cp R24,R10
	cpc R25,R11
	brlt L105
L104:
	movw R24,R10
	cpi R24,35
	ldi R30,0
	cpc R25,R30
	brne X23
	xjmp L102
X23:
	cpi R24,35
	ldi R30,0
	cpc R25,R30
	brge X24
	xjmp L88
X24:
L106:
	movw R24,R10
	cpi R24,46
	ldi R30,0
	cpc R25,R30
	brne X25
	xjmp L103
X25:
	xjmp L88
L105:
	movw R24,R10
	cpi R24,105
	ldi R30,0
	cpc R25,R30
	brne X26
	xjmp L98
X26:
	cpi R24,105
	ldi R30,0
	cpc R25,R30
	brge X27
	xjmp L88
X27:
L107:
	movw R24,R10
	cpi R24,116
	ldi R30,0
	cpc R25,R30
	breq L91
	xjmp L88
X19:
	.dbline 428
L91:
	.dbline 431
;   case ISO_t:
;     /* Send a text string. */
;     hs->state = HTTP_TEXT;
	ldi R24,2
	lds R30,_hs
	lds R31,_hs+1
	std z+0,R24
	.dbline 432
;     hs->dataptr = &hs->script[2];
	lds R30,_hs
	lds R31,_hs+1
	ldd R24,z+5
	ldd R25,z+6
	adiw R24,2
	std z+4,R25
	std z+3,R24
	.dbline 435
	clr R12
	xjmp L95
L92:
	.dbline 435
L93:
	.dbline 435
	inc R12
L95:
	.dbline 435
; 
;     /* Calculate length of string. */
;     for(i = 0; hs->dataptr[i] != ISO_nl; ++i);
	lds R30,_hs
	lds R31,_hs+1
	ldd R2,z+3
	ldd R3,z+4
	mov R30,R12
	clr R31
	add R30,R2
	adc R31,R3
	ldd R24,z+0
	cpi R24,10
	brne L92
	.dbline 436
;     hs->count = i;    
	mov R2,R12
	clr R3
	lds R30,_hs
	lds R31,_hs+1
	std z+2,R3
	std z+1,R2
	.dbline 437
;     break;
	xjmp L89
L96:
	.dbline 440
;   case ISO_c:
;     /* Call a function. */
;     hs->state = HTTP_FUNC;
	ldi R24,3
	lds R30,_hs
	lds R31,_hs+1
	std z+0,R24
	.dbline 441
;     hs->dataptr = NULL;
	clr R2
	clr R3
	lds R30,_hs
	lds R31,_hs+1
	std z+4,R3
	std z+3,R2
	.dbline 442
;     hs->count = 0;
	std z+2,R3
	std z+1,R2
	.dbline 443
;     cgitab[hs->script[2] - ISO_a](0);
	clr R16
	push R26
	push R27
	ldd R26,z+5
	ldd R27,z+6
	movw R30,R26
	pop R27
	pop R26
	ldd R2,z+2
	ldi R24,2
	mul R24,R2
	movw R30,R0
	ldi R24,<_cgitab-194
	ldi R25,>_cgitab-194
	add R30,R24
	adc R31,R25
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	xcall xicall
	.dbline 444
;     break;
	xjmp L89
L98:
	.dbline 447
;   case ISO_i:   
;     /* Include a file. */
;     hs->state = HTTP_FILE;
	ldi R24,1
	lds R30,_hs
	lds R31,_hs+1
	std z+0,R24
	.dbline 448
;     if(!fs_open(&hs->script[2], &fsfile)) {
	movw R18,R28
	lds R30,_hs
	lds R31,_hs+1
	ldd R16,z+5
	ldd R17,z+6
	subi R16,254  ; offset = 2
	sbci R17,255
	xcall _fs_open
	cpi R16,0
	cpc R16,R17
	brne L99
X20:
	.dbline 448
	.dbline 449
;       uip_abort();
	ldi R24,32
	sts _uip_flags,R24
	.dbline 450
;     }
L99:
	.dbline 451
;     hs->dataptr = fsfile.data;
	ldd R2,y+0
	ldd R3,y+1
	lds R30,_hs
	lds R31,_hs+1
	std z+4,R3
	std z+3,R2
	.dbline 452
;     hs->count = fsfile.len;
	ldd R2,y+2
	ldd R3,y+3
	std z+2,R3
	std z+1,R2
	.dbline 453
;     break;
	xjmp L89
L102:
	.dbline 456
;   case ISO_hash:
;     /* Comment line. */
;     next_scriptline();
	xcall _next_scriptline
	.dbline 457
;     goto again;
	xjmp L87
X21:
	.dbline 458
;     break;
L103:
	.dbline 461
;   case ISO_period:
;     /* End of script. */
;     hs->state = HTTP_END;
	ldi R24,4
	lds R30,_hs
	lds R31,_hs+1
	std z+0,R24
	.dbline 462
;     uip_close();
	ldi R24,16
	sts _uip_flags,R24
	.dbline 463
;     break;
	xjmp L89
L88:
	.dbline 465
	ldi R24,32
	sts _uip_flags,R24
	.dbline 466
L89:
	.dbline -2
L86:
	adiw R28,4
	xcall pop_gset4x
	.dbline 0 ; func end
	ret
	.dbsym l fsfile 0 S[fs_file]
	.dbsym r i 12 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\httpd.c
_hs::
	.blkb 2
	.dbstruct 0 7 httpd_state
	.dbfield 0 state c
	.dbfield 1 count s
	.dbfield 3 dataptr pc
	.dbfield 5 script pc
	.dbend
	.dbsym e hs _hs pS[httpd_state]

⌨️ 快捷键说明

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