📄 v100.lst
字号:
C51 COMPILER V7.02b V100 04/20/2004 10:36:57 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE V100
OBJECT MODULE PLACED IN v100.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE v100.c DEBUG OBJECTEXTEND
stmt level source
1 //Demo board system
2 //Designed 2002/12/25
3 //Modify ----------
4 //Software Version V1.0
5 //Hardware Version V1.0
6
7 #include <stdlib.h>
8 #include <LCD.h>
9 #include <reg51.h>
10 typedef unsigned char byte;
11 typedef unsigned int word;
12 #define XTALL 11.0592 //crystal frequency
13 #define DLY_10MS (word)(10000*XTALL/12) // 10ms counter
14 #define DLY_400US (word)(400*XTALL/12) // 400us counter
15 #define speed 30
16 #define LCD_port *(byte xdata*)(0x0000)
17 #define xram ( byte xdata *)(0x8000)
18
19 sbit power = 0x94; //p1.4
20 sbit lcd_power = 0x95; //p1.5
21 sbit DI = 0x92; //p1.2
22 sbit RW = 0x91; //p1.1
23 sbit E = 0x90; //p1.0
24 sbit LCD1 = 0x93; //p1.3
25 sbit LCD2 = 0x96; //p1.6
26 //sbit RST = 0xB0; //p3.0
27 //sbit RAM = 0xB1; //P3.1
28 //sbit UP = 0xB5; //P3.2
29 //sbit DOWN = 0xB4; //P3.3
30 //sbit LEFT = 0xB3; //P3.4
31 //sbit RIGHT = 0xB2; //p3.5
32 sbit C573 = 0x97; //p1.7
33
34 extern bit key_exit;
35
36 extern game(void);
37 extern byte REG573;
38 extern bit move_flag;
39 idata byte last_key;
40 word key_count;
41 //#define k xram[2130];
42 //byte code key_code[16]={0xff,0xe7,0xf3,0xb7,0xcf,0xff,};//1:up 2:left 3:right 4:down
43
44 //------------------------------10ms timer counter-----------------------------
45 void TIM0_isr() interrupt 1 using 1
46 {
47 1 static idata word timercount;
48 1 TR0=0;
49 1 TL0+=-DLY_10MS&0xff;
50 1 TH0+=-DLY_10MS>>8;
51 1 TR0=1;
52 1 if(timercount++ >speed){
53 2 timercount=0;
54 2 move_flag=1;
55 2 }
C51 COMPILER V7.02b V100 04/20/2004 10:36:57 PAGE 2
56 1 if(key_count++>=10){ //press key 30ms force exit
57 2 key_count=0;
58 2 key_exit=1;
59 2 }
60 1 }
61 //-----------------------------key board service program----------------------
62 byte key(void)
63 {
64 1
65 1 return 0xff;
66 1 }
67 //---------------------------reset the lcd controller chip---------------------
68 void reset_lcd(void){
69 1 word i;
70 1 C573 = 1;
71 1 P2 = CS_16550;
72 1 REG573 = CS_16550;
73 1 C573 = 0;
74 1
75 1 MCR = 0X06;
76 1 MCR = 00;
77 1 for(i=0;i<1000;i++);
78 1 }
79 //-------------------------write a command to left part of lcd ---------------
80 void write_l_com(byte com){
81 1 byte ch;
82 1 LCD2=0;
83 1 LCD1=1;
84 1 ch = REG573;
85 1 C573 =1;
86 1 REG573 = CS_LCD;
87 1 P2 = CS_LCD;
88 1 C573 = 0;
89 1
90 1 RW=0;
91 1 DI=0;
92 1 LCD_port = com;
93 1 E=1;
94 1 E=1;
95 1 E=0;
96 1 C573 = 1;
97 1 P2 = ch;
98 1 REG573 = ch;
99 1 C573 = 0;
100 1 C573 = 0;
101 1 }
102 //----------------------write a data to left part of lcd-----------------------
103 void write_l_dat(byte dat){
104 1 byte ch;
105 1 LCD2=0;
106 1 LCD1=1;
107 1 ch = REG573;
108 1 C573 =1;
109 1 REG573 = CS_LCD;
110 1 P2 = CS_LCD;
111 1 C573 = 0;
112 1 RW=0;
113 1 DI=1;
114 1 LCD_port = dat;
115 1 E=1;
116 1 E=1;
117 1 E=0;
C51 COMPILER V7.02b V100 04/20/2004 10:36:57 PAGE 3
118 1 C573 = 1;
119 1 P2 = ch;
120 1 REG573 = ch;
121 1 C573 = 0;
122 1 C573 = 0;
123 1 }
124 //--------------------------write a command to right part of lcd --------------
125 void write_r_com(byte com){
126 1 byte ch;
127 1 LCD2=1;
128 1 LCD1=0;
129 1 ch = REG573;
130 1 C573 =1;
131 1 REG573 = CS_LCD;
132 1 P2 = CS_LCD;
133 1 C573 = 0;
134 1 RW=0;
135 1 DI=0;
136 1 LCD_port = com;
137 1 E=1;
138 1 E=1;
139 1 E=0;
140 1 C573 = 1;
141 1 P2 = ch;
142 1 REG573 = ch;
143 1 C573 = 0;
144 1 C573 = 0;
145 1 }
146 //------------------------write a data to right part of lcd--------------------
147 void write_r_dat(byte dat){
148 1 byte ch;
149 1 LCD2=1;
150 1 LCD1=0;
151 1 ch = REG573;
152 1 C573 =1;
153 1 REG573 = CS_LCD;
154 1 P2 = CS_LCD;
155 1 C573 = 0;
156 1 RW=0;
157 1 DI=1;
158 1 LCD_port = dat;
159 1 E=1;
160 1 E=1;
161 1 E=0;
162 1 C573 = 1;
163 1 P2 = ch;
164 1 REG573 = ch;
165 1 C573 = 0;
166 1 C573 = 0;
167 1 }
168 //----------------------initialize lcd-----------------------------------------
169 void init_lcd(){
170 1 byte i,j,page;
171 1 word offset;
172 1 reset_lcd();
173 1 write_l_com(0x3f);
174 1 write_l_com(0xc0);
175 1 write_r_com(0x3f);
176 1 write_r_com(0xc0);
177 1 page=0;
178 1 for(i=0;i<8;i++){
179 2 page=i|0xb8;
C51 COMPILER V7.02b V100 04/20/2004 10:36:57 PAGE 4
180 2 write_l_com(page);
181 2 write_l_com(0x40);
182 2 write_r_com(page);
183 2 write_r_com(0x40);
184 2 for(j=0;j<64;j++){
185 3 write_l_dat(0x00);
186 3 write_r_dat(0x00);
187 3
188 3 }
189 2 }
190 1 C573 = 1;
191 1 P2 = CS_256;
192 1 C573 = 0;
193 1 for(offset=0;offset<1024;offset++){
194 2 *(xram+offset)=0x00;
195 2 }
196 1 }
197 //---------------------display the data from the xdata buffer-----------------
198 void display(){ //the display buffer is from 0x0000 to 0x0400 total 1024 byte
199 1 byte i,j,page=0;
200 1 for(i=0;i<8;i++){
201 2 page=i|0xb8;
202 2 write_l_com(page); //write the page of lcd display buffer memory
203 2 write_l_com(40); //set the start pixel
204 2 for(j=0;j<64;j++){
205 3 write_l_dat(*(xram+(128*i)+j));
206 3 }
207 2 } //write the data to left part of lcd
208 1
209 1 for(i=0;i<8;i++){
210 2 page=i|0xb8;
211 2 write_r_com(page); //write the page of lcd display buffer memory
212 2 write_r_com(40); //set the start pixel
213 2 REG573 = CS_256;
214 2 C573 = 1;
215 2 P2 = CS_256;
216 2 C573 = 0;
217 2 for(j=0;j<64;j++){
218 3 write_r_dat(*(xram+(128*i)+64+j));
219 3 }
220 2 } //write the data to right part of lcd
221 1 }
222
223 //-----------------------CPU initialization-----------------------------------
224
225 void init(void) {
226 1 TMOD=0x21 ; // (T1 MODE 2_send_flagME,T0 MODE 1_send_flagME)
227 1 TCON=0x51 ; //0101 0000 (TR1=1 , TR0=1
228 1 SCON=0x50 ; //0101 0000 (MODE 1 ;RECEIVE ENABLE)
229 1 IP=0x10 ; //0001 0000 (S-PORT HIGH interrupt)
230 1 IE=0x12 ; //0001 0010 (S_PORT AND TIME0 ENABLE INT)
231 1 TL1=TH1=0xfd; //9600bps
232 1 PCON=0x00; //SMOD=0
233 1 IE = 0x92;
234 1 TR1=0;
235 1 // RAM=0; //static ram be select
236 1 EA=1; // enable all interrupt
237 1 }
238
239 //-----------------------------------------------------------------------------
240 void main(){
241 1 word i;
C51 COMPILER V7.02b V100 04/20/2004 10:36:57 PAGE 5
242 1 power=0;
243 1 lcd_power=0;
244 1 init();
245 1 init_lcd();
246 1 while(1){
247 2 REG573 = CS_256;
248 2 C573 = 1;
249 2 P2 = CS_256;
250 2 C573 = 0;
251 2 game();
252 2 //------------------------------------------------
253 2 display();
254 2 while(1){
255 3 i=rand();
256 3 }
257 2 }
258 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 570 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 2 2
IDATA SIZE = 3 ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -