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

📄 http.asm

📁 web51的开发库
💻 ASM
字号:
.nolist.include	"param.inc".include	"8019.inc".list	.global	http	.global	open_http.equ	CR, 0x0D.equ	LF, 0x0A;	RSEG	CPU_BIT;;***** http *****	.bitcomm flagSecure, 1;	RSEG	CPU_DATA	.comm fileID, 2;	RSEG	CPU_ROM	.text;*************************************************************; http line parameters parser & exec;*************************************************************;state80table:	.equ	stateG0, 0	sjmp	port80g0	;0 'G'	sjmp	port80g1	;1 'E'	sjmp	port80g2	;2 'T'	sjmp	port80g3	;3 ' '	.equ	stateS0, 3	ljmp	port80s0	;4 compute checksum and wait				;  for '/' or ' ' or '?';http:;Acknowledge all received data;;  tx_eth_pkt.pkt.ip.ipdata.tcp.tcpheader.Ack =;;    rcvSeq + data_len;    	mov	r6,data_len    	mov	r7,data_len+1   	lcall	AckBytes	setb	flagSecure	;enable secured CGI;;  copy_r2s (buf, data_addr, sizeof(buf));	//and copy WWW requestgetnextbuf:	mov	r7,#buf	mov	r4,data_addr	mov	r5,data_addr+1	mov	r3,#LOW(sizeofbuf)      	lcall	short_r2_pr2s			;copy WWW request	mov	R0,#buf-1next80:	inc	R0	mov	a,#bufend	xrl	a,R0	jz	getnextbuf	mov	a,data_len	jnz	long80data	mov	a,data_len+1	jz	_next80searchlong80data:	mov	a,@R0	cjne	a,#CR,no80cr_exeurl:ljmp	exeurl_next80search:	ljmp	next80searchno80cr:	cjne	a,#LF,no80lf	sjmp	_exeurlno80lf:	jz	_exeurl;;  data_addr++;	inc	data_addr+1	;LSB	mov	a,data_addr+1	jnz	noinchidaddr	inc	data_addr	;MSBnoinchidaddr:;; data_len--;	dec	data_len+1	;LSB	mov	a,data_len+1	cjne	a,0xFF,nodecdlen	dec	data_len	;MSBnodecdlen:	mov	a,state80	add	a,acc		;sjmp = 2 byte	add	a,#LOW(state80table)	push	Acc		;push low addr	mov	a,#0	addc	a,#HIGH(state80table)	push	Acc		;push high addr	ret			;and Go!;;state 0 - wait for 'G'port80g0:mov	a,@R0	orl	a,#0x20		;G->g	cjne	a,#'g',next80	inc	state80		;state80 = 1	sjmp	next80;state 1 - wait for 'E'port80g1:mov	a,@R0	orl	a,#0x20		;E->e	cjne	a,#'e',reset80	inc	state80		;state80 = 2	sjmp	next80reset80:	mov	state80,#stateG0	sjmp	next80;state 2 - wait for 'T'port80g2:mov	a,@R0	orl	a,#0x20		;T->t	cjne	a,#'t',reset80	inc	state80		;state80 = 3	sjmp	next80;state 3 - wait for ' 'port80g3:mov	a,@R0	cjne	a,#' ',reset80	inc	state80		;state80 = 4	mov	fileID,#0	mov	fileID+1,#0	sjmp	next80;state 4 - wait for '/' or ' ' or '?'port80s0:mov	a,@R0	cjne	a,#'/',nolom	mov	fileID,#0	mov	fileID+1,#0	sjmp	next80nolom:	cjne	a,#' ',nospc	sjmp	exeurlnospc:	cjne	a,#'?',url80	sjmp	exeurlurl80:	add	a,fileID+1	mov	fileID+1,a	mov	a,fileID	addc	a,#0	mov	fileID,a	ljmp	next80;next80search:	setb	modeResend	;don't send FIN packet, wait for next packet	ret;badmethod:;;SendNotImplementedHeader	lcall	send_string	.asciz	"HTTP/1.1 501 Not Implemented\r\n\r\n"	REThttpnotfound:;;SendNotFoundHeader	lcall	send_string	.asciz	"HTTP/1.1 404 Not Found\r\n\r\n"	RETcgi:	ret;exeurl:	mov	a,state80	anl	a,#0b11111100	;>3	jz	badmethod	mov	state80,#8	;binary mode;	lcall	searchfile	;r4	file type				;dptr	file start				;r2r3	file end	jc	httpnotfound;	mov	a,r4	anl	a,#0b11111000	jnz	cgi	.using	0	push	ar2	;MSB file end	push	ar3	;LSB file end	push	dph	;MSB file start	push	dpl	;LSB file start	push	ar5	;filesystem ID	mov	a,r4	jz	_httpcont;;;SendHTTPheader	push	acc	;file type	lcall	send_string	.asciz	"HTTP/1.1 200 OK\r\nContent-type: "	pop	acc	;file type;	cjne	a,#1,notext;;SendTextHeader	lcall	send_string	.asciz	"text/html\r\n\r\n"	mov	state80,#0	;cgi mode_httpcont:ljmp	httpcontnotext:	cjne	a,#2,noplain;;SendPlainHeader	lcall	send_string	.asciz	"text/plain\r\n\r\n"	mov	state80,#0	;cgi mode	sjmp	httpcontnoplain:cjne	a,#3,nojpeg;;SendJPEGheader	lcall	send_string	.asciz	"image/jpeg\r\n\r\n"	sjmp	httpcontnojpeg:	cjne	a,#4,nogif;;SendGIFheader	lcall	send_string	.asciz	"image/gif\r\n\r\n"	sjmp	httpcontnogif:	cjne	a,#5,nopng;;SendPNGheader	lcall	send_string	.asciz	"image/png\r\n\r\n"	sjmp	httpcontnopng:	cjne	a,#6,httpcont;;SendAppHeader	lcall	send_string	.asciz	"application/octet-stream\r\n\r\n";httpcont:	.using	0	pop	Acc	;filesystem ID	pop	dpl	;LSB file start	pop	dph	;MSB file start	pop	ar3	;LSB file end	pop	ar2	;MSB file end	ljmp	sendFile;open_http:	mov	state80,#0	; reset url scanner	ret	;; END

⌨️ 快捷键说明

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