📄 text1.lst
字号:
C51 COMPILER V7.50 TEXT1 04/17/2007 18:33:47 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN Text1.OBJ
COMPILER INVOKED BY: D:\学习软件\单片机编程\C51\BIN\C51.EXE Text1.C BROWSE DEBUG OBJECTEXTEND LISTINCLUDE PREPRINT
line level source
1 #include <stdio.h>
1 =1 /*--------------------------------------------------------------------------
2 =1 STDIO.H
3 =1
4 =1 Prototypes for standard I/O functions.
5 =1 Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
6 =1 All rights reserved.
7 =1 --------------------------------------------------------------------------*/
8 =1
9 =1 #ifndef __STDIO_H__
10 =1 #define __STDIO_H__
11 =1
12 =1 #ifndef EOF
13 =1 #define EOF -1
14 =1 #endif
15 =1
16 =1 #ifndef NULL
17 =1 #define NULL ((void *) 0)
18 =1 #endif
19 =1
20 =1 #ifndef _SIZE_T
21 =1 #define _SIZE_T
22 =1 typedef unsigned int size_t;
23 =1 #endif
24 =1
25 =1 #pragma SAVE
26 =1 #pragma REGPARMS
27 =1 extern char _getkey (void);
28 =1 extern char getchar (void);
29 =1 extern char ungetchar (char);
30 =1 extern char putchar (char);
31 =1 extern int printf (const char *, ...);
32 =1 extern int sprintf (char *, const char *, ...);
33 =1 extern int vprintf (const char *, char *);
34 =1 extern int vsprintf (char *, const char *, char *);
35 =1 extern char *gets (char *, int n);
36 =1 extern int scanf (const char *, ...);
37 =1 extern int sscanf (char *, const char *, ...);
38 =1 extern int puts (const char *);
39 =1
40 =1 #pragma RESTORE
41 =1
42 =1 #endif
43 =1
2 #include <reg52.h>
1 =1 /*--------------------------------------------------------------------------
2 =1 REG52.H
3 =1
4 =1 Header file for generic 80C52 and 80C32 microcontroller.
5 =1 Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
6 =1 All rights reserved.
7 =1 --------------------------------------------------------------------------*/
8 =1
9 =1 #ifndef __REG52_H__
10 =1 #define __REG52_H__
C51 COMPILER V7.50 TEXT1 04/17/2007 18:33:47 PAGE 2
11 =1
12 =1 /* BYTE Registers */
13 =1 sfr P0 = 0x80;
14 =1 sfr P1 = 0x90;
15 =1 sfr P2 = 0xA0;
16 =1 sfr P3 = 0xB0;
17 =1 sfr PSW = 0xD0;
18 =1 sfr ACC = 0xE0;
19 =1 sfr B = 0xF0;
20 =1 sfr SP = 0x81;
21 =1 sfr DPL = 0x82;
22 =1 sfr DPH = 0x83;
23 =1 sfr PCON = 0x87;
24 =1 sfr TCON = 0x88;
25 =1 sfr TMOD = 0x89;
26 =1 sfr TL0 = 0x8A;
27 =1 sfr TL1 = 0x8B;
28 =1 sfr TH0 = 0x8C;
29 =1 sfr TH1 = 0x8D;
30 =1 sfr IE = 0xA8;
31 =1 sfr IP = 0xB8;
32 =1 sfr SCON = 0x98;
33 =1 sfr SBUF = 0x99;
34 =1
35 =1 /* 8052 Extensions */
36 =1 sfr T2CON = 0xC8;
37 =1 sfr RCAP2L = 0xCA;
38 =1 sfr RCAP2H = 0xCB;
39 =1 sfr TL2 = 0xCC;
40 =1 sfr TH2 = 0xCD;
41 =1
42 =1
43 =1 /* BIT Registers */
44 =1 /* PSW */
45 =1 sbit CY = PSW^7;
46 =1 sbit AC = PSW^6;
47 =1 sbit F0 = PSW^5;
48 =1 sbit RS1 = PSW^4;
49 =1 sbit RS0 = PSW^3;
50 =1 sbit OV = PSW^2;
51 =1 sbit P = PSW^0; //8052 only
52 =1
53 =1 /* TCON */
54 =1 sbit TF1 = TCON^7;
55 =1 sbit TR1 = TCON^6;
56 =1 sbit TF0 = TCON^5;
57 =1 sbit TR0 = TCON^4;
58 =1 sbit IE1 = TCON^3;
59 =1 sbit IT1 = TCON^2;
60 =1 sbit IE0 = TCON^1;
61 =1 sbit IT0 = TCON^0;
62 =1
63 =1 /* IE */
64 =1 sbit EA = IE^7;
65 =1 sbit ET2 = IE^5; //8052 only
66 =1 sbit ES = IE^4;
67 =1 sbit ET1 = IE^3;
68 =1 sbit EX1 = IE^2;
69 =1 sbit ET0 = IE^1;
70 =1 sbit EX0 = IE^0;
71 =1
72 =1 /* IP */
C51 COMPILER V7.50 TEXT1 04/17/2007 18:33:47 PAGE 3
73 =1 sbit PT2 = IP^5;
74 =1 sbit PS = IP^4;
75 =1 sbit PT1 = IP^3;
76 =1 sbit PX1 = IP^2;
77 =1 sbit PT0 = IP^1;
78 =1 sbit PX0 = IP^0;
79 =1
80 =1 /* P3 */
81 =1 sbit RD = P3^7;
82 =1 sbit WR = P3^6;
83 =1 sbit T1 = P3^5;
84 =1 sbit T0 = P3^4;
85 =1 sbit INT1 = P3^3;
86 =1 sbit INT0 = P3^2;
87 =1 sbit TXD = P3^1;
88 =1 sbit RXD = P3^0;
89 =1
90 =1 /* SCON */
91 =1 sbit SM0 = SCON^7;
92 =1 sbit SM1 = SCON^6;
93 =1 sbit SM2 = SCON^5;
94 =1 sbit REN = SCON^4;
95 =1 sbit TB8 = SCON^3;
96 =1 sbit RB8 = SCON^2;
97 =1 sbit TI = SCON^1;
98 =1 sbit RI = SCON^0;
99 =1
100 =1 /* P1 */
101 =1 sbit T2EX = P1^1; // 8052 only
102 =1 sbit T2 = P1^0; // 8052 only
103 =1
104 =1 /* T2CON */
105 =1 sbit TF2 = T2CON^7;
106 =1 sbit EXF2 = T2CON^6;
107 =1 sbit RCLK = T2CON^5;
108 =1 sbit TCLK = T2CON^4;
109 =1 sbit EXEN2 = T2CON^3;
110 =1 sbit TR2 = T2CON^2;
111 =1 sbit C_T2 = T2CON^1;
112 =1 sbit CP_RL2 = T2CON^0;
113 =1
114 =1 #endif
3 #include<absacc.h>
1 =1 /*--------------------------------------------------------------------------
2 =1 ABSACC.H
3 =1
4 =1 Direct access to 8051, extended 8051 and Philips 80C51MX memory areas.
5 =1 Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
6 =1 All rights reserved.
7 =1 --------------------------------------------------------------------------*/
8 =1
9 =1 #ifndef __ABSACC_H__
10 =1 #define __ABSACC_H__
11 =1
12 =1 #define CBYTE ((unsigned char volatile code *) 0)
13 =1 #define DBYTE ((unsigned char volatile data *) 0)
14 =1 #define PBYTE ((unsigned char volatile pdata *) 0)
15 =1 #define XBYTE ((unsigned char volatile xdata *) 0)
16 =1
17 =1 #define CWORD ((unsigned int volatile code *) 0)
18 =1 #define DWORD ((unsigned int volatile data *) 0)
19 =1 #define PWORD ((unsigned int volatile pdata *) 0)
C51 COMPILER V7.50 TEXT1 04/17/2007 18:33:47 PAGE 4
20 =1 #define XWORD ((unsigned int volatile xdata *) 0)
21 =1
22 =1
23 =1 #ifdef __CX51__
=1 #define FVAR(object, addr) (*((object volatile far *) (addr)))
=1 #define FARRAY(object, base) ((object volatile far *) (base))
=1 #define FCVAR(object, addr) (*((object const far *) (addr)))
=1 #define FCARRAY(object, base) ((object const far *) (base))
=1 #else
29 =1 #define FVAR(object, addr) (*((object volatile far *) ((addr)+0x10000L)))
30 =1 #define FCVAR(object, addr) (*((object const far *) ((addr)+0x810000L)))
31 =1 #define FARRAY(object, base) ((object volatile far *) ((base)+0x10000L))
32 =1 #define FCARRAY(object, base) ((object const far *) ((base)+0x810000L))
33 =1 #endif
34 =1
35 =1 #endif
4 typedef unsigned char BYTE;
5 #define LCD_CMD_WR 0x00
6 #define LCD_DATA_WR 0x01
7 #define LCD_BUSY_RD 0x02
8 #define LCD_DATA_RD 0x03
9
10 //LCD Commands
11 #define LCD_CLS 0x01
12 #define LCD_HOME 0x02
13 #define LCD_SETMODE 0x04
14 #define LCD_SETVISIBLE 0x08
15 #define LCD_SHIFT 0x10
16 #define LCD_SETFUNCTION 0x20
17 #define LCD_SETCGADDR 0x40
18 #define LCD_SETDDADDR 0x80
19
20 #define COMWR XBYTE [0x0000]
21 #define DATWR XBYTE [0x0001]
22 #define BUSYRD XBYTE [0x0002]
23 #define DATRD XBYTE [0x0003]
24 #define MAX_DISPLAY_CHAR 0x14
25
26 BYTE text[] = {0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,'\n'};
-
27 BYTE pacmanopen[] = {0x0E,0x07,0x03,0x01,0x03,0x07,0x0E,0x00,'\n'};
28 BYTE pacmanshut[] = {0x00,0x0F,0x1F,0x01,0x1F,0x0F,0x00,0x00,'\n'};
29
30 void wrcmd (char cmdcode);
31 void lcd_init (void);
32 void pause(int num);
33 void clearscreen ();
34 //void eat (void);
35 void main(void);
36 {
*** ERROR C141 IN LINE 36 OF TEXT1.C: syntax error near '{'
37 char *textptr = text;
38 lcd_init(); // Initialise the LCD Display
*** ERROR C231 IN LINE 38 OF TEXT1.C: 'lcd_init': redefinition
39 for (;;) // Loop Forever.
*** ERROR C141 IN LINE 39 OF TEXT1.C: syntax error near 'for'
*** ERROR C141 IN LINE 39 OF TEXT1.C: syntax error near ';'
40 { textptr = text;
*** ERROR C279 IN LINE 40 OF TEXT1.C: 'textptr': multiple initialization
*** ERROR C231 IN LINE 40 OF TEXT1.C: 'textptr': redefinition
41 while (*textptr != '\n') // Write the String.
*** ERROR C141 IN LINE 41 OF TEXT1.C: syntax error near 'while'
C51 COMPILER V7.50 TEXT1 04/17/2007 18:33:47 PAGE 5
*** ERROR C141 IN LINE 41 OF TEXT1.C: syntax error near '!=', expected ')'
42 {
43 wrdata(*textptr++);
*** ERROR C141 IN LINE 43 OF TEXT1.C: syntax error near '*'
44 pause(2000);
*** ERROR C141 IN LINE 44 OF TEXT1.C: syntax error near '2000'
45 }
*** ERROR C141 IN LINE 45 OF TEXT1.C: syntax error near '}'
46 pause(5000);
*** ERROR C141 IN LINE 46 OF TEXT1.C: syntax error near '5000'
47 eat(); // Show and Animate the pacman.
48 pause(5000);
*** ERROR C141 IN LINE 48 OF TEXT1.C: syntax error near '5000'
49 }
*** ERROR C141 IN LINE 49 OF TEXT1.C: syntax error near '}'
50 }
51
52 void eat (void)
53 // Show the pacman and 'eat' the text.
54 { int count = MAX_DISPLAY_CHAR-1, eatflag = 0 , tmp;
*** ERROR C231 IN LINE 54 OF TEXT1.C: 'eat': redefinition
55 1 while (count >= 0)
56 1 {
57 2 wrcmd(LCD_SETDDADDR + count); // Work from right to left.
58 2 eatflag ? wrdata(0x00): wrdata(0x01); // Toggle the custom graphics between mouth open
- and mouth shut.
59 2 eatflag ^= 1;
60 2 for (tmp = count; tmp <=MAX_DISPLAY_CHAR; ++tmp) // Anything to the right of pacman is wiped.
61 2 wrdata(' ');
62 2
63 2 count--; // Decrement the count (moving us 1 to the left)
-.
64 2 pause(4000);
65 2 }
66 1 clearscreen(); // Clear the final pacman graphic when we are do
-ne.
67 1 }
*** ERROR C231 IN LINE 67 OF TEXT1.C: 'eat': redefinition
68
69 void pause (int num)
70 {
*** ERROR C231 IN LINE 70 OF TEXT1.C: '_pause': redefinition
71 1 while(num--)
72 1 ;
73 1 }
74
75 void lcd_init (void)
76 {
77 1 wrcmd(LCD_SETFUNCTION); // 4-bit mode - 1 line - 5x7 font.
78 1 wrcmd(LCD_SETVISIBLE+0x04); // Display no cursor - no blink.
79 1 wrcmd(LCD_SETMODE+0x02); // Automatic Increment - No Display shift.
80 1
81 1 // Write Custom Character to CG RAM.
82 1 wrcgchr(pacmanopen, 0); // Offset 0 - 40h-47h in CGRAM.
83 1 wrcgchr(pacmanshut, 8); // Offset 8 - 48h-4Fh in CGRAM.
84 1
85 1 wrcmd(LCD_SETDDADDR); // Address DDRAM with 0 offset 80h.
86 1 }
87
88 void clearscreen ()
89 { wrcmd(LCD_CLS);
90 1 wrcmd(LCD_SETDDADDR+0x00);
C51 COMPILER V7.50 TEXT1 04/17/2007 18:33:47 PAGE 6
91 1 }
92
93 void wrcmd (CHAR cmdcode)
94 {
95 1 COMWR=cmdcode;
96 1 lcd_wait();
97 1 }
98
99 void wrdata (char ddata)
100 {
101 1 DATWR=ddata;
102 1 lcd_wait(); // Call the wait routine.
103 1 }
104
105 void wrcgchr(BYTE *arrayptr, int offset)
106 {
107 1 wrcmd(LCD_SETCGADDR + offset);
108 1 while (*arrayptr != '\n')
109 1 { wrdata (*arrayptr++);
110 2 }
111 1 }
112
113 void lcd_wait ()
114 { BYTE status;
115 1 do
116 1 { status=BUSYRD;
117 2 } while (status & 0x80);
118 1 }
119
120
121
122
123
124
C51 COMPILATION COMPLETE. 0 WARNING(S), 17 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -