?? 1.lst
字號(hào):
C51 COMPILER V8.08 1 05/18/2009 08:24:07 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE 1
OBJECT MODULE PLACED IN 1.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE 1.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg52.h>
2 sbit F1=P1^0;
3 sbit F2=P1^1;
4 sbit M1=P1^2;
5 sbit M2=P1^3;
6 sbit BEEP=P1^4;
7 #define uchar unsigned char
8 #define uint unsigned int
9 void delay(uint z);
10 uchar num,temp;
11 uchar keyscan();
12 void display();
13
14 uchar m[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
15
16 int a=0,b=0,c=0,d=0;
17
18 void main()
19 {
20 1 P1=0xf0;
21 1 // P0=0xc0;
22 1 TMOD = 0x01; //使用定時(shí)器 0 的 16 位工作模式
23 1 TR0 = 0;
24 1 ET0 = 1;
25 1 EA = 1;
26 1 while(1)
27 1 {
28 2 display();
29 2 while(keyscan())
30 2 {
31 3 a=keyscan();
32 3 }
33 2 display();
34 2 while(keyscan())
35 2 {
36 3 b=keyscan();
37 3 }
38 2 display();
39 2 while(keyscan())
40 2 {
41 3 c=keyscan();
42 3 }
43 2 display();
44 2 while(keyscan())
45 2 {
46 3 d=keyscan();
47 3 }
48 2 display();
49 2 /* if(keyscan()==16)
50 2 {
51 2 break;
52 2 } */
53 2 while(keyscan()!=13);
54 2 TR0=1;
55 2 delay(400);
C51 COMPILER V8.08 1 05/18/2009 08:24:07 PAGE 2
56 2 display();
57 2 }
58 1 }
59
60
61
62 void display()
63 {
64 1 while(!keyscan())
65 1 {
66 2 if(a==10)
67 2 {
68 3 a=0;
69 3 }
70 2 if(b==10)
71 2 {
72 3 b=0;
73 3 }
74 2 if(c==10)
75 2 {
76 3 c=0;
77 3 }
78 2 if(d==10)
79 2 {
80 3 d=0;
81 3 }
82 2 F1=0;
83 2 P0=m[a];
84 2 delay(5);
85 2 F1=1;
86 2 F2=0;
87 2 P0=m[b];
88 2 delay(5);
89 2 F2=1;
90 2 M1=0;
91 2 P0=m[c];
92 2 delay(5);
93 2 M1=1;
94 2 M2=0;
95 2 P0=m[d];
96 2 delay(5);
97 2 M2=1;
98 2 }
99 1 }
100
101
102
103
104 uchar keyscan()
105 {
106 1 num=0;
107 1 P2=0xef;
108 1 temp=P2;
109 1 temp=temp&0x0f;
110 1 if(temp!=0x0f)
111 1 {
112 2 delay(5);
113 2 temp=P2;
114 2 temp=temp&0x0f;
115 2 if(temp!=0x0f)
116 2 {
117 3 temp=P2;
C51 COMPILER V8.08 1 05/18/2009 08:24:07 PAGE 3
118 3 switch(temp)
119 3 {
120 4 case 0xee: num=1;break;
121 4 case 0xed: num=2;break;
122 4 case 0xeb: num=3;break;
123 4 case 0xe7: num=4;break;
124 4
125 4 }
126 3 }
127 2 }
128 1
129 1 P2=0xdf;
130 1 temp=P2;
131 1 temp=temp&0x0f;
132 1 if(temp!=0x0f)
133 1 {
134 2 delay(5);
135 2 temp=P2;
136 2 temp=temp&0x0f;
137 2 if(temp!=0x0f)
138 2 {
139 3 temp=P2;
140 3 switch(temp)
141 3 {
142 4 case 0xde: num=5;break;
143 4 case 0xdd: num=6;break;
144 4 case 0xdb: num=7;break;
145 4 case 0xd7: num=8;break;
146 4
147 4 }
148 3 }
149 2 }
150 1
151 1 P2=0xbf;
152 1 temp=P2;
153 1 temp=temp&0x0f;
154 1 if(temp!=0x0f)
155 1 {
156 2 delay(5);
157 2 temp=P2;
158 2 temp=temp&0x0f;
159 2 if(temp!=0x0f)
160 2 {
161 3 temp=P2;
162 3 switch(temp)
163 3 {
164 4 case 0xbe: num=9;break;
165 4 case 0xbd: num=10;break;
166 4 case 0xbb: num=11;break;
167 4 case 0xb7: num=12;break;
168 4
169 4 }
170 3 }
171 2 }
172 1
173 1
174 1 P2=0x7f;
175 1 temp=P2;
176 1 temp=temp&0x0f;
177 1 if(temp!=0x0f)
178 1 {
179 2 delay(5);
C51 COMPILER V8.08 1 05/18/2009 08:24:07 PAGE 4
180 2 temp=P2;
181 2 temp=temp&0x0f;
182 2 if(temp!=0x0f)
183 2 {
184 3 temp=P2;
185 3 switch(temp)
186 3 {
187 4 case 0x7e: num=13;break;
189 4 case 0x7b: num=15;break;
190 4 case 0x77: num=16;break;
191 4
192 4 }
193 3 }
194 2 }
195 1 return num;
197
198 void delay(uint z)
199 {
200 1 uint x,y;
201 1 for (x=z;x>0;x--)
202 1 for(y=110;y>0;y--);
203 1 }
204
205
206 void x() interrupt 1
207 {
208 1 uint t;
209 1 TH0=(65536-50000)/256;
210 1 TL0=(65536-50000)%256;
211 1 t++;
212 1 if(t==20)
213 1 {
214 2 t=0;
215 2 d--;
216 2 if(d+1==0)
217 2 {
218 3 d=9;
219 3 c--;
220 3 if(c+1==0)
221 3 {
222 4 c=5;
223 4 b--;
224 4 if(b+1==0)
225 4 {
226 5 b=9;
227 5 a--;
228 5 }
229 4 }
230 3 }
231 2 }
232 1 if(a==0&&b==0&&c==0&&d==0)
233 1 {
234 2 BEEP=0;
235 2 TR0=0;
236 2 }
237 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 677 ----
C51 COMPILER V8.08 1 05/18/2009 08:24:07 PAGE 5
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 20 2
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -