📄 11-7.1.lst
字号:
175 1 *line = 0; //再加上停止符0
176 1 }
177 //****************************
178 putinbuf(uchar c)
179 {ES=0; if(!inbufful)
C51 COMPILER V7.09 11_7_1 08/24/2005 21:48:33 PAGE 4
180 1 {*inlast= c; //放入数据
181 2 inlast++; //最后放入的位置加一
182 2 if (inlast==inbuf+ILEN) inlast=inbuf;//地址到顶部回到底部
183 2 if (inlast==getlast) inbufful=1; //接收缓冲区满置满标志
184 2 inbufsign=1;
185 2 }
186 1 ES=1;
187 1 }
188 //*****************************************
189 //串口中断处理
190 serial () interrupt 4
191 { if (TI )
192 1 { TI = 0;
193 2 if (outbufsign)
194 2 //if (putlast==outlast) outbufsign=0;
195 2 //else
196 2 {SBUF=*outlast; //未发送完继续发送
197 3 outlast++; //最后传出去的字节位置加一
198 3 if (outlast==outbuf+OLEN) outlast=outbuf;//地址到顶部回到底部
199 3 if (putlast==outlast) outbufsign=0; //数据发送完置发送缓冲区空标志
200 3 }
201 2 }
202 1 if (RI)
203 1 { RI = 0;
204 2 if(!inbufful)
205 2 {
206 3 *inlast= SBUF; //放入数据
207 3 inlast++; //最后放入的位置加一
208 3 inbufsign=1;
209 3 if (inlast==inbuf+ILEN) inlast=inbuf;//地址到顶部回到底部
210 3 if (inlast==getlast) inbufful=1; //接收缓冲区满置满标志
211 3
212 3 }
213 2 }
214 1 }
215 //*****************************
216 //串口初始化 0xfd=19200,0xfa=9600,0xf4=4800,0xe8=2400,0xd0=1200
217 serial_init () {
218 1 SCON = 0x50; /* mode 1: 8-bit UART, enable receiver */
219 1 TMOD |= 0x20; /* timer 1 mode 2: 8-Bit reload */
220 1 PCON |= 0x80; TH1 = 0xfd;//fa, //baud*2 /* reload value 19200 baud */
221 1 TR1 = 1; /* timer 1 run */
222 1 ES = 1; REN=1; EA=1; SM2=1; //SM2=1时收到的第9位为1才置位RI标志
223 1 TMOD |=0x01; //th1 auto load 2X8,th0 1X16
224 1 TH0=31; TL0=0; //X 32 =1S
225 1 TR0=1; ET0=1;
226 1
227 1 }
228 //*****************
229 //测试用主函数
230 /*
231 void main(void)
232 {char c;
233 idata unsigned char free[16];
234 unsigned char idata *freep=free;
235 serial_init();
236 putstring(crlf);
237 putstring(comready);
238 putstring("jdioptuejls;j;klja");
239 delay(10);
240
241 while(1)
C51 COMPILER V7.09 11_7_1 08/24/2005 21:48:33 PAGE 5
242 {
243 c=getbyte();
244 putbyte(0x20);
245 puthex(c);
246 switch(c)
247 {case 'r':
248 putbytes(inbuf,ILEN);
249 break;
250 case 'g':
251 getline(freep,10);
252 putbyte(0x20);
253 putstring(freep);
254 break;
255 default:
256 putbyte(c);
257 }
258 }
259 } */
260
261 //#define cpuw77e58 //定义使用的MCU
262 //#define xtal221184 //定义使用的晶振
263 //#include <serial.c> //包含串行处理模块
264
265 bit showclocksign;
266 bit showblocksign;
267 bit showfensign;
268 uchar count;
269 uint second;
270 uchar paoplace;
271 uint zongfen;
272 uchar speed=32;
273
274 idata uint free[16]; //定义行首处理空间
275 unsigned char idata *freep; //定义指向该数组的指针
276 //****
277 gotoxy(uchar x,y)
278 {putbyte(0x1b);putbyte('['
279 1 );
280 1 putbyte((y%100)/10+0x30);
281 1 putbyte((y%10)+0x30);
282 1 putbyte(';');
283 1 putbyte((x%100)/10+0x30);
284 1 putbyte((x%10)+0x30);
285 1 putbyte('H');
286 1 }
287
288 //******************
289 clrscr()
290 {gotoxy(0,0); putbyte(0x1b); putstring("[J"); }
291
292
293 //**************
294 showpao()
295 {gotoxy(1,16); putbyte(0x1b); putstring("[K");
296 1 gotoxy(paoplace,16); putbyte('|');
297 1 gotoxy(1,17); putbyte(0x1b); putstring("[K");
298 1 gotoxy(paoplace-1,17);
299 1 putbyte('/');putbyte('H');putbyte('\\');
300 1
301 1 gotoxy(0,24);
302 1 }
303 //***************
C51 COMPILER V7.09 11_7_1 08/24/2005 21:48:33 PAGE 6
304 uint bdata showp;
305 sbit outblock=showp^15;
306 showblock() //showblock
307 {uchar i,j;//uint bdata p;
308 1 uint st;
309 1
310 1 gotoxy(0,0);
311 1 for(i=15;i!=0;i--)
312 1 {putbyte('|');
313 2 showp=free[i];
314 2 st=0x8000;
315 2 for(j=0;j!=16;j++)
316 2 { if ((showp&st)!=0) putbyte('@');
317 3 else putbyte(' ');
318 3 st>>=1;
319 3 //showp=showp>>1;
320 3
321 3 }
322 2 putbyte('|');CR;
323 2 }
324 1 gotoxy(0,24);
325 1 showblocksign=0;
326 1 }
327 //*************
328 showfen()
329 {gotoxy(6,19);
330 1 //putstring("得分: ");
331 1 putint(zongfen,1);
332 1 showfensign=0;
333 1
334 1 //putbyte(' ');
335 1 //puthex(free[15]/256); puthex(free[15]%256);
336 1 //gotoxy(0,24);
337 1 }
338
339
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1328 ----
CONSTANT SIZE = 40 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 14 6
IDATA SIZE = 44 11
BIT SIZE = 6 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -