C51中的指针应用之二.rar

源代码在线查看: test.src

软件大小: 22 K
上传用户: sunny_02
关键词: C51 指针
下载地址: 免注册下载 普通下载 VIP

相关代码

				; TEST.SRC generated from: TEST.C
				; COMPILER INVOKED BY:
				;        C:\Keil\C51\BIN\C51.EXE TEST.C REGFILE(.\test.ORC) BROWSE DEBUG OBJECTEXTEND TABS(3)
				
				$NOMOD51
				
				NAME	TEST
				
				P0	DATA	080H
				P1	DATA	090H
				P2	DATA	0A0H
				P3	DATA	0B0H
				T0	BIT	0B0H.4
				AC	BIT	0D0H.6
				T1	BIT	0B0H.5
				EA	BIT	0A8H.7
				IE	DATA	0A8H
				RD	BIT	0B0H.7
				ES	BIT	0A8H.4
				IP	DATA	0B8H
				RI	BIT	098H.0
				INT0	BIT	0B0H.2
				CY	BIT	0D0H.7
				TI	BIT	098H.1
				INT1	BIT	0B0H.3
				PS	BIT	0B8H.4
				SP	DATA	081H
				OV	BIT	0D0H.2
				WR	BIT	0B0H.6
				SBUF	DATA	099H
				PCON	DATA	087H
				SCON	DATA	098H
				TMOD	DATA	089H
				TCON	DATA	088H
				IE0	BIT	088H.1
				IE1	BIT	088H.3
				B	DATA	0F0H
				ACC	DATA	0E0H
				ET0	BIT	0A8H.1
				ET1	BIT	0A8H.3
				TF0	BIT	088H.5
				TF1	BIT	088H.7
				RB8	BIT	098H.2
				TH0	DATA	08CH
				EX0	BIT	0A8H.0
				IT0	BIT	088H.0
				TH1	DATA	08DH
				TB8	BIT	098H.3
				EX1	BIT	0A8H.2
				IT1	BIT	088H.2
				P	BIT	0D0H.0
				SM0	BIT	098H.7
				TL0	DATA	08AH
				SM1	BIT	098H.6
				TL1	DATA	08BH
				SM2	BIT	098H.5
				PT0	BIT	0B8H.1
				PT1	BIT	0B8H.3
				RS0	BIT	0D0H.3
				TR0	BIT	088H.4
				RS1	BIT	0D0H.4
				TR1	BIT	088H.6
				PX0	BIT	0B8H.0
				PX1	BIT	0B8H.2
				DPH	DATA	083H
				DPL	DATA	082H
				REN	BIT	098H.4
				RXD	BIT	0B0H.0
				TXD	BIT	0B0H.1
				F0	BIT	0D0H.5
				PSW	DATA	0D0H
				?PR?main?TEST        SEGMENT CODE 
				?DT?main?TEST        SEGMENT DATA OVERLAYABLE 
				?PR?menu?TEST        SEGMENT CODE 
				?DT?menu?TEST        SEGMENT DATA OVERLAYABLE 
				?PR?_str_chr?TEST    SEGMENT CODE 
				?PR?enter?TEST       SEGMENT CODE 
				?PR?del?TEST         SEGMENT CODE 
				?PR?review?TEST      SEGMENT CODE 
				?PR?quit?TEST        SEGMENT CODE 
				?CO?TEST             SEGMENT CODE 
					EXTRN	CODE (_putcstring)
					EXTRN	CODE (getche)
					EXTRN	CODE (?C_STARTUP)
					EXTRN	CODE (?C?ICALL)
					PUBLIC	option
					PUBLIC	quit
					PUBLIC	review
					PUBLIC	del
					PUBLIC	enter
					PUBLIC	_str_chr
					PUBLIC	menu
					PUBLIC	main
				
					RSEG  ?DT?main?TEST
				?main?BYTE:
				          i?040:   DS   1
				
					RSEG  ?DT?menu?TEST
				?menu?BYTE:
				         ch?141:   DS   1
				
					RSEG  ?CO?TEST
				?SC_0:
					DB  ' ' ,' ' ,'c' ,'o' ,'n' ,'t' ,'i' ,'n' ,'u' ,'e' 
					DB  '!' ,00AH,00AH,000H
				
				?SC_14:
					DB  '1' ,'.' ,' ' ,'E' ,'n' ,'t' ,'e' ,'r' ,00AH,000H
				
				?SC_24:
					DB  '2' ,'.' ,' ' ,'D' ,'e' ,'l' ,'e' ,'t' ,'e' ,00AH
					DB  000H
				
				?SC_35:
					DB  '3' ,'.' ,' ' ,'R' ,'e' ,'v' ,'i' ,'e' ,'w' ,00AH
					DB  000H
				
				?SC_46:
					DB  '4' ,'.' ,' ' ,'Q' ,'u' ,'i' ,'t' ,00AH,000H
				
				?SC_55:
					DB  'S' ,'e' ,'l' ,'e' ,'c' ,'t' ,' ' ,'a' ,' ' ,'n' 
					DB  'u' ,'m' ,'b' ,'e' ,'r' ,':' ,' ' ,000H
				
				?SC_73:
					DB  00AH,000H
				
				?SC_75:
					DB  '1' ,'2' ,'3' ,'4' ,000H
				
				?SC_80:
					DB  00AH,'I' ,'n' ,' ' ,'e' ,'n' ,'t' ,'e' ,'r' ,000H
				
				?SC_90:
					DB  00AH,'I' ,'n' ,' ' ,'d' ,'e' ,'l' ,000H
				
				?SC_98:
					DB  00AH,'I' ,'n' ,' ' ,'r' ,'e' ,'v' ,'i' ,'e' ,'w' 
					DB  000H
				
				?SC_109:
					DB  00AH,'I' ,'n' ,' ' ,'q' ,'u' ,'i' ,'t' ,000H
				
				option:
					DB	0FFH
					DW	enter + 0
					DB	0FFH
					DW	del + 0
					DB	0FFH
					DW	review + 0
					DB	0FFH
					DW	quit + 0
				
				; #pragma src
				; #include "reg51.h"
				; #include "IO.H"   // 自定义头文件, 宏定义及I/O函数外部声明
				; 
				; void enter(void), del(void), review(void), quit(void);  // 函数声明
				; 
				; code void (*option[])(void) = { // 作为code数据, 类似汇编里的函数地址标号
				;    enter,
				;    del,
				;    review,
				;    quit
				; };
				; 
				; 
				; unsigned char str_chr(unsigned char code * str, unsigned char ch); // 检测字符串str中是否含有字符ch
				; 
				; unsigned char menu(void); // 示出一个菜单, 返回用户选择的菜单号
				; 
				; unsigned char main(void)
				
					RSEG  ?PR?main?TEST
				main:
					USING	0
							; SOURCE LINE # 19
				; {
							; SOURCE LINE # 20
				;    unsigned char i;
				; 
				; 	SCON = 0xc0;            // 设置串口为方式3, 11位UART(Universal Asynchronous Receiver/Transmitter), 波特率可变 
							; SOURCE LINE # 23
					MOV  	SCON,#0C0H
				; 	PCON = 0;
							; SOURCE LINE # 24
					CLR  	A
					MOV  	PCON,A
				; 	TMOD = 0x20;				// 设置定时器T1为方式2(自动再装入8位计数器),做为波特率发生器
							; SOURCE LINE # 25
					MOV  	TMOD,#020H
				; 	TH1 = 0xf0;
							; SOURCE LINE # 26
					MOV  	TH1,#0F0H
				; 	TL1 = 0xf0;
							; SOURCE LINE # 27
					MOV  	TL1,#0F0H
				; 	TR1 = 1;
							; SOURCE LINE # 28
					SETB 	TR1
				;  
				;  //EA = 1;						//	所有中断开
				;  //ES = 1;						// 允许串行中断
				; 	REN = 1;                // 允许串行接收, 把此行关闭,串口1就收不到数据了
							; SOURCE LINE # 32
					SETB 	REN
				?C0003:
				; 
				;    do {
							; SOURCE LINE # 34
				;       i = menu(); /* get user's choice */
							; SOURCE LINE # 35
					LCALL	menu
					MOV  	i?040,R7
				; 
				;       (*option[i])(); /* execute */
							; SOURCE LINE # 37
					MOV  	A,R7
					MOV  	B,#03H
					MUL  	AB
					ADD  	A,#LOW (option)
					MOV  	DPL,A
					CLR  	A
					ADDC 	A,#HIGH (option)
					MOV  	DPH,A
					MOV  	A,#01H
					MOVC 	A,@A+DPTR
					MOV  	R2,A
					MOV  	A,#02H
					MOVC 	A,@A+DPTR
					MOV  	R1,A
					LCALL	?C?ICALL
				; 
				; 		if(i==3)break;
							; SOURCE LINE # 39
					MOV  	A,i?040
					XRL  	A,#03H
					JZ   	?C0002
				?C0004:
				; 
				;       putcstring("  continue!\n\n");
							; SOURCE LINE # 41
					MOV  	R6,#HIGH (?SC_0)
					MOV  	R7,#LOW (?SC_0)
					LCALL	_putcstring
				; 
				;    } while(1);
							; SOURCE LINE # 43
					SJMP 	?C0003
				?C0002:
				; 
				; 	return 0;
							; SOURCE LINE # 45
					MOV  	R7,#00H
				; }
							; SOURCE LINE # 46
				?C0005:
					RET  	
				; END OF main
				
				; 
				; 
				; unsigned char menu(void)
				
					RSEG  ?PR?menu?TEST
				menu:
					USING	0
							; SOURCE LINE # 49
				; {
							; SOURCE LINE # 50
				?C0008:
				;    unsigned char ch;
				; 
				;    do {
							; SOURCE LINE # 53
				; /*
				;       putstring("1. Enter\n");
				;       putstring("2. Delete\n");
				;       putstring("3. Review\n");
				;       putstring("4. Quit\n");
				;       putstring("Select a number: ");
				; */
				;       putcstring("1. Enter\n");
							; SOURCE LINE # 61
					MOV  	R6,#HIGH (?SC_14)
					MOV  	R7,#LOW (?SC_14)
					LCALL	_putcstring
				;       putcstring("2. Delete\n");
							; SOURCE LINE # 62
					MOV  	R6,#HIGH (?SC_24)
					MOV  	R7,#LOW (?SC_24)
					LCALL	_putcstring
				;       putcstring("3. Review\n");
							; SOURCE LINE # 63
					MOV  	R6,#HIGH (?SC_35)
					MOV  	R7,#LOW (?SC_35)
					LCALL	_putcstring
				;       putcstring("4. Quit\n");
							; SOURCE LINE # 64
					MOV  	R6,#HIGH (?SC_46)
					MOV  	R7,#LOW (?SC_46)
					LCALL	_putcstring
				;       putcstring("Select a number: ");
							; SOURCE LINE # 65
					MOV  	R6,#HIGH (?SC_55)
					MOV  	R7,#LOW (?SC_55)
					LCALL	_putcstring
				; 
				;       ch = getche();
							; SOURCE LINE # 67
					LCALL	getche
					MOV  	ch?141,R7
				;       putcstring("\n");
							; SOURCE LINE # 68
					MOV  	R6,#HIGH (?SC_73)
					MOV  	R7,#LOW (?SC_73)
					LCALL	_putcstring
				; 
				;    } while(!str_chr("1234", ch));
							; SOURCE LINE # 70
					MOV  	R6,#HIGH (?SC_75)
					MOV  	R7,#LOW (?SC_75)
					MOV  	R5,ch?141
					LCALL	_str_chr
					MOV  	A,R7
					JZ   	?C0008
				; 
				;    return ch - 0x31; /* convert to an integer equivalent */
							; SOURCE LINE # 72
					MOV  	A,ch?141
					ADD  	A,#0CFH
					MOV  	R7,A
				; 
				; }
							; SOURCE LINE # 74
				?C0009:
					RET  	
				; END OF menu
				
				; 
				; unsigned char str_chr(unsigned char code * str, unsigned char ch)
				
					RSEG  ?PR?_str_chr?TEST
				_str_chr:
					USING	0
							; SOURCE LINE # 76
				;---- Variable 'ch?243' assigned to Register 'R5' ----
				;---- Variable 'str?242' assigned to Register 'R6/R7' ----
				; {
							; SOURCE LINE # 77
				; 	unsigned char i=0,j;
							; SOURCE LINE # 78
				;---- Variable 'i?244' assigned to Register 'R4' ----
					CLR  	A
					MOV  	R4,A
				?C0012:
				; 	do {
							; SOURCE LINE # 79
				;       j= str[i];
							; SOURCE LINE # 80
					MOV  	A,R7
					ADD  	A,R4
					MOV  	DPL,A
					CLR  	A
					ADDC 	A,R6
					MOV  	DPH,A
					CLR  	A
					MOVC 	A,@A+DPTR
					MOV  	R3,A
				;---- Variable 'j?245' assigned to Register 'R3' ----
				; 		if(j==ch)break;
							; SOURCE LINE # 81
					XRL  	A,R5
					JZ   	?C0011
				?C0013:
				;       ++i;
							; SOURCE LINE # 82
					INC  	R4
				; 	} while(j);
							; SOURCE LINE # 83
					MOV  	A,R3
					JNZ  	?C0012
				?C0011:
				; 	return j;
							; SOURCE LINE # 84
					MOV  	R7,AR3
				; }
							; SOURCE LINE # 85
				?C0014:
					RET  	
				; END OF _str_chr
				
				; 
				; void enter(void)
				
					RSEG  ?PR?enter?TEST
				enter:
					USING	0
							; SOURCE LINE # 87
				; {
							; SOURCE LINE # 88
				;    //putstring("\nIn enter");
				;    putcstring("\nIn enter");
							; SOURCE LINE # 90
					MOV  	R6,#HIGH (?SC_80)
					MOV  	R7,#LOW (?SC_80)
					LJMP 	_putcstring
				; END OF enter
				
				; }
				; void del(void)
				
					RSEG  ?PR?del?TEST
				del:
					USING	0
							; SOURCE LINE # 92
				; {
							; SOURCE LINE # 93
				;    //putstring("\nIn del");
				;    putcstring("\nIn del");
							; SOURCE LINE # 95
					MOV  	R6,#HIGH (?SC_90)
					MOV  	R7,#LOW (?SC_90)
					LJMP 	_putcstring
				; END OF del
				
				; }
				; void review(void)
				
					RSEG  ?PR?review?TEST
				review:
					USING	0
							; SOURCE LINE # 97
				; {
							; SOURCE LINE # 98
				;    //putstring("\nIn review");
				;    putcstring("\nIn review");
							; SOURCE LINE # 100
					MOV  	R6,#HIGH (?SC_98)
					MOV  	R7,#LOW (?SC_98)
					LJMP 	_putcstring
				; END OF review
				
				; }
				; void quit(void)
				
					RSEG  ?PR?quit?TEST
				quit:
					USING	0
							; SOURCE LINE # 102
				; {
							; SOURCE LINE # 103
				;    //putstring("\nIn quit");
				;    putcstring("\nIn quit");
							; SOURCE LINE # 105
					MOV  	R6,#HIGH (?SC_109)
					MOV  	R7,#LOW (?SC_109)
					LJMP 	_putcstring
				; END OF quit
				
					END
							

相关资源