|
2積分
這是一段我程序中的匯編語言,我想把它改成C語言,但是一直沒有調試出正確的結果,希望高手指點一下!謝謝了!
TIME0: PUSH PSW ;定時器0中斷程序
DJNZ R4,TIME0E
PUSH ACC
MOV A,#00H
MOVC A,@A+DPTR
CJNE A,#00H,TIM01
CLR 7EH
CLR 7BH
ANL P2,#0FH
CLR TR0
CLR ET0
TIME0E2: POP ACC
TIME0E: POP PSW
RETI
;
TIM01: INC DPTR
MOV R4,A
CJNE A,#0FFH,TIM01A
CPL 7BH
TIM01A: CPL 7BH
JB 7BH,TIM02
ANL P2,#0FH
POP ACC
POP PSW
RETI
;
TIM02: MOV A,R2
ORL P2,A
POP ACC
POP PSW
RETI
REM: NOP
JB 7EH,REM
MOV A,#00H
MOVC A,@A+DPTR
CJNE A,#00H,REME ;IF 00H THEN END CODE
RET
REME: MOV R4,A
INC DPTR
SETB 7EH ;SET FLAGE OF DRIVE TIME0
SETB 7BH ;SET FLAGE OF SEND 1 REMOTE LED
MOV A,R3
MOV R2,A
ORL P2,A
SETB ET0
SETB TR0
RET
下面是我自己用C語言寫的:
void time0int() interrupt 1
{
shuzu--;
if(shuzu==0)
{
while(*p!=0x00)
{
p++;
shuzu=*p;
while(*p!=0xff)
{
flag0=~flag0;
if(flag0==1)
{
P2=P2|waishe;
}
else
{
P2=P2&0x0f;
}
}
flag0=~flag0;
}
flag0=0;
flag1=0;
P2=P2&0x0f;
TR0=0;
ET0=0;
}
}
void sendcode(void)
{
while(flag1)
{;}
while(*p!=0x00)
{
p++;
shuzu=*p;
flag0=1;
flag1=1;
P2=P2|waishe;
ET0=1;
TR0=1;
}
} |
|