org 0000h start: mov a,#0ffh mov p1,a ;p1口置高电平 mov p2,a ;p2口置高电平 mov r2,#0feh mov r3,#0h next: mov a,p2 ;是否键被按下 cjne a,#0ffh,dlay0 ljmp next dlay0: mov r1,#0ffh ;消除开关抖动 djnz r1,$ mov a,p2 cjne a,#0ffh,disply ljmp next disply: mov p1,r2 cjne r3,#1h,left ;确定是否向左移 right: mov a,r2 rr a mov r2,a cjne r2,#0feh,chgl acall delay ljmp disply left: mov a,r2 ;把位向左移一位 rl a mov r2,a cjne r2,#7fh,chgr ;比较是否p1.7亮 acall delay chgl: mov r3,#1h acall delay ljmp disply chgr: mov r3,#0h acall delay ljmp disply
delay: mov r4,#0ffh d1: mov r5,#0ffh d2: mov r6,#6h dl3: djnz r6,dl3 ` djnz r5,d2 djnz r4,d1 RET END
p1.0-p1.7接发光二极管,低电平时亮,开关接在p2.0上,想通过开关控制流水灯,目标是让二极管从1亮到7再从7亮到1,在keic中编译总有错误,显示标号为dl3的程序有语法错误,
|