org   0000h
ajmp main
org  0030h
main:
       mov  a,#0ffh
       mov  p3,a
       mov  p1,#0f0h
       jnb  p3.1,a1
       jnb  p3.2,a2
       jnb  p3.3,a3
       jnb  p3.4,a4
       jnb  p3.5,a5
       jnb  p3.7,a6
       jb   p3.1,main
       jb   p3.2,main
       jb   p3.3,main
       jb   p3.4,main
       jb   p3.5,main
       jb   p3.7,main
  a1 :   ajmp   flash50s
  a2 :   ajmp   flash100s
  a3 :   ajmp   flash5100s
  a4 :   ajmp   flash5180s
  a5 :   ajmp   flashrg50s
  a6 :   ajmp   flashrg5100s
flash50s:
           mov  a,#0ffh
           mov  p3,a
           mov  p1,#0f0h
          jnb  p3.0,flasha
           jb   p3.0,flash50s
speak1: clr  p1.2
        clr  p1.1
        clr  p1.0
        setb  p1.2
        acall   delay2s
        clr   p1.2
        ajmp  flash50s
flasha:
     mov  a,#00h
     mov  p1,a
     setb p1.0
     jnb  p3.0,b1
     acall  delay50sa                       ;50s
     clr  p1.0
     clr  p1.1
     ajmp  speak1
  b1:ajmp  flash50s
flash100s:
           mov  a,#0ffh
           mov  p3,a
            mov  p1,#0f0h
       
           jnb  p3.0,flashb
           jb   p3.0,flash100s
 speak2:clr  p1.2
        clr  p1.1
        clr  p1.0
        setb  p1.2
        acall   delay2s
        clr   p1.2
        ajmp  flash100s
flashb:
     mov  a,#00h
     mov  p1,a
     setb p1.0
     jnb  p3.0,b2
     acall  delay50sab                       ;100s
     clr  p1.0
     clr  p1.1
     ajmp  speak2
  b2:ajmp  flash100s

flash5100s:   mov a,#0ffh
            mov  p3,a
            mov  p1,#0f0h
          
            jnb  p3.0,flashc
            jb   p3.0,flash5100s
speak3:clr  p1.2
       clr  p1.1
       clr  p1.0
       setb  p1.2
       acall   delay2s
       clr   p1.2
       ajmp  flash5100s
flashc:
      mov  a,#00h
      mov  p1,a
      mov  r0,#0
      mov  r1,#0
    l18:MOV r0,#0
    l28:clr  p1.0
       jnb  p3.0,b3
       acall  delay005sc
       setb  p1.0
       jnb  p3.0,b3
       acall  delay005sc
       inc  r0
       cjne  r0,#05h,l28
       inc  r1
       cjne  r1,#54h,l18
       ajmp  speak3
   b3:ajmp  flash5100s

flash5180s:
            mov  a,#0ffh
            mov  p3,a
             mov  p1,#0f0h
          
            jnb  p3.0,flashd
            jb   p3.0,flash5180s
speak4:    clr  p1.2
          clr  p1.1
          clr  p1.0
         setb  p1.2
         acall   delay2s
         clr   p1.2
         ajmp  flash5180s
flashd:
      mov  a,#00h
      mov  p1,a
      mov  r0,#0
      mov  r1,#0
    l11:MOV r0,#0
    l21:clr  p1.0
        jnb  p3.0,b4
       acall  delay005scd
       setb  p1.0
       jnb  p3.0,b4
       acall  delay005scd
       inc  r0
       cjne  r0,#05h,l21
       inc  r1
       cjne  r1,#54h,l11
       ajmp  speak4
    b4: ajmp  flash5180s

flashrg50s: mov  a,#0ffh
           mov  p3,a
           mov  p1,#0f0h
           clr a
           jnb  p3.0,flash1
           jb   p3.0,flashrg50s
 speaka:clr  p1.2
        clr  p1.1
        clr  p1.0
        setb  p1.2
        acall   delay2s
        clr   p1.2
        ajmp  flashrg50s
flash1:
     mov  p1,#0f0h
     setb p1.0
     jnb  p3.0,b5
     acall  delay50s1
     clr  p1.0
     ajmp  speaka
  b5:ajmp  flash2
flash2:
     mov  p1,#0f0h
     setb p1.1
     jnb  p3.0,b6
     acall  delay50s11
     clr  p1.1
     ajmp  speaka
  b6:ajmp  flashrg50s

flashrg5100s: mov  a,#0ffh
              mov  p3,a
              mov  p1,#0f0h
              
              jnb  p3.0,flash11
              jb   p3.0,flashrg5100s
