发布网友 发布时间:2022-04-23 10:01
共2个回答
热心网友 时间:2023-07-11 04:06
ORG 0000H
LJMP MAIN
ORG 000BH
T0MS EQU NOT 50000 ; 50 mS 晶振 12.000 MHz
PJSBZ EQU 20H
PJSBZY EQU 21H
PST0: MOV TL0, #LOW T0MS ; T0 中断
MOV TH0, #HIGH T0MS
SETB PJSBZ ; 50 mS 标志
DJNZ R6, PST02
MOV R6, #40 ; 50 mS * 40 = 2 S
SETB PJSBZY ; 2 S 标志
PST02: RETI
MAIN: MOV TMOD, #01H
MOV IE, #82H ; 开 T0 中断
MOV SP, #30H
MOV TL0, #LOW T0MS ; TO 50MS 中断 计时 0
MOV TH0, #HIGH T0MS
SETB TR0
MOV R6, #40 ; 计时初值
MAIN1: MOV A, #7FH
MAIN2: JNB PJSBZ, $ ; 50 mS
CLR PJSBZ
RR A ; 右移
MOV P1, A
JNB PJSBZY, MAIN2 ; 2 S
CLR PJSBZY
MAIN3: JNB PJSBZ, $ ; 50 mS
CLR PJSBZ
RL A ; 左移
MOV P1, A
JNB PJSBZY, MAIN3 ; 2 S
CLR PJSBZY
AJMP MAIN1
END
热心网友 时间:2023-07-11 04:07
ORG 0000H
LJMP MM
ORG 0030H
MM:MOV P1,#01H
MOV A,P1
CJNE A,#01H,BL
D1:RL A
MOV P1,A
LCALL DEL
BL: CJNE A,#80H,D1
D2:RR A
MOV P1, A
LCALL DEL
CJNE A ,#01H,D2
LJMP MM
DEL:MOV R1,#10
ZQ:MOV R2,#100
ZH:MOV R3,#100
ZG:DJNZ R3,ZG
DJNZ R2,ZH
DJNZ R1,ZQ
RET