Witam
Znalazłem program na miganie diod, tylko nie rozumiem jak on działa...czy mógłby ktoś mi skomentować ten program, ponieważ nie mam zielonego pojęcia o co chodzi?
Pozdrawiam
Znalazłem program na miganie diod, tylko nie rozumiem jak on działa...czy mógłby ktoś mi skomentować ten program, ponieważ nie mam zielonego pojęcia o co chodzi?
$MOD51
ORG 0H
AJMP START
ORG 100H
START:
MOV DPTR,#DIODA1
MOV R0,#0
MOV A,R0
MOVC A,@A+DPTR
MOV R2,A
MOV DPTR,#DIODA2
MOV R1,#0
MOV A,R1
MOVC A,@A+DPTR
MOV R3,A
MOV R4,#0
MOV R5,#0
CLR P1.7
CLR P1.5
PENTLA:
ACALL DELAY
ACALL SPRAWDZ_CZAS
ACALL ZASWIEC_ZGAS
ACALL PRZESUN_INDEKS
LJMP PENTLA
AJMP START
AJMP $
DIODA1: DB 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
DIODA2: DB 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
PRZESUN_INDEKS:
CJNE R4,#1,PP1
CJNE R0,#30,S1
MOV DPTR,#DIODA1
MOV R0,#0
MOV A,R0
MOVC A,@A+DPTR
MOV R2,A
MOV R4,#0
AJMP K1
S1:
INC R0
MOV DPTR,#DIODA1
MOV A,R0
MOVC A,@A+DPTR
MOV R2,A
MOV R4,#0
K1:
PP1:
CJNE R5,#1,PP2
CJNE R1,#30,S2
MOV DPTR,#DIODA2
MOV R1,#0
MOV A,R1
MOVC A,@A+DPTR
MOV R3,A
MOV R5,#0
AJMP K2
S2:
INC R1
MOV DPTR,#DIODA2
MOV A,R1
MOVC A,@A+DPTR
MOV R3,A
MOV R5,#0
K2:
PP2:
RET
SPRAWDZ_CZAS:
DJNZ R2,SKOK1
MOV R4,#1
AJMP KONIEC1
SKOK1:
MOV R4,#0
KONIEC1:
DJNZ R3,SKOK2
MOV R5,#1
AJMP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