OUTBIT   equ 0e101h
CLK164   equ 0e102h  ; 段控制口(接164时钟位)
DAT164   equ 0e102h  ; 段控制口(接164数据位)
LEDBuf   equ 40h
IN       equ 0e103h
         ORG 0000H
         MOV sp,#60h
	     MOV DPTR,#0e100H     ;8155初始化
     	 MOV A,#03H
	     MOVX @DPTR,A
START:   MOV DPTR,#8000H     ;往6264的8000H-9FFFH单元送入#55H
         MOV A,#55H
DD:      MOVX @DPTR,A
        INC DPTR
        mov r0,dph
        CJNe r0,#0A0H,DD
        MOV DPTR,#8000h
DD1:    MOVX A,@DPTR     ;读出数据进行比较
        CJNE A,#55H,ERR
        INC DPTR
        MOV R0,DPH
        CJNE R0,#0A0H,DD1
        mov 40h,#06h         ;显示缓冲器初始化
	    mov 41h,#05h
	    mov 42h,#06h
	    mov 43h,#04h
        mov 44h,#10h
        mov 45h,#00h
START1: LCALL DISPLAY   ;正确的显示“6464-0”
        SJMP START1
ERR:    mov 40h,#06h
        mov 41h,#05h
	    mov 42h,#06h
	    mov 43h,#04h
        mov 44h,#10h
        mov 45h,#0Eh    ;不正确的显示“6264-E。”
START2: LCALL DISPLAY
        SJMP  START2
DISPLAY:setb 0d3h
        mov   r0, #LEDBuf
        mov   r1, #6          ; 共6个八段管
        mov   r2, #00100000b ; 从左边开始显示
Loop:
        mov   dptr, #OUTBIT
        mov   a, #00h
        movx  @dptr, a        ; 关所有八段管
        mov   a, @r0
        mov dptr,#LEDmap
        movc a,@a+dptr
        mov   B, #8           ; 送164
DLP:
        rlc   a
        mov   r3, a
        mov   acc.0, c
        anl  a,#0fdh
        mov   dptr, #DAT164
        movx  @dptr, a
        mov   dptr, #CLK164
        orl a,#02h
        movx  @dptr, a
        anl a,#0fDh
        movx  @dptr, a
        mov   a, r3
        djnz  B, DLP
        mov   dptr, #OUTBIT
        mov   a, r2
        movx  @dptr, a        ; 显示一位八段管
        mov   r6, #01
        call  Delay
        mov   a, r2           ; 显示下一位
        rR    a
        mov   r2, a
        inc   r0
        djnz  r1, Loop
        mov   dptr, #OUTBIT
        mov   a, #0
        movx  @dptr, a        ; 关所有八段管
        clr 0d3h
        ret
LEDMAP:                       ; 八段管显示码
       db    3fh, 06h, 5bh, 4fh, 66h, 6dh, 7dh, 07h
       db    7fh, 6fh, 77h, 7ch, 39h, 5eh, 79h, 71h
       DB    40H
 Delay: mov   r7, #00H          ; 延时子程序
DelayLoop:
        djnz  r7, DelayLoop
        djnz  r6, DelayLoop
        ret
	    end
