Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 77 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
77
Dung lượng
27,73 KB
Nội dung
TRƯỜNG CAO ĐẲNG KỸ THUẬT LÝ TỰ TRỌNG KHOA ĐIỆN – ĐIỆN TỬ - PHẦN CODE ;code19/12/2013 ;code cho hao quang ;************* SI BIT P1.0 RCK BIT P1.1 SCK BIT P1.2 VAN BIT P3.3 BITDICH BIT 20H.0 BITTAM BIT 20H.1 BITXOAd BIT 20H.2 BITXOAt BIT 20H.3 BITDON BIT 20H.4 BITLENXUONG BIT 20H.5 BITDICHTRAI BIT 20H.6 BITDICHPHAI BIT 20H.7 BITDICHLEN BIT 21H.0 BITDICHXUONG BIT 21H.1 ;*************************** DICHBIT EQU 08H TAM EQU 10H GIATRI_TOCDO EQU 11H ;*************************** HANGTREN EQU P2 HANGDUOI EQU P0 ;**************************** TOC_DO EQU R2 SOLANCHAY EQU R4 MODECHAY EQU R5 ;bien xoa mang hinh dau= R6 ;**************************** ;16byte ram tu 30H > 40H =MAHANG ;32byte ram tu 41H > 61H =XUATHANGDUOI ;32byte ram tu 61H > 81H =XUATHANTREN ;**************************** RAM1DAU DATA 41H RAM2DAU DATA 61H RAM1CUOI DATA 61H RAM2CUOI DATA 81H RAMTAM1DAU DATA 82H ;32BYTE tu 82H den 0a2H RAMTAM2DAU DATA 0A3H ;32BYTE tu 0A3H den 0C4H RAMTAM1CUOI DATA 0A2H RAMTAM2CUOI DATA 0C3H ;SP = 0C5H ;**************************** ORG 0000H LJMP MAIN ORG 000BH ;Dia chi vector bo dinh thoi LJMP T0ISR ; ORG 001BH ;Dia chi vector bo dinh thoi ; LJMP T1ISR MAIN: ;************************** MOV TMOD,#11H ;Ca bo dinh thoi che MOV IE,#80H MOV SP,#0C5H;90H MOV R7,#20 ; CLR VAN SETB TF0 ;Buoc ngat bo time SETB ET0 ;Cho phep ngat bo dinh thoi ;************* LCALL LODE_MAHANG ;************ SETB BITDICHTRAI ;=1 CHAY, =0 BO QUA SETB BITDICHPHAI SETB BITDICHLEN ; SETB BITDICHXUONG CHUONGTRINH1: ;**************** MOV MODECHAY,#1 LCALL TIMMA_DPTR CLR BITDICH clr bitlenxuong ;************************** DICH_LEN_C1: clr bitxoad clr bitxoat mov r6,#0 clr bitdon MOV SOLANCHAY,#18 MOV TOC_DO,#4 MOV R3,#8 LCALL LOADRAM_TAM TIEP_C1: ;((((((( LCALL LOADRAM_HIENTHI ;((((((( DJNZ TOC_DO,TIEP_C1 MOV TOC_DO,#4 JB BITDICH,D8_16_C1 jb bitlenxuong,xuong_C1 LCALL DICH_RAM_LEN1_8 ljmp _0xC1 xuong_C1:LCALL DICH_RAM_XUONG8_16 _0xC1: jb bitxoat,nor6 inc r6 ;lay ma xoa nor6: DJNZ R3,THOAT_C1 MOV R3,#8 setb bitxoad SETB BITDICH ;((((((( THOAT_C1:LJMP TIEP_C1 D8_16_C1:jb bitlenxuong,xuong1_C1 LCALL DICH_RAM_LEN8_16 ljmp _0xC2 xuong1_C1:LCALL DICH_RAM_XUONG1_8 _0xC2: jb bitxoat,nor6_1 inc r6 nor6_1: DJNZ R3,EXIT_C1_1 MOV R3,#8 CLR BITDICH ;dich len 1bit setb bitxoat DEC SOLANCHAY CJNE SOLANCHAY,#16,EXIT_C1 cpl bitlenxuong setb bitdon mov r6,#0 jmp EXIT_C1_1 EXIT_C1: jnb bitdon,nor6_2 inc r6 nor6_2: CJNE SOLANCHAY,#0,EXIT_C1_1 INC MODECHAY EX_01: ; POP 05H LJMP CHUONGTRINH2;&&&&&&&& EXIT_C1_1:LJMP TIEP_C1 ;************************************************** CHUONGTRINH2: ;**************** LCALL TIMMA_DPTR JNB BITDICHLEN,EX_02 CLR BITDICH clr bitlenxuong ;************************** DICH_LEN_C2: clr bitxoad clr bitxoat mov r6,#0 clr bitdon MOV SOLANCHAY,#10 MOV TOC_DO,#6;GIATRI_TOCDO;#6 MOV R3,#8 LCALL LOADRAM_TAM TIEP_C2: ;((((((( LCALL LOADRAM_HIENTHI ;((((((( DJNZ TOC_DO,TIEP_C2 MOV TOC_DO,#6;GIATRI_TOCDO;#6#6 JB BITDICH,D8_16_C2 jb bitlenxuong,xuong_C2 LCALL DICH_RAM_LEN1_8 ;dich len 1bit ljmp _0x2C2 xuong_C2:LCALL DICH_RAM_XUONG8_16 _0x2C2: inc r6 DJNZ R3,THOAT_C2 MOV R3,#8 setb bitxoad ;lay ma xoa SETB BITDICH ;((((((( THOAT_C2:LJMP TIEP_C2 D8_16_C2:jb bitlenxuong,xuong1_C2 LCALL DICH_RAM_LEN8_16 ljmp _0x3C2 xuong1_C2:LCALL DICH_RAM_XUONG1_8 _0x3C2: inc r6 DJNZ R3,EXIT_C2 MOV R3,#8 CLR BITDICH setb bitxoat DEC SOLANCHAY CJNE SOLANCHAY,#5,EXIT_C2 cpl bitlenxuong EXIT_C2: CJNE SOLANCHAY,#0,EXIT_C2_1 LJMP CHUONGTRINH3 EX_02: LCALL LOADRAM_TAM LJMP CHUONGTRINH3;&&&&&&&& EXIT_C2_1:LJMP TIEP_C2 ;************************************************** CHUONGTRINH3:;dich sang trai JNB BITDICHTRAI,EX_03 ;******** mov r6,#0 MOV SOLANCHAY,#100 MOV TOC_DO,#6 ; LCALL LOADRAM_TAM TIEP_C3: ;((((((( LCALL LOADRAM_HIENTHI ;((((((( DJNZ TOC_DO,TIEP_C3 MOV TOC_DO,#6 LCALL DICHRAMQUATRAI DEC SOLANCHAY CJNE SOLANCHAY,#0,EXIT_C3 EX_03: LJMP CHUONGTRINH4;&&&&&&&& EXIT_C3: LJMP TIEP_C3 ;$$$$$$$$$$$$$$$$$$$ CHUONGTRINH4:;dich sang phai JNB BITDICHPHAI,EX1_04 ;*********** mov r6,#0 MOV SOLANCHAY,#100 MOV TOC_DO,#6 ;*** ; LCALL LOADRAM_TAM db 000h,0BFh db 0FFh,040h db 000h,0BFh db 0FFh,040h db 000h,0BFh ; HINHAMDUONG:;18 xoay vòng db 000h,000h db 0FFh,0FEh db 0FFh,0FCh db 0FFh,0F8h db 0FFh,0F0h db 0FFh,0E0h db 0FFh,0C0h db 0FFh,080h db 0FFh,000h db 0FEh,000h db 0FCh,000h db 0F8h,000h db 0F0h,000h db 0E0h,000h db 0C0h,000h db 080h,000h db 000h,000h db 0FFh,0FEh db 0FFh,0FCh db 0FFh,0F8h db 0FFh,0F0h db 0FFh,0E0h db 0FFh,0C0h db 0FFh,080h db 0FFh,000h db 0FEh,000h db 0FCh,000h db 0F8h,000h db 0F0h,000h db 0E0h,000h db 0C0h,000h db 080h,000h ; HOABONCANH:;19 db 0FCh,000h db 010h,003h db 008h,00Ch db 013h,030h db 000h,0C0h db 013h,030h db 008h,00Ch db 010h,003h db 0C0h,000h db 010h,003h db 008h,00Ch db 013h,030h db 000h,0C0h db 013h,030h db 008h,00Ch db 010h,003h db 0C0h,000h db 010h,003h db 008h,00Ch db 013h,030h db 000h,0C0h db 013h,030h db 008h,00Ch db 010h,003h db 0C0h,000h db 010h,003h db 008h,00Ch db 013h,030h db 000h,0C0h db 013h,030h db 008h,00Ch db 0D0h,003h ; BATIAVONGCUNG:;xoay vong;20 db 0A0h,000h db 05Fh,0F9h db 0BFh,0F3h db 05Fh,0E7h db 0BFh,0CFh db 05Fh,09Fh db 0BFh,03Fh db 05Eh,07Fh db 0BCh,0FFh db 059h,0FFh db 0B3h,0FFh db 040h,000h db 0BFh,0F9h db 05Fh,0F3h db 0BFh,0E7h db 05Fh,0CFh db 0BFh,09Fh db 05Fh,03Fh db 0BEh,07Fh db 05Ch,0FFh db 0B9h,0FFh db 053h,0FFh db 0A0h,000h db 05Fh,0F9h db 0BFh,0F3h db 05Fh,0E7h db 0BFh,0CFh db 05Fh,09Fh db 0BFh,03Fh db 05Eh,07Fh db 0BCh,0FFh db 059h,0FFh ; BONCANHTIA5NHANH:;xoay vong;21 db 080h,000h db 040h,003h db 0A0h,00Fh db 05Fh,0FFh db 0BFh,0FFh db 05Fh,0FFh db 0A0h,00Fh db 040h,003h db 080h,000h db 040h,003h db 0A0h,00Fh db 05Fh,0FFh db 0BFh,0FFh db 05Fh,0FFh db 0A0h,00Fh db 040h,003h db 080h,000h db 040h,003h db 0A0h,00Fh db 05Fh,0FFh db 0BFh,0FFh db 05Fh,0FFh db 0A0h,00Fh db 040h,003h db 080h,000h db 040h,003h db 0A0h,00Fh db 05Fh,0FFh db 0BFh,0FFh db 05Fh,0FFh db 0A0h,00Fh db 040h,003h ; BATPHONG:;22 db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h db 0A2h,080h db 043h,081h db 0A2h,083h db 040h,007h ; HAIVONG8TIA:; 24 MA12TIA: ;25 BANHXE6: ;26 db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh db 000h,000h db 0FDh,0FEh db 07Bh,0FEh db 0FDh,0FEh ; MAVONGCON: ;25 BANHXE6: ;26 db 03Eh,01Eh db 05Dh,0EEh db 03Bh,0F6h db 05Ah,066h db 039h,096h db 05Bh,0F6h db 03Dh,0EEh db 05Eh,01Eh db 03Eh,01Eh db 05Dh,0EEh db 03Bh,0F6h db 05Ah,066h db 039h,096h db 05Bh,0F6h db 03Dh,0EEh db 05Eh,01Eh db 03Eh,01Eh db 05Dh,0EEh db 03Bh,0F6h db 05Ah,066h db 039h,096h db 05Bh,0F6h db 03Dh,0EEh db 05Eh,01Eh db 03Eh,01Eh db 05Dh,0EEh db 03Bh,0F6h db 05Ah,066h db 039h,096h db 05Bh,0F6h db 03Dh,0EEh db 05Eh,01Eh ; BANHXE6: ;26 db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh db 080h,000h db 000h,000h db 0BFh,0FEh db 03Fh,0FEh ; CHAMHAI: db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h db 08Eh,038h db 071h,0C7h ; MA12VONG: db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh db 0BFh,0FBh db 000h,000h db 0BFh,0FBh END [...]... LOADRAMTAM_DUOI ;ram tam RET ;******************************* LOADRAM_HIENTHI: LCALL LOADRAMDUOI ;load data tu ram tam vao LCALL LOADRAMTREN LCALL QUET8HANG1_8 LCALL QUET8HANG8_16 RET ;******************************* DICHRAMQUATRAI: LCALL DICHRAM_TRAI_DUOI LCALL DICHRAM_TRAI_TREN RET ;******************************* DICHRAMQUAPHAI: ;ram hien thi LCALL DICHRAM_PHAI_TREN LCALL DICHRAM_PHAI_DUOI RET ;*******************************... 01H MOV R1,#RAMTAM1DAU MOV R0,#RAMTAM1DAU ;ram hien thi MOV A,@R0 MOV TAM,A LDICHPD: INC R0 MOV A,@R0 MOV @R1,A INC R1 CJNE R1,#RAMTAM1CUOI,LDICHPD DEC R1 MOV @R1,TAM POP 01H POP 00H RET ;******************************* DICHRAM_PHAI_TREN: PUSH 00H PUSH 01H MOV R1,#RAMTAM2DAU MOV R0,#RAMTAM2DAU MOV A,@R0 MOV TAM,A LDICHPT: INC R0 MOV A,@R0 ;ram hien thi MOV @R1,A INC R1 CJNE R1,#RAMTAM2CUOI,LDICHPT DEC... MOV R1,#RAMTAM1CUOI MOV R0,#RAMTAM1CUOI;RAMTAM1DAU ;ram hien thi dec r0 dec r1 MOV A,@R0 MOV TAM,A LDICHTD: DEC R0 MOV A,@R0 MOV @R1,A DEC R1 CJNE R1,#RAMTAM1DAU,LDICHTD MOV @R1,TAM POP 01H POP 00H RET ;******************************* DICHRAM_TRAI_TREN: PUSH 00H PUSH 01H MOV R1,#RAMTAM2CUOI;RAMTAM2DAU MOV R0,#RAMTAM2CUOI;RAMTAM2DAU ;ram hien thi dec r0 dec r1 MOV A,@R0 MOV TAM,A LDICHTT: DEC R0 MOV A,@R0... MOV R1,#38H ;chon hang LAPHANG1: MOV R0,#RAM2DAU CLR RCK LAPCOT1:CLR SCK MOV A,@R0 SETB C RLC A MOV @R0,A SETB SCK MOV SI,C INC R0 CJNE R0,#81H,LAPCOT1 LCALL XUNGSAU SETB RCK LCALL XUATTREN; LCALL DELAYLED MOV HANGTREN,#0FFH INC R1 CJNE R1,#40H,LAPHANG1 POP 01H POP 00H RET ;******************************************* ;******************** XUATDUOI: MOV A,@R1 MOV HANGDUOI,A RET ;***********************... 00H RET ;******************************* ;******************************* ;******************************* ;*******************************; LOADRAMDUOI:;(RAM1);sao chep tu ram tam sang ram duoi de hien thi PUSH 00H PUSH 01H ; mov r6,#0 MOV R0,#RAMTAM1DAU MOV R1,#RAM1DAU LRAM1:CLR A MOV A,@R0 jb bitxoad,k_xd mov dptr,#maxoa push acc mov a,r6 movc a,@a+dptr mov tam,a pop acc orl a,tam jmp lrd k_xd:jnb... a,tam k_xd1: lrd:MOV @R1,A INC R0 INC R1 CJNE R1,#RAM1CUOI,LRAM1 ; pop 06h POP 01H POP 00H RET ;******************************************** LOADRAMTREN:;(RAM2);sao chep tu ram tam sang ram duoi de hien thi PUSH 00H PUSH 01H mov dptr,#maxoat MOV R0,#RAMTAM2DAU MOV R1,#RAM2DAU LRAM2:CLR A MOV A,@R0 jb bitxoat,k_xt push acc mov a,r6 movc a,@a+dptr mov tam,a pop acc orl a,tam jmp lrt k_xt:jnb bitdon,k_xt1...TIEP_C4: ;((((((( LCALL LOADRAM_HIENTHI ;((((((( DJNZ TOC_DO,TIEP_C4 MOV TOC_DO,#6 LCALL DICHRAMQUAPHAI DEC SOLANCHAY CJNE SOLANCHAY,#0,EXIT_C4 EX1_04: INC MODECHAY CJNE MODECHAY,#29,EX_04 LJMP CHUONGTRINH1 EX_04: LJMP CHUONGTRINH2 ;&&&&&&&&... LAPHANG: MOV R0,#RAM1DAU CLR RCK LAPCOT: CLR SCK MOV A,@R0 SETB C RLC A MOV @R0,A SETB SCK MOV SI,C INC R0 CJNE R0,#RAM1CUOI,LAPCOT LCALL XUNGSAU SETB RCK LCALL XUATDUOI; MOV CHONHANG,R7;Sang hang LCALL DELAYLED MOV HANGDUOI,#0FFH INC R1 CJNE R1,#38H,LAPHANG POP 01H POP 00H RET ;******************************************* ;******************************************* QUET8HANG8_16:MOV HANGDUOI,#0FFH PUSH 00H... R0,#RAMTAM2CUOI;RAMTAM2DAU ;ram hien thi dec r0 dec r1 MOV A,@R0 MOV TAM,A LDICHTT: DEC R0 MOV A,@R0 MOV @R1,A DEC R1 CJNE R1,#RAMTAM2DAU,LDICHTT MOV @R1,TAM POP 01H POP 00H RET ;*******************************TIM MA CHAY HAO QUANG* *********** ;******************************* TIMMA_DPTR: CJNE MODECHAY,#1,M_KH MOV DPTR,#HINH_CARO MOV GIATRI_TOCDO,#4 RET M_KH:CJNE MODECHAY,#2,M_KH1 MOV DPTR,#BAUTROISAO ;MOV GIATRI_TOCDO,#6 CLR