Text

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Text as PDF for free.

More details

  • Words: 691
  • Pages: 3
;================================================================== ;chuong trinh thuc hien hien thi va chay chu tren 2 ma tran led 8x8 ;================================================================== org 000h ;khoi dau chuong trinh, doc bo nho tai dia chi ROM 000h nhan1: mov r1,#01 ;bao so bit dich nhan2: mov r0,#1 ;bao so vong lap cho mot frame hien thi, thoi gian huong toi khoang 0.7s nhan3: ;-------------------------------------------------------------------;bat dau quet hang thu nhat mov r2,#01h ;khai bao hang so 1 mov r3,#11100111b ;khai bao trang thai 1 mov r4,#0ffh ;khai bao trang thai 2 mov r5,#00111111b ;khai bao trang thai 3 lcallhienthi ;goi chuong trinh con hien thi ;xong hang 1 ;----------------------------------------------------------------------;bat dau quet hang thu hai mov r2,#02h ;khai bao hang so1 mov r3,#10001001b ;khai bao trang thai 1 mov r4,#01100100b ;khai bao trang thai 2 mov r5,#00100100b ;khai bao trang thai 3 lcallhienthi ;xong hang 2 ;----------------------------------------------------------------------;bat dau quet hang thu ba mov r2,#03h ;khai bao hang so1 mov r3,#10010001b ;khai bao trang thai 1 mov r4,#11111100b ;khai bao trang thai 2 mov r5,#00100111b ;khai bao trang thai 3 lcallhienthi ;goi chuong trinh con hien thi ;xong hang 3 ;----------------------------------------------------------------------;bat dau quet hang thu tu mov r2,#04h ;khai bao hang so1 mov r3,#10001001b ;khai bao trang thai 1 mov r4,#00100000b ;khai bao trang thai 2 mov r5,#00111111b ;khai bao trang thai 3 lcallhienthi ;goi chuong trinh con hien thi ;xong hang 4 ;----------------------------------------------------------------------;bat dau quet hang thu nam mov r2,#05h ;khai bao hang so1 mov r3,#10000111b ;khai bao trang thai 1 mov r4,#11111100b ;khai bao trang thai 2 mov r5,#00111111b ;khai bao trang thai 3 lcallhienthi ;goi chuong trinh con hien thi ;xong hang 5 ;----------------------------------------------------------------------inc r0 ;tang bien tao so frame/s cjne r0,#40,nhan3 ;se lap 25frame inc r1 ;neu r0 da du bang 25 thi tang noi dung thanh ghi dia chi 08h, chua so bit can dich len 1 mov A,r1 cjne A,#24,nhan2 ;neu khong bang thi tiep tuc set lai r1 jmp nhan1

;======================================================================= ;chuong trinh con "hien thi" ;======================================================================= hienthi: mov 09h,#0 ;dat bien so cho bit dich xuat phat tu 0 mov A,09h ;lay thanh ghi accumulator lam trung gian nhan4: inc A ;tang A them 1 mov 09h,A ;tuong duong voi tang noi dung thanh ghi co dia chi 09h them 1 cjne A,01h,nhan5 ;so sanh A(luc nay chua bien so ve so bit dich can thiet voi so bit can dich chuan luu trong 08h) jmp nhan6 nhan5:

lcall dich1bit jmp nhan4 nhan6: lcall quet1hang

;goi ctc dich mot bit

;goi ctc quet mot hang, co tac dung hien thi

RET ;ket thuc ctc ;===========================================================================

;============================================================================ ;ctc dich di mot bit du lieu chua trong 3 thanh ghi ;=========================================================================== dich1bit: mov 31h,A push 31h mov A,r5 ;luu r5 sang thanh ghi A de thuc hien lenh quay rlc A ;xoay bit, luc nay co C chua bit A.7, hay bit 7 cua thanh ghi R5 mov 20h,A ;luu len 20h de cho xu li bit mov A,r4 ;luu r6 sang A de thuc hien quay rlc A ;xoay bit, hoan hao, luc nay C chua R6.7 mov r4,A ;luu lai vao r6 mov A,r3 ;luu R7 sang A rlc A ;xoay bit,hoan hao, luc nay C chua R7.7 mov r3,A ;luu lai vao r7 mov 00h,c ;dua bit R7.7 vao bit 0 cua 20h mov r5,20h ;hoan thanh xoay mot bit pop 31h mov A,31h RET ;hoan thanh chuong trinh con ;=============================================================================

;============================================================================= ;chuong trrinh con hien thi "quet1hang" ;============================================================================= ;============================================================= ;chuong trinh con quet mot hang voi du lieu gui tren R2, R3, R4 ;============================================================= quet1hang: mov p1,r2 ;mo hang setb p1.3 ;mo IC1 mov p3,r3 ;mo trang thai 1 lcall tre_1_mgiay ;goi ham tre mov p3,#00h ;tat trang thai clr p1.3 ;tat IC1 lcall tre_1_mgiay ;goi ham tre setb p1.4 ;mo IC2 mov p3,r4 ;mo trang thai 2 lcall tre_1_mgiay ;goi ham tre mov p3,#00h ;tat trang thai clr p1.4 ;tat IC2 lcall tre_1_mgiay ;goi ham tre RET ;=============================================================== ;CTC tao thoi gian tre 1ms ;================================================================== tre_1_mgiay: push 07h ;luu r7 vao stack mov r7,#250 ;tao 250 vong lap loop1milli: nop ;tre 1CK may nop djnz r7,loop1milli ;lenh co thoi gian 2ck may pop 07h ;lay lai r7 RET end

Related Documents

Text
October 2019 63
Text
November 2019 59
Text
May 2020 38
Text
May 2020 42
Text
October 2019 64
Text
December 2019 53