mình dang làm mạch chạy số ngẩu nhiên 6 số,có 1 số đặt trc.mình đả làm xong nhwng chưa chạy,anh em nào có hứng thú thì test dùm ha cảm ơn.
org 000h
mov p2,#00h;tat tat ca led
mov p1,0FFh ;dat port 1 len cao
sjmp main
main:
mov 40h,#04h
mov 41h,#0ffh
lap:
inc 40h ; t ao so ngau nhien
dec 41h
jnb p1.7,xuat
mov a,40h
cjne a,#255,main
sjmp lap
xuat:
mov a,p1 ; so cai truoc ,xuat so don vi
anl a,0FH ;lay 4 bit thap
mov b,#10
div ab
mov a,b
lcall chuyenma
mov p2,01h
lcall delay
mov a,40h ; xuat so hang chuc
mov b,#10
div ab
mov 42h,a
mov a,b
lcall chuyenma
mov p2,02h
lcall delay
mov a,40h ; xuat so hang tram
mov b,#10
div ab
mov a,b
lcall chuyenma
mov p2,100b
lcall delay
mov a,41h ; xuat so hang ngan
mov b,#10
div ab
mov 42h,a
mov a,b
lcall chuyenma
mov p2,1000b
lcall delay
mov a,41h ;xuat so hang chuc ngan
mov b,#10
div ab
lcall chuyenma
mov p2,10000b
lcall delay
mov a,b;xuat so hang tram ngan
lcall chuyenma
mov p2,100000b
lcall delay
jb p1.7,main
sjmp xuat
chuyenma :
mov dptr,#led7
movc a,@a+dptr
mov p0,a
ret
delay:
push 07
push 06
mov r6,#100
delay1:
mov r7,#255
djnz r7,$
djnz r6,delay1
pop 06
pop 07
ret
led7: DB 0C0h,0F9h,0A4h,0B0h,99h,92h,82h,0F8h,80h,90h
end
http://www.mediafire.com/?nmjjdgtm2c0
đay là link sơ đồ nguyên lý,hình để trong file word.diẻn đàn mình sao em upload ko dc.
org 000h
mov p2,#00h;tat tat ca led
mov p1,0FFh ;dat port 1 len cao
sjmp main
main:
mov 40h,#04h
mov 41h,#0ffh
lap:
inc 40h ; t ao so ngau nhien
dec 41h
jnb p1.7,xuat
mov a,40h
cjne a,#255,main
sjmp lap
xuat:
mov a,p1 ; so cai truoc ,xuat so don vi
anl a,0FH ;lay 4 bit thap
mov b,#10
div ab
mov a,b
lcall chuyenma
mov p2,01h
lcall delay
mov a,40h ; xuat so hang chuc
mov b,#10
div ab
mov 42h,a
mov a,b
lcall chuyenma
mov p2,02h
lcall delay
mov a,40h ; xuat so hang tram
mov b,#10
div ab
mov a,b
lcall chuyenma
mov p2,100b
lcall delay
mov a,41h ; xuat so hang ngan
mov b,#10
div ab
mov 42h,a
mov a,b
lcall chuyenma
mov p2,1000b
lcall delay
mov a,41h ;xuat so hang chuc ngan
mov b,#10
div ab
lcall chuyenma
mov p2,10000b
lcall delay
mov a,b;xuat so hang tram ngan
lcall chuyenma
mov p2,100000b
lcall delay
jb p1.7,main
sjmp xuat
chuyenma :
mov dptr,#led7
movc a,@a+dptr
mov p0,a
ret
delay:
push 07
push 06
mov r6,#100
delay1:
mov r7,#255
djnz r7,$
djnz r6,delay1
pop 06
pop 07
ret
led7: DB 0C0h,0F9h,0A4h,0B0h,99h,92h,82h,0F8h,80h,90h
end
http://www.mediafire.com/?nmjjdgtm2c0
đay là link sơ đồ nguyên lý,hình để trong file word.diẻn đàn mình sao em upload ko dc.