speak3b:clr  p1.2
        clr  p1.1
        clr  p1.0
        setb  p1.2
        acall   delay2s
        clr   p1.2
        ajmp  flashrg5100s
flash11:
      mov  a,#00h
      mov  p1,a
      mov  r0,#0
      mov  r1,#0
   l12:MOV r0,#0
   l22:clr  p1.0
       jnb  p3.0,b7
       acall  delay005s2
       setb  p1.0
       jnb  p3.0,b7
       acall  delay005s2
       inc  r0
       cjne  r0,#05h,l22
       inc  r1
       cjne  r1,#54h,l12
       ajmp  speak3b
   b7:  ajmp  flash12
flash12:
      mov  a,#00h
      mov  p1,a
      mov  r0,#0
      mov  r1,#0
    l1:MOV r0,#0
    l2:clr  p1.1
       jnb  p3.0,b8
       acall  delay005s2
       setb  p1.1
       jnb  p3.0,b8
       acall  delay005s2
       inc  r0
       cjne  r0,#05h,l2
       inc  r1
       cjne  r1,#54h,l1
       ajmp  speak3b
   b8: ajmp flashrg5100s

delay50sa:
            mov  r1 ,#68H
  dly1m_10:
            lcall dly_1s0
            djnz r1,dly1m_10
            ret
   dly_1s0:
            mov  r2,#0EFH
  dly1s_10:
            mov  r3,#01FH
  dly1s_20:
            mov  r4,#02FH
      dl10:
             nop
             nop
             djnz  r4,dl10
             djnz  r3,dly1s_20
             jnb  p3.0,d4
             djnz  r2,dly1s_10
             ret
      d4:   ajmp   flash50s

delay50sab:
            mov  r1 ,#0e9H
  dly1m_11:
            lcall dly_1s1
            djnz r1,dly1m_11
            ret
   dly_1s1:
            mov  r2,#0EFH
  dly1s_11:
            mov  r3,#01FH
  dly1s_21:
            mov  r4,#02FH
      dl11:
             nop
             nop
            djnz  r4,dl11
            djnz  r3,dly1s_21
            jnb  p3.0,c1
            djnz  r2,dly1s_11
             ret
     c1:ajmp  flash100s
delay005sc:mov R5,#02H
    DELX1:MOV R6,#0FFH
    DELX2:MOV R7,#0FFH
    DELX3:DJNZ R7,DELX3
          DJNZ R6,DELX2
          DJNZ R5,DELX1
          RET


delay005scd:mov R5,#02H
    DELX12:MOV R6,#0FFH
    DELX22:MOV R7,#0FFH
    DELX32:DJNZ R7,DELX32
          DJNZ R6,DELX22
          DJNZ R5,DELX12
          RET
delay50s1:
            mov  r1 ,#68H
  dly1m_15:
            lcall dly_1s5
            djnz r1,dly1m_15
            ret
   dly_1s5:
            mov  r2,#0EFH
  dly1s_15:
            mov  r3,#01FH
  dly1s_25:
            mov  r4,#02FH
      dl15:
             nop
             nop
             djnz  r4,dl15
             djnz  r3,dly1s_25
             jnb  p3.0,d1
             djnz  r2,dly1s_15
             ret
         d1:   ajmp  flash2
  delay50s11:
            mov  r1 ,#68H
  dly1m_151:
            lcall dly_1s51
            djnz r1,dly1m_151
            ret
   dly_1s51:
            mov  r2,#0EFH
  dly1s_151:
            mov  r3,#01FH
  dly1s_251:
            mov  r4,#02FH
      dl151:
             nop
             nop
             djnz  r4,dl151
             djnz  r3,dly1s_251
             jnb  p3.0,d2
             djnz  r2,dly1s_151
             ret
        d2:ajmp  flashrg50s
 delay005s2:mov R5,#02H
    DELX17:MOV R6,#0FFH
    DELX27:MOV R7,#0FFH
    DELX37:DJNZ R7,DELX37
          DJNZ R6,DELX27
          DJNZ R5,DELX17
          RET
 delay2s:  mov  r1 ,#5                         ;     2.4s
  dly1m_119:
            lcall dly_1s19
            djnz r1,dly1m_119
            ret
   dly_1s19:
            mov  r2,#100
  dly1s_119:
            mov  r3,#10
  dly1s_219:
            mov  r4,#125
      dl119:
             nop
             nop
            djnz  r4,dl119
             djnz  r3,dly1s_219
             djnz  r2,dly1s_119
            ret
