DELAY_REG EQU 0x20
LINE_NUM EQU 0x21 ;行號(hào)
BYTE_NUM EQU 0x22 ;字節(jié)號(hào)
WORD_NUM EQU 0x23 ;字號(hào)
;字號(hào)X32 + 行號(hào)X2 + 字節(jié)號(hào) 得查表偏移量。
BYTE_BIT_COUNT EQU 0x24 ;一個(gè)字節(jié)的位數(shù),移位時(shí)用
SER EQU 0x07
SCK EQU 0x00
RCK EQU 0x01
;**********************************************************************
ORG 0x000 ; processor reset vector
nop ; nop required for icd
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
retfie ; return from interrupt
main
; remaining code goes here
BSF STATUS,RP0
CLRF TRISB
CLRF TRISC
CLRF TRISD
BCF STATUS,RP0
CLRF PORTB
CLRF PORTC
CLRF PORTD
CLRF LINE_NUM
MAIN_LOOP:
CALL LOAD_A_LINE ;加載一行
MOVF LINE_NUM,W ;行選
MOVWF PORTC
BSF PORTB,RCK ;將一行數(shù)據(jù)送入鎖存器
NOP
NOP
BCF PORTB,RCK
CALL DELAY ;延時(shí)
INCF LINE_NUM ;下一行
BCF LINE_NUM,4 ;一共16行,模16
GOTO MAIN_LOOP
;加載一行
LOAD_A_LINE:
CLRF WORD_NUM ;字號(hào)清零
LOAD_A_WORD:
CLRF BYTE_NUM ;字節(jié)號(hào)清零
LOAD_A_BYTE:
BCF STATUS,C ;清除C標(biāo)志位,為移位乘2做準(zhǔn)備
RLF LINE_NUM,W ;每個(gè)字一行占兩個(gè)字節(jié),所以乘2
ADDWF WORD_NUM,W ;下面WORD_NUM每次加32,不用再乘
ADDWF BYTE_NUM,W ;行號(hào)X2 + 字號(hào)X32 + 字節(jié)號(hào)
CALL ENCODE ;查表,取出對(duì)應(yīng)的字節(jié)
MOVWF PORTD
MOVLW D'8'
MOVWF BYTE_BIT_COUNT ;一個(gè)字節(jié)有8位
LOAD_A_BIT:
BSF PORTB,SCK ;將PORTD最高位送入移位寄存器
NOP
NOP
BCF PORTB,SCK
RLF PORTD ;移位,準(zhǔn)備將下一位送入移位寄存器
DECFSZ BYTE_BIT_COUNT ;循環(huán)8次
GOTO LOAD_A_BIT
INCF BYTE_NUM
BTFSS BYTE_NUM,1 ;BYTE_NUM==2?一行有兩個(gè)字節(jié)
GOTO LOAD_A_BYTE
MOVLW D'32'
ADDWF WORD_NUM ;一個(gè)字32個(gè)字節(jié),每次加32,使用時(shí)不用再乘32
MOVF WORD_NUM,W
SUBLW D'160'
BTFSS STATUS,Z ;WORD_NUM==160?5個(gè)字160個(gè)字節(jié)
GOTO LOAD_A_WORD
RETURN
;延時(shí)
DELAY:
DECFSZ DELAY_REG
GOTO DELAY
RETURN
ENCODE:
ADDWF PCL
;黑
DT 0x3F,0xF8,0x21,0x08,0x29,0x28,0x25,0x48,0x25,0x88,0x3F,0xF8,0x01,0x00,0x01,0x00,
DT 0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x00,0x48,0x84,0x44,0x42,0x84,0x42,0x00,0x00
;龍
DT 0x02,0x00,0x02,0x40,0x02,0x20,0x02,0x20,0x7F,0xFE,0x02,0x80,0x02,0x90,0x02,0x90,
DT 0x04,0xA0,0x04,0xC0,0x08,0x80,0x09,0x80,0x12,0x82,0x20,0x82,0x40,0x7E,0x00,0x00
;江
DT 0x20,0x00,0x10,0x00,0x13,0xFC,0x00,0x40,0x88,0x40,0x48,0x40,0x50,0x40,0x10,0x40,
DT 0x10,0x40,0x20,0x40,0xE0,0x40,0x20,0x40,0x20,0x40,0x2F,0xFE,0x20,0x00,0x00,0x00
;大
DT 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x02,0x80,
DT 0x02,0x80,0x02,0x40,0x04,0x40,0x04,0x20,0x08,0x10,0x10,0x18,0x20,0x0E,0x40,0x04
;學(xué)
DT 0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0xE8,0x00,0x40,
DT 0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x02,0x80,0x01,0x00
END ; directive 'end of program'