.org 0x0000
    rjmp RESET
    reti		; INT0_ISR
    reti		; PCINT0_ISR
    reti		; TIM1_COMPA_ISR
    reti		; TIM1_OVF_ISR
    reti		; TIM0_OVF_ISR
    reti		; EE_RDY_ISR
    reti		; ANA_COMP_ISR
    reti		; ADC_ISR
    reti		; TIM1_COMPB_ISR
    reti		; TIM0_COMPA_ISR
    reti		; TIM0_COMPB_ISR
    reti		; WDT_ISR
    reti		; USI_START_ISR
    reti		; USI_OVF_ISR

RESET:
	ldi R16,0x00			; R16(LED_MODE) = 0
	ldi R17,0x00			; R17(LED_COUNTER) = 0
	ldi R18,0x00			; R18(MODE_TIMER) = 0
	; LED_INIT
    ldi R20,0x19			; R20 <- **011001B
    out 0x17,R20			; DDRB <- R20
 MAIN_LOOP:
	inc R17
	inc R18					; R18(MODE_TIMER)++
	cpi R18,0x50			; TimeLimitChekc
	brne LED_CONTROL
	ldi R18,0x00			; R18(MODE_TIMER) CLEAR
	inc R16					; R16(LED_MODE)++
	andi R16,0x03
	ldi R17,0x00
  LED_CONTROL:
	cpi R16,0x01
	brcs LED_MODE0
	breq LED_MODE1
	cpi R16,0x03
	brne LED_MODE2
	rjmp LED_MODE3
; -------------------------
LED_MODE0:
	andi R17,0x03
	breq LED_MODE0L
	cpi R17,0x02
	breq LED_MODE0R
 LED_MODE0C:
	ldi R20,0xf7			; R20 <- 11110111B
    out 0x18,R20			; PORTB <- R20
 	rjmp LED_MODE0_WAIT
 LED_MODE0L:
	ldi R20,0xfe			; R20 <- 11111110B
	out 0x18,R20			; PORTB <- R20
 	rjmp LED_MODE0_WAIT
 LED_MODE0R:
	ldi R20,0xef			; R20 <- 11101111B
	out 0x18,R20			; PORTB <- R20
 LED_MODE0_WAIT:
 	rjmp LED_WAIT
; -------------------------
LED_MODE1:
	mov R20,R17
	andi R20,0x04
	breq LED_MODE1LR
 LED_MODE1C:
	ldi R20,0xf7			; R20 <- 11110111B
    out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE1_WAIT
 LED_MODE1LR:
	ldi R20,0xee			; R20 <- 11101110B
	out 0x18,R20			; PORTB <- R20
 LED_MODE1_WAIT:
 	rjmp LED_WAIT
; -------------------------
LED_MODE2:
	cpi R17,0x01
	breq LED_MODE2_ON
	cpi R17,0x03
	breq LED_MODE2_ON
	andi R17,0x07
 LED_MODE2_OFF:
	ldi R20,0xff			; R20 <- 11111111B
	out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE2_WAIT
 LED_MODE2_ON:
	ldi R20,0xe6			; R20 <- 11100110B
	out 0x18,R20			; PORTB <- R20
 LED_MODE2_WAIT:
	rjmp LED_WAIT
; -------------------------
LED_MODE3:
	cpi R17,0x0e
	brne LED_MODE3_MAIN
	ldi R17,0x00
 LED_MODE3_MAIN:
	cpi R17,0x01
	brcs LED_MODE30
	breq LED_MODE31
	cpi R17,0x03
	brcs LED_MODE32
	breq LED_MODE33
	cpi R17,0x05
	brcs LED_MODE34
	breq LED_MODE35
	cpi R17,0x07
	brcs LED_MODE35
	breq LED_MODE34
	cpi R17,0x09
	brcs LED_MODE33
	breq LED_MODE32
	cpi R17,0x0b
	brcs LED_MODE31
	breq LED_MODE30
	rjmp LED_MODE35
 LED_MODE30:
	ldi R20,0xfe			; R20 <- 11111110B
	out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE3_WAIT
 LED_MODE31:
	ldi R20,0xf6			; R20 <- 11110110B
	out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE3_WAIT
 LED_MODE32:
	ldi R20,0xe6			; R20 <- 11100110B
	out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE3_WAIT
 LED_MODE33:
	ldi R20,0xe7			; R20 <- 11100111B
	out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE3_WAIT
 LED_MODE34:
	ldi R20,0xef			; R20 <- 11101111B
	out 0x18,R20			; PORTB <- R20
	rjmp LED_MODE3_WAIT
 LED_MODE35:
	ldi R20,0xff			; R20 <- 11111111B
	out 0x18,R20			; PORTB <- R20
 LED_MODE3_WAIT:
 	ldi R20,0x04			; WAIT_TIME
	rjmp LED_WAIT
; -------------------------
LED_WAIT:
 	ldi R20,0x01			; WAIT_TIME
 LED_WAIT0:
    ldi R21,0x7f			; R21,0xff
 LED_WAIT1:
    ldi R22,0xff			; R22,0xff
 LED_WAIT2:
	nop
	dec R22					; R22--
	brne LED_WAIT2			; R22 != 0 LED_WAIT3
	dec R21					; R21--
	brne LED_WAIT1			; R21 != 0 LED_WAIT2
	dec R20					; R20--
	brne LED_WAIT0			; R20 != 0 LED_WAIT1
    rjmp MAIN_LOOP
