• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

汇编程序改为C语言程序

陌路绝途 2014-06-24 浏览量:1349
收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
所有亮答 数量:9

  • 网上应该是汇编转C的小工具吧?!我们写硬件描述代码都有verilog和vhdl之间互转的小工具

  • 自己翻译了一下,不保证一定能实现你要的效果,大概程序是这样,不知道你引脚接的什么,所以只能用a,b,c,d,e代替

    #include
    #define uchar unsigned char 
    #define uint  unsigned int
    sbit a=P3^0;
    sbit b=P3^1;
    sbit c=P1^2; 
    sbit d=P1^0;
    sbit e=P3^2;
    uchar num=14;
    
    void delay()
    {
    	uint x,y;
    	for(x=110;x>0;x--)
    		for(y=100;y>0;y--);
    }
    
    void alarm()
    {
    	c=1;
    	a=~a;
    	b=~b;
    	TMOD=0x01;
    	TL0=0xb0;
    	TH0=0x3c;
    	TR0=1;
    	if(TF0==1)
    	{
    		TL0=0xb0;
    		TH0=0x3c;
    		num--;
    		if(num==0)
    		{
    			num=14;
    			a=1;
    			b=0;
    			c=0;
    
    		}
    	}
    }
    
    void main()
    {
    	IE=0x81;
    	IT0=1;
    	a=1;
    	b=0;
    	P1=0xff;
    	P2=0x00;
    	c=0;
    	while(1)
    	{
    		if(d==0)
    		{
    			delay();
    			if(d==0)
    			{
    				alarm();
    			}
    		}
    	}
    }
    
    void INT_0() interrupt 0
    {
    	EX0=0;
    	if(e==0)
    	{
    		delay();
    		if(e==0)
    		{
    			a=1;
    			b=0;
    			c=0;
    			EX0=1;
    			if(d==0)
    			{
    			delay();
    			if(d==0)
    			{
    				alarm();
    			}
    			}
    		}
    	}
    }
    
    
    

相关问题

问题达人换一批

汇编程序改为C语言程序