📄 yy1.lst
字号:
22 =2 //**********************************************************************************
23 =2 //使用方法:(此范例自包含,独立于其他程序。)
24 =2 // 1.开头加入#include <reg51.h>语句,一定要有。
25 =2 // 2.初始化串口 InitSerial();//本例中为20MHz晶体,300波特率,模式2初始化
26 =2 // 3.初始化串口缓冲区 InitSerialBuffer();
27 =2 // 4.使用显示字节,字,长字,字符,字符串,清屏函数。
28 =2 //**********************************************************************************
29 =2 //波特率计算公式:
30 =2 // TH1=256-(2^SMOD/32*Fosc/12*1/Bound)
31 =2 // 其中:SMOD=0,1;Fosc=晶体或晶振频率;Bound=波特率
32 =2 // 本例中,SMOD=0;Fosc=20*10E6;Bound=300,所以TH1=0x52。
33 =2 //**********************************************************************************
34 =2 //书写风格:
35 =2 // 1.带yy前缀标志的函数为杨屹改写的等效C库函数。
36 =2 // 2.单个单词用小写,yy定义为前缀,不算一个单词。
37 =2 // 3.多个单词(2个及以上),每个单词首字母大写。(有时变量名第一个单词首字母小写)
38 =2 // 4.采用内缩风格,每次缩进8个空格。
39 =2 //**********************************************************************************
40 =2
41 =2 void InitSerial() ;//串口初始化
42 =2 void InitSerialBuffer(void) ;//串口缓冲区初始化
43 =2 bit yygetch(unsigned char *ch) ;//从串口缓冲区读1字节数据
44 =2 void PrintChar(unsigned char ch) ;//显示字符
45 =2 void PrintCh(unsigned char ch) ;//内部使用,不建议用户使用。
46 =2 void PrintByte(unsigned char Byte) ;//以十六进制格式显示1个字节数据
47 =2 void PrintWord(unsigned int Word) ;//以十六进制格式显示1个字数据
48 =2 void PrintLong(unsigned long LongWord) ;//以十六进制格式显示1个长字数据
49 =2 void PrintStr(unsigned char *str) ;//显示字符串
50 =2 void clrscr() ;//清屏
51 =2
52 =2 void serial(void) ;//串口中断服务子程序
53 =2
54 =2 //收发缓冲区长度
C51 COMPILER V7.01 YY1 01/09/2003 18:37:29 PAGE 13
55 =2 #define LenTxBuf 2000 //Don't too small,because it will cause display abnormal.
56 =2 #define LenRxBuf 50
57 =2
58 =2 #define MaxLenStr 100 /*buf[MaxLenStr+1] for '\0'*/
59 =2
60 =2 #define TABNum 4 //TAB键移动长度
61 =2
25 =1 #include <intrins.h>
1 =2 /*--------------------------------------------------------------------------
2 =2 INTRINS.H
3 =2
4 =2 Intrinsic functions for C51.
5 =2 Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
6 =2 All rights reserved.
7 =2 --------------------------------------------------------------------------*/
8 =2
9 =2 extern void _nop_ (void);
10 =2 extern bit _testbit_ (bit);
11 =2 extern unsigned char _cror_ (unsigned char, unsigned char);
12 =2 extern unsigned int _iror_ (unsigned int, unsigned char);
13 =2 extern unsigned long _lror_ (unsigned long, unsigned char);
14 =2 extern unsigned char _crol_ (unsigned char, unsigned char);
15 =2 extern unsigned int _irol_ (unsigned int, unsigned char);
16 =2 extern unsigned long _lrol_ (unsigned long, unsigned char);
17 =2 extern unsigned char _chkfloat_(float);
26 =1 #include <absacc.h>
1 =2 /*--------------------------------------------------------------------------
2 =2 ABSACC.H
3 =2
4 =2 Direct access to 8051, extended 8051 and Philips 80C51MX memory areas.
5 =2 Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
6 =2 All rights reserved.
7 =2 --------------------------------------------------------------------------*/
8 =2
9 =2 #define CBYTE ((unsigned char volatile code *) 0)
10 =2 #define DBYTE ((unsigned char volatile data *) 0)
11 =2 #define PBYTE ((unsigned char volatile pdata *) 0)
12 =2 #define XBYTE ((unsigned char volatile xdata *) 0)
13 =2
14 =2 #define CWORD ((unsigned int volatile code *) 0)
15 =2 #define DWORD ((unsigned int volatile data *) 0)
16 =2 #define PWORD ((unsigned int volatile pdata *) 0)
17 =2 #define XWORD ((unsigned int volatile xdata *) 0)
18 =2
19 =2
20 =2 #ifdef __CX51__
=2 #define FVAR(object, addr) (*((object volatile far *) (addr)))
=2 #define FARRAY(object, base) ((object volatile far *) (base))
=2 #else
24 =2 #define FVAR(object, addr) (*((object volatile far *) ((addr)+0x10000L)))
25 =2 #define FCVAR(object, addr) (*((object const far *) ((addr)+0x810000L)))
26 =2 #define FARRAY(object, base) ((object volatile far *) ((base)+0x10000L))
27 =2 #define FCARRAY(object, base) ((object const far *) ((base)+0x810000L))
28 =2 #endif
27 =1 #include <stdlib.h>
1 =2 /*--------------------------------------------------------------------------
2 =2 STDLIB.H
3 =2
4 =2 Standard functions.
5 =2 Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
6 =2 All rights reserved.
7 =2 --------------------------------------------------------------------------*/
C51 COMPILER V7.01 YY1 01/09/2003 18:37:29 PAGE 14
8 =2
9 =2 #ifndef _SIZE_T
10 =2 #define _SIZE_T
11 =2 typedef unsigned int size_t;
12 =2 #endif
13 =2
14 =2 #ifndef NULL
15 =2 #define NULL ((void *) 0L)
16 =2 #endif
17 =2
18 =2 #ifndef _WCHAR_T_DEFINED_
19 =2 #define _WCHAR_T_DEFINED_
20 =2 typedef char wchar_t;
21 =2 #endif
22 =2
23 =2
24 =2 #pragma SAVE
25 =2 #pragma REGPARMS
26 =2
27 =2 extern int abs (int val);
28 =2 extern long labs (long val);
29 =2
30 =2 extern float atof (char *s1);
31 =2 extern long atol (char *s1);
32 =2 extern int atoi (char *s1);
33 =2 extern int rand ();
34 =2 extern void srand (int);
35 =2
36 =2 extern float strtod (char *, char **);
37 =2 extern long strtol (char *, char **, unsigned char);
38 =2 extern unsigned long strtoul (char *, char **, unsigned char);
39 =2
40 =2 #define _MALLOC_MEM_ xdata
41 =2
42 =2 extern int init_mempool (void _MALLOC_MEM_ *p, unsigned int size);
43 =2 extern void _MALLOC_MEM_ *malloc (unsigned int size);
44 =2 extern void free (void _MALLOC_MEM_ *p);
45 =2 extern void _MALLOC_MEM_ *realloc (void _MALLOC_MEM_ *p, unsigned int size);
46 =2 extern void _MALLOC_MEM_ *calloc (unsigned int size, unsigned int len);
47 =2
48 =2 #pragma RESTORE
28 =1 #include <stdio.h>
1 =2 /*--------------------------------------------------------------------------
2 =2 STDIO.H
3 =2
4 =2 Prototypes for standard I/O functions.
5 =2 Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
6 =2 All rights reserved.
7 =2 --------------------------------------------------------------------------*/
8 =2
9 =2 #ifndef EOF
10 =2 #define EOF -1
11 =2 #endif
12 =2
13 =2 #ifndef NULL
=2 #define NULL ((void *) 0)
=2 #endif
16 =2
17 =2 #ifndef _SIZE_T
=2 #define _SIZE_T
=2 typedef unsigned int size_t;
=2 #endif
C51 COMPILER V7.01 YY1 01/09/2003 18:37:29 PAGE 15
21 =2
22 =2 #pragma SAVE
23 =2 #pragma REGPARMS
24 =2 extern char _getkey (void);
25 =2 extern char getchar (void);
26 =2 extern char ungetchar (char);
27 =2 extern char putchar (char);
28 =2 extern int printf (const char *, ...);
29 =2 extern int sprintf (char *, const char *, ...);
30 =2 extern int vprintf (const char *, char *);
31 =2 extern int vsprintf (char *, const char *, char *);
32 =2 extern char *gets (char *, int n);
33 =2 extern int scanf (const char *, ...);
34 =2 extern int sscanf (char *, const char *, ...);
35 =2 extern int puts (const char *);
36 =2
37 =2 #pragma RESTORE
29 =1 #include <REG52.H>
1 =2 /*--------------------------------------------------------------------------
2 =2 REG52.H
3 =2
4 =2 Header file for generic 80C52 and 80C32 microcontroller.
5 =2 Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
6 =2 All rights reserved.
7 =2 --------------------------------------------------------------------------*/
8 =2
9 =2 /* BYTE Registers */
10 =2 sfr P0 = 0x80;
11 =2 sfr P1 = 0x90;
12 =2 sfr P2 = 0xA0;
13 =2 sfr P3 = 0xB0;
14 =2 sfr PSW = 0xD0;
15 =2 sfr ACC = 0xE0;
16 =2 sfr B = 0xF0;
17 =2 sfr SP = 0x81;
18 =2 sfr DPL = 0x82;
19 =2 sfr DPH = 0x83;
20 =2 sfr PCON = 0x87;
21 =2 sfr TCON = 0x88;
22 =2 sfr TMOD = 0x89;
23 =2 sfr TL0 = 0x8A;
24 =2 sfr TL1 = 0x8B;
25 =2 sfr TH0 = 0x8C;
26 =2 sfr TH1 = 0x8D;
27 =2 sfr IE = 0xA8;
28 =2 sfr IP = 0xB8;
29 =2 sfr SCON = 0x98;
30 =2 sfr SBUF = 0x99;
31 =2
32 =2 /* 8052 Extensions */
33 =2 sfr T2CON = 0xC8;
34 =2 sfr RCAP2L = 0xCA;
35 =2 sfr RCAP2H = 0xCB;
36 =2 sfr TL2 = 0xCC;
37 =2 sfr TH2 = 0xCD;
38 =2
39 =2
40 =2 /* BIT Registers */
41 =2 /* PSW */
42 =2 sbit CY = PSW^7;
43 =2 sbit AC = PSW^6;
44 =2 sbit F0 = PSW^5;
C51 COMPILER V7.01 YY1 01/09/2003 18:37:29 PAGE 16
45 =2 sbit RS1 = PSW^4;
46 =2 sbit RS0 = PSW^3;
47 =2 sbit OV = PSW^2;
48 =2 sbit P = PSW^0; //8052 only
49 =2
50 =2 /* TCON */
51 =2 sbit TF1 = TCON^7;
52 =2 sbit TR1 = TCON^6;
53 =2 sbit TF0 = TCON^5;
54 =2 sbit TR0 = TCON^4;
55 =2 sbit IE1 = TCON^3;
56 =2 sbit IT1 = TCON^2;
57 =2 sbit IE0 = TCON^1;
58 =2 sbit IT0 = TCON^0;
59 =2
60 =2 /* IE */
61 =2 sbit EA = IE^7;
62 =2 sbit ET2 = IE^5; //8052 only
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -