;ST7565V*1
CS1   EQU P1.0
RES EQU P1.1  ;RST=/RES
A0    EQU P1.2 ;RS=A0
W_R    EQU P1.3 ;W_R=/WR
R_D   EQU P1.4  ;R_D=RD/E
      ORG    0000H
      JMP    BEGIN
      ORG    0003H
      JMP    INTOO
      ORG    0013H
      JMP    INTII
BEGIN:   CLR EA
         CLR    RES           ;RST  
         NOP
         lcall  delay
         lcall  delay
      
         SETB   RES
         NOP   
         lcall  delay
         ;MOV     A,#0E2H        ;SOFTWAVE  RST
         ;LCALL  WCOM
         MOV    A,#00101111B     ;POWER SETTING(VF=ON,VR=ON,VC=ON)
         LCALL WCOM
         MOV     A,#0A2H         ;MOV    A,#0A2H         ;BIAS SELECT =1/6
         LCALL  WCOM
         MOV    A,#10100000B         ;ADC SELECT:  SEG0 TO SEG131
         LCALL  WCOM
         MOV A,#11001000B            ;SHL SELECT:  COM63 TO COM0
         LCALL  WCOM                                                                                                                                                                                            
         MOV    A,#00100010B    ;SET V5 VOLTAGE
         LCALL  WCOM
         MOV    A,#10000001B    ;ELECTRONIC VOLUME MODE SET
         LCALL  WCOM
         MOV    A,#00100101B     ;ELECTRONIC VOLUME REGISTER SET;
         MOV B,A
         LCALL  WCOM
         ;MOV    R3,090H     ;WRITE 00H TO DISPLAY DATA RAM
         ;LCALL  TEST
         ;MOV A,#10101100B        ;STATIC INDICATOR OFF
         ;LCALL WCOM

        ;MOV    A,#11111000B
         ;LCALL WCOM
         ;MOV    A,#00000000B
         ;LCALL WCOM
         ;LCALL DELAY
         MOV    A,#040H    ;INITIAL DISPLAY LINE
         LCALL  WCOM
         MOV    A,#0A6H    ;NORMAL DISPLAY!!!!!!!!!!!
         LCALL  WCOM
         SETB EA
         SETB IT0
         SETB IT1
         CLR EX0
         CLR EX1
START:  
         MOV    A,#0AFH    ;DISPLAY  ON
         LCALL  WCOM
         
         MOV    A,#10100101B  ;DISPLAY ALL POINTS ON(TEST1)
         LCALL  WCOM
         LCALL  DELAY2
         ;LCALL DELAY4
;        WAIT: JMP WAIT
         MOV    A,#10100100B  ;return normal
         LCALL  WCOM
         ;LCALL  DELAY2
         
         ;MOV    A,#040H    ;INITIAL DISPLAY LINE
         ;LCALL  WCOM
         LCALL  TEST2         ;TEST2
            ;MOV    A,#0AFH    ;DISPLAY  ON
         ;LCALL  WCOM
         LCALL  DELAY2
         ;LCALL DELAY4

         ;MOV    A,#040H    ;INITIAL DISPLAY LINE
         ;LCALL  WCOM         
         MOV    R3,#00H       ;TSET3
         LCALL  TEST
            ;MOV    A,#0AFH    ;DISPLAY  ON
         ;LCALL  WCOM
         lcall   delay2
         ;LCALL DELAY4
         
         MOV    R3,#08H       ;TEST4
         LCALL  TEST
            ;MOV    A,#0AFH    ;DISPLAY  ON
         ;LCALL  WCOM
         LCALL  DELAY2
         ;LCALL DELAY4
         
         MOV R3,#090H
         LCALL TEST
         LCALL  TEST6         ;TEST6
         LCALL  DELAY2
         ;LCALL  DELAY2
         ;LCALL DELAY4
         
         MOV    A,#10101110B   ;DISPLAY OFF(TEST6)
         LCALL  WCOM
         LCALL  DELAY2
         ;LCALL DELAY4
;         WAIT:JMP WAIT
         LJMP   START
 INTOO:  PUSH ACC
        MOV A,B
        CJNE A,#00000000B,GO_DEC
        JMP OUT_INTOO
  GO_DEC:DEC A
         MOV B,A
         MOV A,#10000001B
         LCALL WCOM
         MOV A,B
         LCALL WCOM
   OUT_INTOO:POP ACC
         RETI
INTII:  PUSH ACC
        MOV A,B
        CJNE A,#00111111B,GO_INC
        JMP OUT_INTII
  GO_INC:INC A
         MOV B,A
         MOV A,#10000001B
         LCALL WCOM
         MOV A,B
         LCALL WCOM
   OUT_INTII:POP ACC
         RETI

  TEST:
              MOV      R2,#0B0H
  DISP2:      MOV      A,R2            ;set page address
              LCALL    WCOM
              MOV      A,#010H         ;set column address MSB
              LCALL    WCOM
              mov       a,#00h
              ;MOV      A,#00H          ;set column address LSB
              LCALL    WCOM
              MOV      R1,#010H         ;set (8*8)*16characters
     DISP1:   MOV      DPTR,#CHAR


              MOV      R0,#08H
    DISP0:
                MOV      A,R3
                MOVC     A,@A+DPTR
                LCALL    WDATA
                INC      DPTR
                DJNZ     R0,DISP0
                DJNZ     R1,DISP1
                INC      R2
                CJNE     R2,#0B4H,DISP2
                RET
   TEST2:       MOV      A,#10110000B    
                LCALL    WCOM  
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
                MOV      A,#11111111B
                LCALL    WDATA
                MOV      A,#00000001B
                LCALL    LOOP
                MOV      A,#11111111B
                LCALL    WDATA
                MOV      A,#10110001B
                MOV      R5,A    
                LCALL    WCOM  
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM               
                MOV      R6,#2
     TEST2_1:   MOV      A,#11111111B
                LCALL    WDATA
                MOV      A,#00000000B
                LCALL    LOOP
                MOV      A,#11111111B
                LCALL    WDATA
                INC      R5
                MOV      A,R5
                LCALL    WCOM
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
                DJNZ     R6,TEST2_1
                MOV      A,#10110011B    
                LCALL    WCOM  
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
                MOV      A,#11111111B
                LCALL    WDATA
                MOV      A,#10000000B
                LCALL    LOOP
                MOV      A,#11111111B
                LCALL    WDATA
                RET
                          
    TEST5:      MOV      A,#10110000B
                MOV      R5,A
                LCALL    WCOM
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
                MOV      R7,#4
     TEST5_1:   MOV      A,#10H
                MOV      R4,A
                MOV      DPTR,#CHAR
                MOV      R6,#128
     TEST5_2:   MOVC     A,@A+DPTR
                LCALL    WDATA
                INC      R4
                MOV      A,R4
                DJNZ     R6,TEST5_2
                INC      R5
                MOV      A,R5
                LCALL    WCOM
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
                DJNZ     R7,TEST5_1
                RET
    TEST6:      MOV      A,#10110000B
                MOV      R5,A
                LCALL    WCOM
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
;                MOV      DPTR,#CHAR1
                ;MOV R4,#4
    TEST6_3:    MOV      DPTR,#CHAR2
                MOV      R7,#4
     TEST6_1:   ;MOV      A,#10H
