帮忙把这段汇编翻译成C语言,我不会单片机C语言的编程,程序很简单的

来源:百度知道 编辑:UC知道 时间:2024/06/23 22:36:51
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP ITOP
ORG 1000H
MAIN: SETB EA
SETB EX0
SJMP $
ITOP: PUSH PSW
PUSH ACC
CPL P1.0
POP ACC
POP PSW
RETI
END


ORG 0000H
LJMP MAIN
ORG 000BH
LJMP ITOP
ORG 1000H
MAIN: SETB EA
SETB EX0
HERE: SJMP HERE
ITOP: PUSH PSW
PUSH ACC
INC B
MOV P1,B
POP ACC
POP PSW
RETI
END
回三楼的,给INTO一个单脉冲 申请中断,是人为给的中断,已在试验箱上实验结果正确

第一个:
#include<reg52.h>
main()
{
EA=1;
EX0=1;
while(1);//等待中断
}
void ex0_interrupt(void) interrupt 0 //外中断0处理程序
{
P1^1~=P1^1 //p1.1位取反
}

第二个差不多:
#include<reg52.h>
main()
{
EA=1;
EX0=1;
while(1);
}
void ex0_interrupt(void) interrupt 0
{
B++;
P1=B;
}

1楼已经作答了。

第一个好像不能中断
#include<reg52.h>
sbit led=P2^0;
sbit led1=P1^1;

void main()
{
EA=1;
EX0=1;
while(1);

led=0;
led1=0;

}

void ex0_interrupt(void) interrupt 1 //外中断0处理程序
{
led1=!led1;//p1.1位取反
}