谁能帮我把这个汇编程序变成c程序?急需,解决后还有重谢!!

2024年11月22日 10:03
有2个网友回答
网友(1):

#include

unsigned char code dat[] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
volatile unsigned char data LED_0, LED_1, LED_2, ADC;

sbit D0 = P2^3;
sbit D1 = P2^2;
sbit D2 = P2^1;

sbit ADC0808_CLOCK = P2^4;
sbit ST = P2^5;
sbit EOC = P2^6;
sbit OE = P2^7;

void delay(void)
{
unsigned char r6 = 10, r7;
while(r6)
{
r7 = 250;
while(r7)
r7--;
r6--;
}
}

void init(void)
{
LED_0 = 0x00;
LED_1 = 0x00;
LED_2 = 0x00;
TMOD = 0x02;
TH0 = 245;
TL0 = 0x00;
IE = 0x82;
TR0 =1;
}

void T0_handle(void) interrupt 1
{
if(ADC0808_CLOCK)
ADC0808_CLOCK = 0;
else
ADC0808_CLOCK = 1;
}

void DISP(unsigned char L0, L1, L2)
{

D0 = 0;
P0 = dat[L0];
delay();
D0 = 1;

D1 = 0;
P0 = dat[L1];
delay();
D1 = 1;

D2 = 0;
P0 = dat[L2];
delay();
D2 = 1;
}

void main(void)
{
init();
while(1)
{
ST = 0;
ST = 1;
ST = 0;
while(!EOC);
ADC = P1;
OE = 0;
LED_2 = ADC/51;
LED_1 = (ADC%51)/10;
LED_0 = (ADC%51)%10;
DISP(LED_0,LED_1,LED_2);
}
}

网友(2):

这个程序似曾相识啊