本帖最后由 Resbi 于 2019-8-7 16:19 编辑
完整程序:
;Goto MAIN
JMP MAIN
;Delay
DELAY: MOV A, R4
MOV R0, A
DELAY2: MOV R1, #1
LOOP2: MOV A, R1
SUBB A, #1
MOV R1, A
CJNE A, #0, LOOP2
LOOP1: MOV A, R0
SUBB A, #1
MOV R0, A
CJNE A, #0, DELAY2
RET
;Reduce
RED: MOV A, R5
SUBB A, #1
RET
;Increse
INE: MOV A, R5
ADD A, #1
RET
;ReduceOrIncrese
ROI: MOV A, R6
JMP T1
TRED: ACALL RED
JMP T2
TINE: ACALL INE
JMP T2
T1: CJNE A, #0, TRED
JMP TINE
T2: MOV R5, A
RET
;MAIN
MAIN: MOV R6, #1 ;RED/INC flag(0=INC, 1=RED)
MOV R5, #255
MOV DPTR, #0xFF00 ;P0M0 is here
MOV A, #10 ;set output mode
MOVX @DPTR, A
MLOOP: MOV P0, #00 ;P00 = 1
MOV A, R5
MOV R4, A ;Delay R5*C
ACALL DELAY
MOV P0, #01 ;P00 = 0
MOV A, #255
SUBB A, R5
MOV R4, A ;Delay (255-R5)*C
ACALL DELAY
ACALL ROI
JMP MLOOP
END
代码网页显示出来会乱。。抱歉 |