DELAY:MOVR3,#100;2DLY0:MOVR2,#249;2*100DLY1:DJNZR2,DLY1;249*2*100MOVR2,#248;2*100DLY2:DJNZR2,DLY2;248*2*100DJNZR3,DLY0;2*100RET;2以上假设12M晶振,延时共2+(249*2+2+248*2)*100+2=100004微妙=100.004毫秒
DELAY:
MOV R3,#100 ;2
DLY0:
MOV R2,#249 ;2*100
DLY1:
DJNZ R2,DLY1 ;249*2*100
MOV R2,#248 ;2*100
DLY2:
DJNZ R2,DLY2 ;248*2*100
DJNZ R3,DLY0 ;2*100
RET ;2
以上假设12M晶振,延时共2+(249*2+2+248*2)*100+2=100004微妙=100.004毫秒