Mình làm chạy chữ "Khoa điện" bằng code này nhưng chỉ chạy được mỗi chữ "K" và "H" rùi nó lại lặp lại. Mình ko tìm đc lỗi sai mong mọi người chỉ giúp nha mình đang cần gấp.....Thanks (mình dùng IC 89C51)
$ include(reg51.inc)
hang equ p2
cot equ p0
main:
mov DPTR,#Dulieu ;chuyen du lieu vao DPTR
main1: mov r2,#150 ;lap so lan
main2: mov r1,#00h
mov r3,#00000001b ;ma quet hang dau tien cua chu
main3: mov a,r1 ;chuyen r1 vao thanh ghi a
movc a,@a+dptr ;lay du lieu tu dptr vao thanh ghi a
mov hang,a ;gui byte dau tien cua ky tu gui a ra hang
mov cot,r3 ;chuyen r3 ra cot
call delay ;goi chuong trinh tao tre
mov cot,#00h ;xoa cot
inc r1 ;lenh them 1 gia tri
mov a,r3 ;chuyen r3 vao thanh ghi a
rl a ;quay trai khong nho cua a
mov r3,a ;chuyen thanh ghi a vafo r3
cjne r1,#8,main3
djnz r2,main2
inc dptr
mov a,dpl
cjne a,#56,main1
jmp main ;lap lai
delay: ;chuong trinh con tao tre
mov r4,#1
lap: mov r5,#200
djnz r5,$
djnz r4,lap
ret ;thoat khoi chuong trinh con tao tre
Dulieu: ; hien thi "khoa dien"
DB 1H,0EFH,0D7H,0BBH,7DH,0FFH,0FFH,0FFH;K
DB 1H,0EFH,0EFH,0EFH,1H,0FFH,0FFH,0FFH ;H
DB 83H,7DH,7DH,7DH,83H,0FFH,0FFH,0FFH;O
DB 7H,0EBH,0EDH,0EBH,7H,0FFH,0FFH,0FFH;A
DB 0EFH,1H,6DH,7DH,83H,0FFH,0FFH,0FFH;D
DB 7DH,7DH,1H,7DH,7DH,0FFH,0FFH,0FFH;I
DB 1H,6DH,6DH,6DH,7DH,0FFH,0FFH,0FFH;E
DB 1H,0FBH,0F7H,0EFH,1H,0FFH,0FFH,0FFH;N
End
$ include(reg51.inc)
hang equ p2
cot equ p0
main:
mov DPTR,#Dulieu ;chuyen du lieu vao DPTR
main1: mov r2,#150 ;lap so lan
main2: mov r1,#00h
mov r3,#00000001b ;ma quet hang dau tien cua chu
main3: mov a,r1 ;chuyen r1 vao thanh ghi a
movc a,@a+dptr ;lay du lieu tu dptr vao thanh ghi a
mov hang,a ;gui byte dau tien cua ky tu gui a ra hang
mov cot,r3 ;chuyen r3 ra cot
call delay ;goi chuong trinh tao tre
mov cot,#00h ;xoa cot
inc r1 ;lenh them 1 gia tri
mov a,r3 ;chuyen r3 vao thanh ghi a
rl a ;quay trai khong nho cua a
mov r3,a ;chuyen thanh ghi a vafo r3
cjne r1,#8,main3
djnz r2,main2
inc dptr
mov a,dpl
cjne a,#56,main1
jmp main ;lap lai
delay: ;chuong trinh con tao tre
mov r4,#1
lap: mov r5,#200
djnz r5,$
djnz r4,lap
ret ;thoat khoi chuong trinh con tao tre
Dulieu: ; hien thi "khoa dien"
DB 1H,0EFH,0D7H,0BBH,7DH,0FFH,0FFH,0FFH;K
DB 1H,0EFH,0EFH,0EFH,1H,0FFH,0FFH,0FFH ;H
DB 83H,7DH,7DH,7DH,83H,0FFH,0FFH,0FFH;O
DB 7H,0EBH,0EDH,0EBH,7H,0FFH,0FFH,0FFH;A
DB 0EFH,1H,6DH,7DH,83H,0FFH,0FFH,0FFH;D
DB 7DH,7DH,1H,7DH,7DH,0FFH,0FFH,0FFH;I
DB 1H,6DH,6DH,6DH,7DH,0FFH,0FFH,0FFH;E
DB 1H,0FBH,0F7H,0EFH,1H,0FFH,0FFH,0FFH;N
End