;                MOV      R4,A
                
                MOV      R6,#128
     TEST6_2:   MOV A,#0
                MOVC     A,@A+DPTR
                LCALL    WDATA
                INC      DPTR
                ;MOV      A,R4
                DJNZ     R6,TEST6_2
                INC      R5
                MOV      A,R5
                LCALL    WCOM
                MOV      A,#00010000B
                LCALL    WCOM
                MOV      A,#00000000B
                LCALL    WCOM
                DJNZ     R7,TEST6_1
                ;DJNZ R4,TEST6_3
                RET 
    LOOP:       MOV R7,#126
     LOOP_1:    LCALL WDATA
                DJNZ R7,LOOP_1
                RET   
    DELAY:  MOV     40H,#032H        ;10.05ms
    DEL1: MOV     41H,#030H        
    DEL2: DJNZ    41H,DEL2      ;192us
            DJNZ    40H,DEL1      
            RET
            
    DELAY2: SETB EX0
            SETB EX1
            LCALL DELAY4
            MOV     40H,#15
    DEL21:  MOV     41H,#250
    DEL22:  MOV     42H,#80
    DEL23:  ;MOV C,P2.0
            JB P2.0,KDL
            LCALL DELAY4
  CHECK_KEY:  NOP
              NOP
              ;MOV C,P2.0
              JNB P2.0,BREAK1
              JMP CHECK_KEY
      KDL:  DJNZ    42H,DEL23
            DJNZ    41H,DEL22
            DJNZ    40H,DEL21
      BREAK1: CLR EX0
              CLR EX1
            RET
    DELAY4: MOV     43h,#4
    DEL41:  MOV     44h,#250
    DEL42:  MOV     45h,#200
     DEL43:  DJNZ    45h,DEL43
            DJNZ    44h,DEL42
            DJNZ    43h,DEL41
            RET          
WCOM:      CLR EA
           clr A0
           CLR CS1
           SETB R_D
           ;CLR W_R
           
           MOV P0,A
           NOP
           ;SETB R_D
           ;CLR R_D
           CLR W_R
           NOP
           SETB W_R
           NOP
           NOP
           NOP
           NOP
           SETB CS1
           SETB A0
           MOV 49H,#15
           L1:DJNZ 49H,L1
           SETB EA
           RET
WDATA:     CLR EA
           SETB A0
           CLR CS1
           SETB R_D
           ;CLR W_R
           
           MOV P0,A
           NOP
           ;CLR R_D
           CLR W_R
           ;SETB A0
           NOP
           SETB W_R
                 NOP
           NOP
           NOP
           NOP     
           
           ;MOV 49H,#15
           ;L2:DJNZ 49H,L2
          ; SETB R_D
           ;CLR R_D
           SETB CS1
           CLR A0
           SETB EA
           RET
             
      CHAR:
           DB      0FFH,000H,0FFH,000H,0FFH,000H,0FFH,000H
           DB      055H,055H,055H,055H,055H,055H,055H,055H
           DB      03FH,048H,048H,048H,03FH,000H,000H,000H
           DB      07FH,049H,049H,049H,036H,000H,000H,000H
           DB      03EH,041H,041H,041H,022H,000H,000H,000H
           DB      07FH,041H,041H,022H,01CH,000H,000H,000H
           DB      07FH,049H,049H,049H,041H,000H,000H,000H
           DB      07FH,048H,048H,048H,040H,000H,000H,000H
           DB      03EH,041H,049H,049H,02FH,000H,000H,000H
           DB      036H,049H,055H,022H,005H,000H,000H,000H
           DB      002H,015H,015H,015H,00FH,000H,000H,000H
           DB      07FH,009H,011H,011H,00EH,000H,000H,000H
           DB      00EH,011H,011H,011H,002H,000H,000H,000H
           DB      00EH,011H,011H,009H,07FH,000H,000H,000H
           DB      00EH,015H,015H,015H,00CH,000H,000H,000H
           DB      008H,03FH,048H,040H,020H,000H,000H,000H
           DB      018H,025H,025H,025H,03EH,000H,000H,000H
           DB      036H,049H,055H,022H,005H,000H,079H,000H
           DB      000H,000H,000H,000H,000H,000H,000H,000H
           
  CHAR2:
