单片机P1口数据输入、输出实验汇编程序(跑马灯实验)
以下程序已经通过实验验证---可放心使用【P1口输出实验程序】-----跑马灯--------------------------------------------------------
ORG 0000H
LJMP START
ORG 0100H
START: MOV SP,#60H
MOV A,#0FFH
MOV P1,A
ACALLDelay
CLR C
START1: MOV A,#0H
MOV P1,A
ACALLDELAY
LJMP START1
Delay: MOV R5,#2 ;延时
Delay1: MOV R6,#0
Delay2: MOV R7,#0
DJNZ R7,$
DJNZ R6,Delay2
DJNZ R5,Delay1
RET
END
【P1口输入、输出实验程序】-----跑马灯--------------------------------------------------------
ORG 0000H
LJMP START
ORG 0100H
START: MOV SP,#60H
MOV A,#0FFH
MOV P1,A
CLR C
START1: MOV P1,#00H
ACALLDelay
MOV R0,#0
CLR C
LOOP1: RLC A
MOV P1,A
ACALLDelay
INC R0
CJNE R0,#0BH,LOOP1
CLR C
MOV A,#0FFH
MOV R0,#0
LOOP2: RRC A
MOV P1,A
ACALLDelay
INC R0
CJNE R0,#0BH,LOOP2
SETB C
MOV R0,#0
MOV A,#03FH
LOOP3: RRC A
MOV P1,A
INC R0
CJNE R0,#07H,LOOP3
SJMP START1
Delay: MOV R5,#2 ;延时
Delay1: MOV R6,#0
Delay2: MOV R7,#0
DJNZ R7,$
DJNZ R6,Delay2
DJNZ R5,Delay1
RET
END
页:
[1]