EM đang làm một cái đồ án về VDK, nhưng chuyên ngành của em là cơ khí nên VDK học rồi mà vẫn mù tịt, qua nhà đứa bạn nó cho em cái mạch và chuờng trình ntn, em đọc mãi mà vẫn không hiểu gì cả, mong các anh giải thích từng dòng lệnh cho em đc không a, em cảm ơn rất nhiều
Mach nay hoạt động : Đếm giờ phút, giây, Có hẹn giờ, báo thức
Mach nay hoạt động : Đếm giờ phút, giây, Có hẹn giờ, báo thức
PHP Code:
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
; p2 dieu khien 8 led va p3.0, p3.1, p3.2, p3.4, p3.5
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
dwn bit p3.3
up bit p3.4
mode bit p3.5
mode1 bit p3.1
bell bit p3.0
bien_mode equ r2
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
org 000h
jmp main
org 003h
jmp ngat_n0
main: mov bien_mode,#0
lcall khoitaodallass
mov ie,#81h
setb it0
setb bell
tu_dau: lcall doc_data
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi
jb mode,adj
jb mode1,adj_alr
sjmp tu_dau
adj_alr: jmp set_alr
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
adj: lcall hien_thi
jb mode,adj
inc bien_mode
cjne bien_mode,#04,loop
mov bien_mode,#0
ljmp tu_dau
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
loop: mov 67h,#10
loop3: mov 66h,#0afh
loop1: lcall doc_data
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi
jb up,tang
jb dwn,giam
jb mode,adj
djnz 66h,loop1
cjne bien_mode,#1,tatphut
mov 34h,#0ffh
mov 35h,#0ffh
sjmp tat
tatphut: cjne bien_mode,#02,tatgio
mov 32h,#0ffh
mov 33h,#0ffh
sjmp tat
tatgio: mov 30h,#0ffh
mov 31h,#0ffh
tat: mov 66h,#0afh
loop2: lcall hien_thi
jb up,tang
jb dwn,giam
jb mode,adj2
djnz 66h,loop2
djnz 67h,loop3
mov bien_mode,#0
ljmp tu_dau
adj2: ljmp adj
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tang: mov 78h,#200
tang1: lcall hien_thi
djnz 78h,tang1
cjne bien_mode,#01h,ss1
mov r0,#04h
movx a,@r0
inc a
cjne a,#24,z1
mov a,#0
z1: movx @r0,a
jmp loop
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ss1: cjne bien_mode,#02h,ss2
mov r0,#02h
movx a,@r0
inc a
cjne a,#60,z1
mov a,#0
jmp z1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ss2: mov r0,#0h
movx a,@r0
inc a
cjne a,#060,z1
mov a,#0
jmp z1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
giam: mov 78h,#200
giam11: lcall hien_thi
djnz 78h,giam11
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
cjne bien_mode,#01h,sss1
mov r0,#04
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#23
zz1: movx @r0,a
jmp loop
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sss1: cjne bien_mode,#02h,sss2
mov r0,#02h
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#59
jmp zz1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sss2: mov r0,#0h
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#59
jmp zz1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
; doan ct cai dat bao thuc
set_alr: lcall hien_thi_alr
jb mode1,set_alr
jb bell,set_a
setb bell
mov r0,#0ch
movx a,@r0
jmp tu_dau
set_a: inc bien_mode
cjne bien_mode,#4,wait
mov bien_mode,#0
ljmp tu_dau
wait: mov 67h,#10
wait3: mov 66h,#0ffh
lcall doc_data_alr
lcall hex_bcd
lcall bcd_7doan
wait1: lcall hien_thi_alr
jb up,tang_alr
jb dwn,giam_alr
jb mode1,set_alr
djnz 66h,wait1
cjne bien_mode,#1,tatphut_alr
mov 35h,#0ffh
mov 34h,#0ffh
sjmp tat_alr
tatphut_alr: cjne bien_mode,#2,tatgiay_alr
mov 32h,#0ffh
mov 33h,#0ffh
sjmp tat_alr
tatgiay_alr: mov 31h,#0ffh
mov 30h,#0ffh
tat_alr: mov 66h,#0ffh
wait2: lcall hien_thi_alr
jb up,tang_alr
jb dwn,giam_alr
jb mode1,set_alr
djnz 66h,wait2
djnz 67h,wait3
mov bien_mode,#0
ljmp tu_dau
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tang_alr: mov 78h,#200
tang1_alr: lcall hien_thi_alr
djnz 78h,tang1_alr
waitx3: cjne bien_mode,#01h,ss_alr1
mov r0,#05h
movx a,@r0
inc a
cjne a,#24,z_alr1
mov a,#0
z_alr1: movx @r0,a
jmp wait
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ss_alr1: cjne bien_mode,#2,ss_alr2
mov r0,#03h
movx a,@r0
inc a
cjne a,#60,z_alr1
mov a,#0
jmp z_alr1
ss_alr2: mov r0,#01h
movx a,@r0
inc a
cjne a,#60,z_alr1
mov a,#0
jmp z_alr1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
giam_alr: mov 78h,#200
giam_alr11: lcall hien_thi_alr
djnz 78h,giam_alr11
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
waity3: cjne bien_mode,#01h,sss_alr1
mov r0,#5
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#24
zz_alr1: movx @r0,a
jmp wait
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sss_alr1: cjne bien_mode,#2,sss_alr2
mov r0,#03h
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#59
jmp zz_alr1
sss_alr2: mov r0,#01h
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#59
jmp zz_alr1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
khoitaodallass: mov r0,#0bh
mov a,#026h
movx @r0,a ;cho phep chinh cai dat gio
mov r0,#0ah
mov a,#020h
movx @r0,a ;cho phep bo dao dong chay
mov r0,#0ch
movx a,@r0
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
doc_data: mov r0,#0
mov r1,#10h
x1: movx a,@r0
mov @r1,a
inc r0
inc r0
inc r1
cjne r0,#06h,x1
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
doc_data_alr: mov r0,#01h
movx a,@r0
mov 10h,a
mov r0,#03h
movx a,@r0
mov 11h,a
mov r0,#05h
movx a,@r0
mov 12h,a
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hex_bcd: mov r0,#10h
mov r1,#20h
hb: mov a,@r0
mov b,#10
div ab
mov @r1,b
inc r1
mov @r1,a
inc r0
inc r1
cjne r0,#13h,hb
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
bcd_7doan: mov dptr,#900h
mov r0,#20h
mov r1,#30h ;chua cac ma data
x3: mov a,@r0 ;lay giay
movc a,@a+dptr
mov @r1,a
inc r0
inc r1
cjne r0,#26h,x3
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hien_thi: mov r0,#30h
mov a,#0feh
ht: mov p1,@r0
mov p2,a
lcall delay
mov p2,#0ffh
inc r0
rl a
cjne a,#0bfh,ht
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hien_thi_alr: mov r0,#30h
mov a,#0feh
ht11: mov p1,@r0
mov p2,a
lcall delay
mov p2,#0ffh
inc r0
rl a
cjne a,#0bfh,ht11
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ngat_n0: clr bell
reti
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
delay: mov 7fh,#100
djnz 7fh,$
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
org 900h
db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h
end
Comment