|
C語言程序如圖,實(shí)在是不會(huì)轉(zhuǎn)匯編,求大佬幫忙指點(diǎn)思路,想自己搞定
//12M晶振。4位共陰數(shù)碼管,P0 段碼,P2.0~P2.3 位控
//顯示 00.00~99.99
//2011 07 07 E:\DPJ_C\00.00\00.00.c
#include <reg51.h>
#define uchar unsigned char
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
sbit P27=P0^7;
sbit KS=P1^0; //開始
sbit KR=P1^1; //復(fù)位
uchar time,xs,ge,shi,bai,qian;
uchar code tab[ ]= {
0x3F,/*0*/
0x06,/*1*/
0x5B,/*2*/
0x4F,/*3*/
0x66,/*4*/
0x6D,/*5*/
0x7D,/*6*/
0x07,/*7*/
0x7F,/*8*/
0x6F,/*9*/
};
void delay_ms(unsigned int ms) //1ms延時(shí)
{
uchar a;
while(ms--)
for(a=123;a>0;a--);
}
void display();
void T0intinit( ) //定時(shí)器T0初始化
{
TMOD=0x01;
TH0=(65536-10000)/256; //10ms定時(shí)
TL0=(65536-10000)%256;
EA=1;
ET0=1;
}
void main()
{
T0intinit( );
while(1)
{
display( );
while(!KS) //開始/暫停 鍵
{
display( );
if(KS)
TR0=!TR0;
}
while(!KR) //清零鍵
{
display( );
if(KR)
TR0=0;
qian=0;
bai=0;
shi=0;
ge=0;
}
if(bai==10)
{
bai=0;
qian++;
}
if(qian==10)
{
qian=0;
TR0=0;
}
}
}
void display( )
{
P23=0;
P0=tab[ge];
delay_ms(1);
P23=1;
P22=0;
P0=tab[shi];
delay_ms(1);
P22=1;
P21=0;
P0=tab[bai]|0x80;
delay_ms(1);
P21=1;
P20=0;
P0=tab[qian];
delay_ms(1);
P20=1;
}
void T0int( ) interrupt 1 //定時(shí)器T0中斷 方式1
{
TH0=(65536-10000)/256; //重裝10ms定時(shí)常數(shù)
TL0=(65536-10000)%256;
ge++;
if(ge==10)
{
ge=0;
shi++;
}
if(shi==10)
{
shi=0;
bai++;
}
}
實(shí)在是不會(huì)
|
-
|