龙空技术网

项目19 基于单片机与上位机通信系统的设计(汇编语言)

ying悦1SD 70

前言:

目前你们对“汇编语言jb指令怎么用”大约比较着重,小伙伴们都需要分析一些“汇编语言jb指令怎么用”的相关资讯。那么小编在网上网罗了一些对于“汇编语言jb指令怎么用””的相关内容,希望姐妹们能喜欢,你们一起来学习一下吧!

一,汇编源代码(注释乱码,其他正常)

 RXBUFFSTART		EQU 040H 		; ½ÓÊÕ¶ÓÁÐÊ×Ö· (170 ×Ö½Ú)			XBUFFSTART		EQU 050H 		; ·¢ËͶÓÁÐÊ×Ö· (170 ×Ö½Ú)			RXBUFFEND 		EQU 0F0H 		; ½ÓÊÕ»º³åÇø¶ÓÁÐÄ©Ö·			CMDANDLEN 		EQU 008H 		; ÃüÁî×Ö·û×î´ó³¤¶È			; ±à³ÌÑÓʱ			P15MS 		EQU 0C9H 			P1US 		EQU 0FEH 			P50US 		EQU 0D1H 			; ¿ØÖƼü			BACKSPACE 		EQU 008H 		; Í˺óɾ³ý¼ü ;ÄÚ²¿¼Ä´æÆ÷¶¨Òå			T2CON EQU 0C8H 		; T2 ¿ØÖƼĴæÆ÷			T2MOD EQU 0C9H 			TL2 EQU 0CCH 		; T2 ¼ÆÊý¼Ä´æÆ÷µÍ×Ö½Ú			TH2 EQU 0CDH 		; T2 ¼ÆÊý¼Ä´æÆ÷¸ß×Ö½Ú			TR2 EQU 0CAH 		; T2 Æô¶¯Î»			RCAP2L EQU 0CAH 		; T2 ¼ÆÊýÖØÔԼĴæÆ÷µÍ×Ö½Ú			RCAP2H EQU 0CBH 		; T2 ¼ÆÊýÖØÔԼĴæÆ÷¸ß×Ö½Ú			CHPCON EQU 0BFH 		; ÔÚϵͳ±à³Ì¿ØÖƼĴæÆ÷		 	CHPENR EQU 0F6H 			; ±à³Ì״̬Ï MTP ROM µÄ¿ØÖÆ ; ¿ØÖƱê־붨Òå			TXOKFLAG EQU 04H 		; ·¢ËÍ OK ±ê¼Ç			CMDSPACEFLAG 	EQU 06H 		; ÃüÁîɾ³ý OK ±ê¼Ç			RXCMDOKFLAG 	EQU 07H 		; ÃüÁî½ÓÊÕOK±ê¼Ç ; È«¾Ö±äÁ¿¶¨Òå ; ´®¿Ú				RXBUFFTAIL 	EQU 3BH 		; ½ÓÊÕ»º³åÇøβָÕë			RXBUFFHEAD EQU 3AH 		; ½ÓÊÕ»º³åÇøÍ·Ö¸Õë			RXBUFFLEN EQU 39H 		; ÃüÁ¶È¼ÆÊý			BLKCHK EQU 35H 		;			ORG 0000H			LJMP START			ORG 0003H 		; ÖжÏÈë¿Ú±í			RETI			ORG 000BH							RETI			ORG 0013H			RETI			ORG 001BH			RETI			ORG 0023H			LJMP S_INT			ORG 002BH			RETI			ORG 0080H ;ÔÚÏß±à³Ì¿ØÖÆ STARTAB: 	DB " online operation system", 00DH, 00AH			DB 	" Input ? to Help ", 0FFHFRQUTAB: 	DB 00DH, 00AH, "0) 38400 1) 19200 2)9600 3)4800 4)Exit Input: ", 0FFHB_TAB: 	DB 	0F6H, 0ECH, 0D9H, 0B2H, 0FFH 	;12.0000 MHzÉèÖÃ			;	¹¦ÄÜ¿ØÖÆCMDTAB: 	DB 	"?", 00DH, 00AH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH			DB 	00DH, 00AH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH			DB 	"OP5", 00DH, 00AH, 0FFH, 0FFH, 0FFH			DB 	"OP0", 00DH, 00AH, 0FFH, 0FFH, 0FFH			DB 	"OP1", 00DH, 00AH, 0FFH, 0FFH, 0FFH			DB 	"OP2", 00DH, 00AH, 0FFH, 0FFH, 0FFH			DB 	"OP3", 00DH, 00AH, 0FFH, 0FFH, 0FFH			DB 	"OP4", 00DH, 00AH, 0FFH, 0FFH, 0FFH			DB 	"SETB", 00DH, 00AH, 0FFH, 0FFH			DB 	"APROM", 00DH, 00AH, 0FFH			DB 	0FFH, 0FFH, 0FFH, 0FFHHLPTAB: 	DB 	00DH, 00AH			DB 	"	ÔÚÏß°ïÖúÃüÁî 	 ", 00DH,00AH			DB 	"************************************	", 00DH, 00AH			DB 	"*	?	Online	help	CMDand ", 00DH, 00AH			DB 	"* 	OP5 Operation 5 * 		 op0 Operation 0 *", 00DH, 00AH			DB 	"* SETB Set mcu baud rate * op2 Operation 2 *", 00DH, 00AH			DB 	"* OP1 Operation * 1 	 op3 Operation 3 *", 00DH, 00AH			DB 	"* 	APROM In APROM * op4 Operation 4 *",00DH, 00AH			DB 	"***", 0FFH, 0FFHROMMARKTAB:	DB 	00DH, 00AH, "pass:>", 0FFHCMDERROR: 	DB 	00DH, 00AH, "Bad CMDand", 0FFHWARNTAB: 	DB 	00DH, 00AH, "Are you sure (Y/N)", 0FFHINPUTTAB: 	DB 	00DH, 00AH, "Input: ", 0FFHINPUTERROR:	DB 	00DH, 00AH, "Error !!! Input: ", 0FFH ;³õʼ»¯³ÌÐòSTART: 	MOV R0, #0F0H 	; Çå CLR A 	; 01 µ½CLRAM: 	MOV @R0, A 	; F0			DJNZ R0, CLRAM 	; RAM			MOV P0, #0FFH 	; P0--P3ÖÃ1			MOV P1, #0FFH			MOV P2, #0FFH			MOV P3, #0FFH			MOV DPL, #00H 	; DPTRÇåÁã			MOV DPH, #00H			MOV PSW, #00H 		; ±êÖ¾¼Ä´æÆ÷ÇåÁã			MOV SP, #0F1H 	; ÉèÖöÑÕ»Ö¸Õë			MOV SCON, #50H 	; ´®¿Ú¹¤×÷ÓÚ·½Ê½ 1 £¬ÔÊÐí½ÓÊÕ			MOV TMOD, #11H 	; ¶¨Ê±Æ÷¹¤×÷·½Ê½ 1 £¬¶¨Ê±·½Ê½			MOV TH1, #0DBH 	; ÉèÖö¨Ê±Æ÷³õÖµ			MOV TL1, #0FFH			MOV T2CON,#30H 	; T2CON			MOV A, #01H 	; ÉèÖò¨ÌØÂÊ 0: 38400 1: 19200			LCALL B_SET 		; 2: 9600 3: 4800			SETB ES 	; ÔÊÐí´®¿ÚÖжÏ			SETB ET0 	; ÔÊÐí¶¨Ê±Æ÷ 0 ÖжÏ			SETB ET1 	; ÔÊÐí¶¨Ê±Æ÷ 1 ÖжÏ			MOV IP, #00H 	; µÍÓÅÏȼ¶			SETB TR1 	; Æô¶¯¶¨Ê±¼ÆÊýÆ÷ 1			SETB TR2 	; Æô¶¯¶¨Ê±¼ÆÊýÆ÷ 2			SETB REN 	; Æô¶¯´®¿Ú½ÓÊÕÖжÏ			CLR TI 	; Çå´®¿Ú·¢ËÍÖжϱê־λ			CLR RI 	; Çå´®¿Ú½ÓÊÕÖжϱê־λ			SETB EA 	; ¿ª·ÅËùÓÐÖжÏ			MOV RXBUFFHEAD, #RXBUFFSTART;			MOV RXBUFFTAIL, #RXBUFFSTART;			MOV DPTR, #STARTAB 	; ÔÚÖÕ¶ËÉÏÏÔʾ LOGO ×Ö·û			LCALL DIS_FUN 			MOV DPTR, #ROMMARKTAB 	; ÔÚÖÕ¶ËÉÏÏÔʾ LRM> ×Ö·û			LCALL DIS_FUN			;Ö÷³ÌÐòMAIN: 	LCALL CMD_GET			NOP									; ¿É¼ÓÈëÆäËü²Ù×÷³ÌÐò			CPL P2.0			LJMP MAIN			NOP			NOP			NOP			LJMP START			;»ñÈ¡ÃüÁî CMD_GET:	LCALL RG_CMD 			; Ë¢ÐÂÃüÁî·û			MOV A, RXBUFFTAIL 			XRL A, #RXBUFFSTART 			JZ RETT 			; ½ÓÊÕ»º³åÇø¿Õ²»´¦Àí			JNB RXCMDOKFLAG, RETT 			; ÃüÁî½ÓÊÕ²»³É¹¦²»´¦Àí			MOV A, RXBUFFLEN 				CLR C 				SUBB A, #CMDANDLEN 				JNC CMD_GERROR 			; ÃüÁî×Ö·û³¬³¤³ö´í			CLR A 			MOV R4, A 			; Çå²é±í¼ÆÊýÆ÷			MOV R5, #RXBUFFSTART 			; ÖýÓÊÕ»º³åÇøÊ×Ö·			MOV DPTR, #CMDTAB 			; ÖÃÃüÁî±íÊ×Ö·CMD_S: 	MOV A, R4 	MOVC A, @A+DPTR 			; ²é±íINC R4 	MOV R6, A 			; ÔÝ´æµ½ R6MOV A, R4 	JNZ CMD_OUT 	INC DPH 				; ¼ÆÊýÆ÷Òç³ö´¦ÀíCMD_OUT: 	MOV A, R5 INC R5 	MOV R0, A 	MOV A, @R0 				; ¶Á½ÓÊÕ»º³åÇøMOV R7, A 			; ÔÝ´æµ½ R7MOV A, R6 	XRL A, #0FFH 	JZ CMD_GERROR 			; ÊÇ·ñ³ö´íMOV A, R6 	XRL A, #0AH 	JZ CMD_SEND 			; ±È½Ï³É¹¦MOV A, R7 	XRL A, R6 	JZ CMD_S 			; È¥ÏÂÒ»¸ö±È½ÏMOV A, R6 	ADD A, #20H 	; Сд´¦ÀíXRL A, R7 	JZ CMD_S 			; È¥ÏÂÒ»¸ö±È½ÏMOV R5, #RXBUFFSTART		MOV A, R4 	MOV B, #CMDANDLEN 	DIV		AB				MOV B, #CMDANDLEN 	INC		A				MUL AB	 				; ±È½ÏÏÂÒ»¸öÃüÁîMOV R4, A 	LJMP CMD_S 	CMD_SEND: 	CLR A 	; ³õʼ»¯MOV RXBUFFLEN, A 	MOV RXBUFFTAIL, #RXBUFFSTART	CLR RXCMDOKFLAG 	MOV A, R4 	MOV B, #CMDANDLEN 	DIV AB 	; µ÷ÕûµØÖ·MOV B, A 	RL A 	ADD A, B 	MOV DPTR, #CMD_TAB 	JMP @A+DPTR 	RETT: 	RET 	CMD_GERROR:	MOV DPTR, #CMDERROR 		; ÏÔʾ Bad CMDandLCALL DIS_FUN 		CLR A 	; ³õʼ»¯MOV RXBUFFLEN, A 	MOV RXBUFFTAIL, #RXBUFFSTART	CLR RXCMDOKFLAG 	LJMP DISPROM 	RET 	CMD_TAB: 	LJMP	HLPLJMP DISPROMLJMP FUN_5LJMP FUN_0LJMP FUN_1LJMP FUN_2LJMP FUN_3LJMP FUN_4LJMP FUN_SETLJMP FUN_APROMRET			; ÃüÁî½âÊÍÆ÷¹¦ÄÜ´¦Àí×Ó³ÌÐò			;OP0 ¹¦ÄÜ´¦Àí FUN_0: 	CPL P2.0LCALL S_INTI ;LJMP DISPROM ; 			;OP1 ¹¦ÄÜ´¦ÀíFUN_1: 	CPL P2.1 	LCALL S_INTI 	LJMP DISPROM 			;OP2 ¹¦ÄÜ´¦ÀíFUN_2: 	CPL P2.2 	LCALL S_INTI 	LJMP DISPROM			;OP3 ¹¦ÄÜ´¦Àí FUN_3: 	CPL P2.3 	LCALL S_INTI 	LJMP DISPROM 			;OP4 ¹¦ÄÜ´¦ÀíFUN_4: 	CPL P2.4 	LCALL S_INTI 	LJMP DISPROM 			;OP5 ¹¦ÄÜ´¦ÀíFUN_5: 	CPL 	P2.5LCALL S_INTI ;LJMP DISPROM 			; HELP ÏÔʾ°ïÖúÐÅÏ¢ HLP: 	MOV DPTR, #HLPTAB 		; ÏÔʾ°ïÖúÐÅÏ¢LCALL 	DIS_FUN 	LCALL S_INTI 	LJMP DISPROM 			;SETB ¹¦ÄÜ´¦ÀíFUN_SET: 	MOV DPTR, #FRQUTAB 				LCALL DIS_FUN 				MOV DPTR, #INPUTTAB 				LCALL DIS_FUN 	SET_LOOP:	LCALL READWAIT 	MOV R0, #RXBUFFSTART 	MOV A, @R0 	MOV R7, A 	DEC R7 	SET_LOOP1: 	INC R7 	MOV RXBUFFTAIL, #RXBUFFSTART	XRL A, R7 	JNZ SET_LOOP1 	; ÊÇ·ñÓÐÊäÈëMOV A, @R0 	SUBB A, #30H 	MOV B, A 	MOV A, B 	XRL A, #04H ; ÊÇ·ñ ExitJZ SET_ERROR 	 	CLR C 	SUBB A, #05H ; ´óÓÚ 5 ÖØÊäJNC SET_RL ;MOV A, B ;LCALL B_SET 	; ÉèÖà Baud rateSET_ERROR:	LCALL S_INTI 				LJMP DISPROM 	SET_RL: 	MOV RXBUFFTAIL, #RXBUFFSTART	MOV DPTR, #INPUTERROR 	LCALL DIS_FUN 	LJMP SET_LOOP 	;APROM¹¦ÄÜ´¦ÀíFUN_APROM: 	MOV DPTR, #WARNTAB 	LCALL DIS_FUN 	MOV DPTR, #INPUTTAB 	LCALL DIS_FUN 	APROM_LOOP:	MOV RXBUFFTAIL, #RXBUFFSTART	LCALL READWAIT 	MOV R0, #RXBUFFSTART 	MOV R4, #59H ; ÊÇ·ñ YLCALL C_CMP 	JZ CMD_GREADY 	MOV R4, #4EH ; ÊÇ·ñ NLCALL C_CMP 	JNZ READY_LOOP 	LCALL S_INTI 				LJMP DISPROM 	CMD_GREADY:	LCALL ENTER_PUT 	; ÏÔʾ»Ø³µLCALL ENTER_PUT 	MOV CHPENR,#87H 			; ½øÈëAPROMÐ޸ijÌÐò״̬MOV CHPENR,#59HMOV CHPCON,#03HMOV TCON,#00H 			;¹ØT0¡¢T1MOV T2CON,#00H 			;¹ØT2MOV IP,#00H 		;ͬÓÅÏȼ¶MOV IE,#82H 		;ÔÊÐíT0Öжϣ¬×ÜÖжϿª·ÅMOV TL0,#0FBH 		;×°³õÖµ£¬¶¨Ê±Îª5UFMOV TH0,#0FFHMOV TMOD,#01H 		;T0Ϊ16λ¶¨Ê±Æ÷MOV TCON,#10H 		;¿ªÆôT0MOV PCON,#01H 		;ÔÚÏß±à³Ìģʽ£¬µÈ´ý»½ÐѺó½øÈëRETREADY_LOOP:	MOV DPTR, #INPUTERROR 	LCALL DIS_FUN 	LJMP APROM_LOOP B_SET: 	MOV DPTR, #B_TAB 	CLR TR2 	MOVC A, @A+DPTR 	MOV TL2, A ; TL2MOV RCAP2L, A ; RCAP2LCLR A ;DEC A ;MOV TH2, A ;MOV RCAP2H, A ;SETB TR2 ;RET; ´®¿ÚÖжϷþÎñ³ÌÐò ; ´®¿ÚÖжϴ¦ÀíS_INT: 	PUSH PSWPUSH	ACCMOV PSW, #04H ; ÉèµÚ¶þ×é¼Ä´æÆ÷JBC RI, S_LOOP ; RI = 1 È¥½ÓÊÕÖжϳÌÐò RI = 0JNB TI, R_INT 	CLR TI ; Çå·¢ËÍÖжÏLJMP TXINFOS_LOOP: 	NOP 	R_DATA: 	MOV R0, RXBUFFTAIL ; ½ÓÊÕÃüÁîMOV A, SBUF ;XRL A, #BACKSPACE ; ɾ³ý´¦ÀíJNZ R_DATA1 	SETB CMDSPACEFLAG ; ÐèҪɾ³ý±ê¼ÇDEC RXBUFFLEN ; ½ÓÊÕ¶ÓÁе÷ÕûMOV A, RXBUFFLEN 	INC A 	JNZ R_DATAB1 	CLR CMDSPACEFLAG ; È«²¿É¾³ýINC RXBUFFLEN 	R_DATAB1: 	DEC RXBUFFTAIL MOV A, RXBUFFTAIL INC A XRL A, #RXBUFFSTART JNZ R_INT CLR CMDSPACEFLAG ; È«²¿É¾³ýINC RXBUFFTAIL ;LJMP R_INT ;R_DATA1: 	INC RXBUFFLEN ; ÃüÁ¶È¼ÆÊýINC RXBUFFTAIL ; ½ÓÊÕ»º³åÇø¼ÆÊýMOV A, RXBUFFLEN ;XRL A, #90H ; ÃüÁ¶ÈÏÞÖÆJZ CMD_ERROR MOV A, SBUF MOV @R0, A ; ´æÃüÁî×Ö·ûXRL A, #0DH ; ÊÇ·ñ½áÊøJZ CMD_GFLSH ;R_DATA2: 	MOV A, SBUF ; »ØÏÔÊÕµ½µÄ×Ö·ûCLR TXOKFLAG ;MOV SBUF, A ;R_INT: 	POP ACC ;			POP PSW ;			RETI ;CMD_ERROR: 	CLR A ; ³ö´í´¦Àí			MOV RXBUFFLEN, A ; ³õʼ»¯			MOV RXBUFFTAIL, #RXBUFFSTART;			LJMP R_INT ;			;CMD_GFLSH: 	SETB RXCMDOKFLAG 	; ½ÓÊճɹ¦			LJMP R_INT 	;TXINFO: 	SETB TXOKFLAG ; ·¢Ëͳɹ¦			LJMP R_INT ;			; °Ñ±íµÄÄÚÈÝдµ½´®¿Ú 			; DPTR ÄÚÈÝÊDZíµÄÊ×Ö·			; ÏÔʾ±í¸ñÄÚÈÝDIS_FUN: 	CLR A 				MOV R5, A 	TAB_DATA: MOV A, R5 				MOVC A, @A+DPTR ; ²é±í			MOV R4, A 				INC R5 ; ¼ÆÊýÆ÷¼ÓÒ»			MOV A, R5 				JNZ TAB_OVER ; ¼ÆÊýÆ÷Òç³ö´¦Àí			INC DPH 	TAB_OVER: 	MOV A, R4 	INC A 	JZ RETT1 		; ¶Áµ½½áÊø·û½áÊøCLR TXOKFLAG ;DEC A ;LCALL RG_CMDS ; ·¢ËÍ×Ö·ûLJMP TAB_DATA ;RETT1: 	RET			;Ë¢ÐÂÃüÁî·ûRG_CMD: 	JNB CMDSPACEFLAG, RETT2;CLR CMDSPACEFLAG ;MOV A, #BACKSPACE ; Öùâ±êµ½Ç°Ò»×Ö·ûLCALL RG_CMDS ;MOV A, #20H ; Óÿոñ¸²¸ÇLCALL RG_CMDS ;MOV A, #BACKSPACE ; µ÷Õû¹â±êλÖÃLCALL RG_CMDS ;RETT2: RET ;			; ·¢ËÍ Ò»¸ö×Ö·û 			; A ÄÚÈÝ´ý·¢×Ö·ûRG_CMDS: 	CLR TXOKFLAG 	MOV SBUF, A 	JNB TXOKFLAG, $ 	RET; ·¢ËÍ×Ö·û´® ; A ÄÚÈÝ´ý·¢×Ö·ûÊ×Ö·; B ÄÚÈÝ´ý·¢×Ö·û¸öÊýSTR_PUT: 	MOV R0, A 				MOV R4, B 	STR_LOOP: 	MOV A, @R0 				INC R0 				LCALL RG_CMDS 				DJNZ R4, STR_LOOP 				RET			; ÏÔʾ»Ø³µ 			; Ïò´®¿Ú·¢ËͻسµENTER_PUT: 	MOV A, #0DH 				LCALL RG_CMDS 				MOV A, #0AH 				LCALL RG_CMDS 				RET			; ³õʼ»¯´®¿Ú(CMDAND) 			; ³õʼ»¯´®¿ÚÊý¾ÝS_INTI: 	CLR A 				MOV RXBUFFLEN, A 	; ³õʼ»¯			CLR RXCMDOKFLAG 				MOV RXBUFFTAIL, #RXBUFFSTART				LCALL ENTER_PUT 	; ÏÔʾ»Ø³µ			RET			;¶ÁµÈ´ý 			; ËÀ¶Á»º³åÇøÒ»Ö±µ½ÓÐÊý¾ÝREADWAIT: 	MOV RXBUFFTAIL, #RXBUFFSTART				CLR A 				MOV A, RXBUFFLEN 	READWAIT1: 	MOV A, RXBUFFTAIL 				XRL A, #RXBUFFSTART 				JZ READWAIT1 	; ½ÓÊÕ»º³åÇø¿Õ LOOPREADLOOP: 	LCALL RG_CMD ;			JNB RXCMDOKFLAG, READLOOP 	; ÃüÁî½ÓÊÕ²»³É¹¦²»´¦Àí			MOV R0, #RXBUFFSTART 				RET 				; ±È½Ïµ¥¸ö×Ö·û			; R0 ÄÚÈÝΪµØÖ·			; R4 ÄÚÈÝΪԴ			; A ÄÚÈÝΪÁã: ³É¹¦; ·ÇÁã: ʧ°ÜC_CMP: 	MOV A, @R0 	XRL A, R4 	; ÊÇ·ñ´óдJZ C_CMPOUT 	MOV A, R4 ; ÊÇ·ñСдADD A, #20H 	MOV R4, A 	MOV A, @R0 	XRL A, R4 	C_CMPOUT: 	RET			; DISPROMDISPROM: 	MOV DPTR,#ROMMARKTAB ;ÏÔʾROM>LCALL DIS_FUNRET; ½á Êø END¡¡¡¡

标签: #汇编语言jb指令怎么用