Toàn vừa viết bài asm dùng vdk 89C51 hiển thị đồng hồ:
Cacs bạn xem rồi cho ý kiến nha !
Mô phỏng bằng proteus va code asm Click here to download
Cacs bạn xem rồi cho ý kiến nha !
- Code:
ORG 00H
SJMP MAIN
;*************************************
ORG 03H
ACALL DELAY1
INC R0
CJNE R0,#24,RESTART_R0
MOV R0,#0
RESTART_R0:
RETI
;*************************************
ORG 0BH
CLR TF0
ACALL CHAY
RETI
;*************************************
ORG 13H
ACALL DELAY1
INC R1
CJNE R1,#60,RESTART_R1
MOV R1,#0
RESTART_R1:
RETI
;*************************************
ORG 30H
CHAY:
MOV TH0,#0BH
MOV TL0,#0DCH
INC R2
CJNE R2,#16,TIEP
MOV R2,#0
INC R3
CJNE R3,#60,TIEP
MOV R3,#0
INC R1
CJNE R1,#60,TIEP
MOV R1,#0
INC R0
CJNE R0,#24,TIEP
MOV R0,#0
TIEP:
RET
;*************************************
DELAY:
MOV TH1,#0F4H
MOV TL1,#48H
SETB TR1
JNB TF1,$
CLR TR1
CLR TF1
RET
;*************************************
DELAY1:
MOV R5,#255
D1: MOV R6,#255
D2: MOV R7,#1
D3: DJNZ R7,D3
DJNZ R6,D2
DJNZ R5,D1
RET
;*************************************
MAIN:
MOV R0,#0
MOV R1,#0
MOV R2,#0
MOV R3,#0
MOV R4,#0
MOV IE,#10000111B
MOV TMOD,#00010001B
MOV TH0,#0BH
MOV TL0,#0DCH
SETB TR0
QUET:
MOV A,R0
MOV B,#10
DIV AB
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P1,#11111110B
MOV P2,A
ACALL DELAY
MOV A,B
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P1,#11111101B
MOV P2,A
ACALL DELAY
MOV A,R1
MOV B,#10
DIV AB
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P1,#11111011B
MOV P2,A
ACALL DELAY
MOV A,B
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P1,#11110111B
MOV P2,A
ACALL DELAY
SJMP QUET
;********************************************************
MALED:
DB 11111100B,01100000B,11011010B,11110010B,01100110B
DB 10110110B,00111110B,11100000B,11111110B,11100110B
END
Mô phỏng bằng proteus va code asm Click here to download
Được sửa bởi huutoan_ss ngày Mon May 31, 2010 2:38 pm; sửa lần 1.