ORG 0000H
LJMP MAIN		 ; jump to main program
    ORG 0030H
 MAIN:  
       CLR RS0			 ; choose register
       CLR RS1
       cs1 equ p3.3
       cs2 equ p3.4
        rs equ p3.0
        rw equ p3.1
        e equ p3.2
        RES equ p3.5
        com equ 20h
        DAT EQU 21h
        X EQU 22h
        Y EQU 23h
        Z EQU 24h
       
        lcall rest
        lcall init
        mov z,#0
  






           mov x,#1
           mov y,#0
           mov dptr,#S1       ;显示"卡"
           lcall Lshow

      
           mov x,#1
           mov y,#16
          
           mov dptr,#S2        ;显示"号"
           lcall lshow


           mov x,#1
           mov y,#0
           mov dptr,#S1       ;显示"卡"
           lcall Rshow

      
           mov x,#1
           mov y,#16
          
           mov dptr,#S2        ;显示"号"
           lcall Rshow



     CLY:    AJMP CLY
         






 lshow:  MOV A,#0C0H   ;START = 0
          ADD A,Z
          MOV COM,A
	     LCALL PRL0

	     MOV R7,#2
	     MOV A,#0B8H
	     ADD A,X	 ;B8+X
	     MOV X,A	 ;A>>30H
   HZ2:    
	     MOV COM,X  ; X+1
	     LCALL PRL0

	     MOV A,#40H   ; Y
	     ADD A,Y
	 
	     MOV COM,A
	     LCALL PRL0

	     MOV R5,#16
   HZ1:      MOV A,#00H
	     MOVC A,@A+DPTR
	     MOV DAT,A
	     LCALL PRL1
	     INC DPTR
	     DJNZ R5,HZ1
             INC X
	     DJNZ R7,HZ2
	     RET

rshow:  MOV A,#0C0H   ;START = 0
         ADD A,Z
         MOV COM,A
	     LCALL PRR0

	     MOV R7,#2
	     MOV A,#0B8H
	     ADD A,X	 ;B8+X
	     MOV X,A	 ;A>>30H
   rHZ2:    
	     MOV COM,X  ; X+1
	     LCALL PRR0

	     MOV A,#40H   ; Y
	     ADD A,Y
	 
	     MOV COM,A
	     LCALL PRR0

	     MOV R5,#16
   rHZ1:      MOV A,#00H
	     MOVC A,@A+DPTR
	     MOV DAT,A
	     LCALL PRR1
	     INC DPTR
	     DJNZ R5,rHZ1
             INC X
	     DJNZ R7,rHZ2
	     RET











                          
   rest:  lcall DLY100
	    clr res
	    lcall DLY50
           lcall DLY50
           setb res
           lcall DLY50
           ret

 init:                               ;初始化
         MOV COM,#3FH   ;开显示
	     LCALL PRL0
	     lcall PRR0
	     MOV R7,#8	       
	     MOV R2,#0B8H
      LOP1:  MOV A,R2
	     MOV COM,A        ;  清
	    LCALL PRL0
	     lcall PRR0
	     MOV R1,#40H      ;  屏
	     LCALL PRL0
	     lcall PRR0
	     MOV R5,#64
     LOP11:  MOV dat,#0H
	     LCALL PRL1
	     lcall PRR1
	     DJNZ R5,LOP11 
	     INC R2
	     DJNZ R7,LOP1
        MOV COM,#0C0H   ;   显示起始行
	     LCALL PRL0
	     LCALL PRR0
	     ret


PRL0:
       setb cs1
       clr cs2
       clr rs
       setb rw
 sw1:  mov p1,#0ffh
       setb e
       mov a,p1
       clr e
       jb acc.7,sw1
       clr rw
       mov p1,COM
       setb e
       setb e
       nop
       clr e
       ret
PRL1:
       setb cs1
       clr cs2
       clr rs
       setb rw
 sw2:  
       mov p1,#0ffh
       setb e
       mov a,p1                 
       clr e
       jb acc.7,sw2
       setb rs
       clr rw
       mov p1,DAT
       setb e
       clr e
       ret
      
PRR0:
       clr cs1
       setb cs2
       clr rs
       setb rw
 rsw1:  mov p1,#0ffh
       setb e
       mov a,p1
       clr e
       jb acc.7,rsw1
       clr rw
       mov p1,COM
       setb e
       setb e
       nop
       clr e
       ret
PRR1:
       clr cs1
       setb cs2
       clr rs
       setb rw
 rsw2:  mov p1,#0ffh
       setb e
       mov a,p1
       clr e
       jb acc.7,rsw2
       setb rs
       clr rw
       mov p1,DAT
       setb e
       setb e
       nop
       clr e
       ret
 










 
 DLY10:MOV R3,#01H
	DL1:MOV R4,#01H
	DL2:MOV R6,#0FH
	DL3:DJNZ R6,DL3
	    DJNZ R4,DL2
	    DJNZ R3,DL1
	    RET

      DLY50:MOV R3,#04H
	DL111:MOV R4,#0FH
	DL222:MOV R6,#0AFH
	DL333:DJNZ R6,DL333
	    DJNZ R4,DL222
	    DJNZ R3,DL111
	    RET
DLY100:MOV R3,#06H
	DL11:MOV R4,#0FFH
	DL22:MOV R6,#0FFH 
	DL33:DJNZ R6,DL33
	     DJNZ R4,DL22
	     DJNZ R3,DL11
	     RET

 
		  
		  

s1:;卡
    DB  40H, 40H, 40H, 40H, 40H, 40H,0ffH, 44H, 44H, 44H, 46H, 44H, 40H, 60H, 40H, 00H
    DB  00H, 00H, 00H, 00H, 00H, 00H,0ffH, 00H, 02H, 04H, 0cH, 18H, 00H, 00H, 00H, 00H
s2:;号
   DB  80H, 80H, 80H,0beH,0a2H,0a2H,0a2H,0a2H,0a2H,0a2H,0a2H,0bfH, 82H,0c0H, 80H, 00H
   DB  00H, 00H, 00H, 04H, 06H, 05H, 04H, 04H, 44H, 84H, 44H, 3eH, 04H, 00H, 00H, 00H


end

     