经过修正中止操控的寄存器IP能够使中止嵌套,一起能够修正中止优先级。详细c程序如下:
#include
#include
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)//延时函数
{
while(z–);
}
void main()
{
//uint i,j;
// i=0xfe;
//j=0x01;
EA=1;
EX0=1;
EX1=1;
PX0=0;
PX1=1;
}
void intt0() interrupt 0
{
uint i=0xfe;
while(1)
{
i=_crol_(i,1);
P2=i;
delay(50000);
}
}
void intt1() interrupt 2
{
uint j=0x01;
while(1)
{
j=_crol_(j,1);
P2=j;
delay(50000);
}
}
#include
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)//延时函数
{
while(z–);
}
void main()
{
//uint i,j;
// i=0xfe;
//j=0x01;
EA=1;
EX0=1;
EX1=1;
PX0=0;
PX1=1;
}
void intt0() interrupt 0
{
uint i=0xfe;
while(1)
{
i=_crol_(i,1);
P2=i;
delay(50000);
}
}
void intt1() interrupt 2
{
uint j=0x01;
while(1)
{
j=_crol_(j,1);
P2=j;
delay(50000);
}
}
汇编语言程序如下:
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP INTT0
ORG 0013H
AJMP INTT1
ORG 0030H
MAIN:SETB EA
SETB EX0
SETB EX1
CLR PX0
SETB PX1
AJMP $
INTT0:MOV A,#0FEH
LOOP1:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP1
RETI
INTT1:MOV A,#01H
LOOP2:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP2
RETI
DELAY:MOV R6,#255
LP: MOV R7,#100
DJNZ R7,$
DJNZ R6,LP
RET
END
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP INTT0
ORG 0013H
AJMP INTT1
ORG 0030H
MAIN:SETB EA
SETB EX0
SETB EX1
CLR PX0
SETB PX1
AJMP $
INTT0:MOV A,#0FEH
LOOP1:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP1
RETI
INTT1:MOV A,#01H
LOOP2:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP2
RETI
DELAY:MOV R6,#255
LP: MOV R7,#100
DJNZ R7,$
DJNZ R6,LP
RET
END