DB    000H,000H,000H,000H,008H,0F8H,008H,008H,008H,010H,0E0H,000H,000H,080H,098H,098H
DB    000H,000H,000H,000H,000H,000H,080H,080H,080H,080H,080H,000H,080H,080H,000H,080H
DB    080H,000H,000H,000H,000H,008H,008H,0F8H,000H,000H,000H,000H,000H,000H,080H,080H
DB    080H,080H,000H,000H,080H,080H,080H,000H,000H,080H,080H,080H,000H,080H,080H,0E0H
DB    080H,080H,000H,000H,000H,000H,080H,080H,080H,080H,000H,000H,000H,000H,000H,080H
DB    080H,080H,000H,000H,008H,0F8H,000H,080H,080H,080H,000H,000H,000H,000H,000H,000H
DB    000H,000H,000H,000H,008H,0F8H,008H,000H,000H,000H,000H,000H,000H,080H,080H,0E0H
DB    080H,080H,000H,000H,000H,000H,000H,080H,080H,088H,0F8H,000H,000H,000H,000H,000H
DB    000H,000H,000H,000H,020H,03FH,020H,020H,020H,010H,00FH,000H,000H,020H,020H,03FH
DB    020H,020H,000H,000H,000H,033H,024H,024H,024H,024H,019H,000H,080H,0FFH,0A1H,020H
DB    020H,011H,00EH,000H,000H,020H,020H,03FH,020H,020H,000H,000H,000H,019H,024H,022H
DB    022H,022H,03FH,020H,080H,081H,08EH,070H,018H,006H,001H,000H,000H,000H,000H,01FH
DB    020H,020H,000H,000H,000H,01FH,022H,022H,022H,022H,013H,000H,000H,00EH,011H,020H
DB    020H,020H,011H,000H,020H,03FH,021H,000H,000H,020H,03FH,020H,000H,000H,000H,000H
DB    000H,000H,000H,000H,020H,03FH,020H,020H,020H,020H,030H,000H,000H,000H,000H,01FH
DB    020H,020H,000H,000H,000H,00EH,011H,020H,020H,010H,03FH,020H,000H,000H,000H,000H
DB    000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,030H,008H,088H
DB    088H,048H,030H,000H,000H,070H,008H,008H,008H,088H,070H,000H,000H,010H,010H,0F8H
DB    000H,000H,000H,000H,000H,070H,008H,008H,008H,088H,070H,000H,000H,070H,088H,008H
DB    008H,088H,070H,000H,000H,000H,0C0H,038H,0E0H,000H,000H,000H,000H,000H,000H,000H
DB    000H,000H,000H,000H,000H,070H,088H,008H,008H,008H,038H,000H,000H,000H,080H,080H
DB    080H,080H,000H,000H,080H,080H,080H,000H,080H,080H,080H,000H,000H,080H,098H,098H
DB    000H,000H,000H,000H,000H,000H,080H,080H,080H,080H,000H,000H,000H,000H,080H,080H
DB    080H,080H,080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H
DB    000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,018H,020H,020H
DB    020H,011H,00EH,000H,000H,030H,028H,024H,022H,021H,030H,000H,000H,020H,020H,03FH
DB    020H,020H,000H,000H,000H,030H,028H,024H,022H,021H,030H,000H,000H,01CH,022H,021H
DB    021H,022H,01CH,000H,020H,03CH,023H,002H,002H,027H,038H,020H,000H,000H,000H,000H
DB    000H,000H,000H,000H,000H,038H,020H,021H,021H,022H,01CH,000H,000H,01FH,022H,022H
DB    022H,022H,013H,000H,020H,020H,03FH,021H,020H,000H,001H,000H,000H,020H,020H,03FH
DB    020H,020H,000H,000H,000H,01FH,022H,022H,022H,022H,013H,000H,000H,033H,024H,024H
DB    024H,024H,019H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H

           END

