
;CodeVisionAVR C Compiler V3.12 Advanced
;(C) Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l.
;http://www.hpinfotech.com

;Build configuration    : Debug
;Chip type              : ATmega16
;Program type           : Application
;Clock frequency        : 8.000000 MHz
;Memory model           : Small
;Optimize for           : Speed
;(s)printf features     : int, width
;(s)scanf features      : int, width
;External RAM size      : 0
;Data Stack size        : 256 byte(s)
;Heap size              : 0 byte(s)
;Promote 'char' to 'int': Yes
;'char' is unsigned     : Yes
;8 bit enums            : Yes
;Global 'const' stored in FLASH: Yes
;Enhanced function parameter passing: Yes
;Enhanced core instructions: On
;Automatic register allocation for global variables: On
;Smart register allocation: On

	#define _MODEL_SMALL_

	#pragma AVRPART ADMIN PART_NAME ATmega16
	#pragma AVRPART MEMORY PROG_FLASH 16384
	#pragma AVRPART MEMORY EEPROM 512
	#pragma AVRPART MEMORY INT_SRAM SIZE 1024
	#pragma AVRPART MEMORY INT_SRAM START_ADDR 0x60

	#define CALL_SUPPORTED 1

	.LISTMAC
	.EQU UDRE=0x5
	.EQU RXC=0x7
	.EQU USR=0xB
	.EQU UDR=0xC
	.EQU SPSR=0xE
	.EQU SPDR=0xF
	.EQU EERE=0x0
	.EQU EEWE=0x1
	.EQU EEMWE=0x2
	.EQU EECR=0x1C
	.EQU EEDR=0x1D
	.EQU EEARL=0x1E
	.EQU EEARH=0x1F
	.EQU WDTCR=0x21
	.EQU MCUCR=0x35
	.EQU GICR=0x3B
	.EQU SPL=0x3D
	.EQU SPH=0x3E
	.EQU SREG=0x3F

	.DEF R0X0=R0
	.DEF R0X1=R1
	.DEF R0X2=R2
	.DEF R0X3=R3
	.DEF R0X4=R4
	.DEF R0X5=R5
	.DEF R0X6=R6
	.DEF R0X7=R7
	.DEF R0X8=R8
	.DEF R0X9=R9
	.DEF R0XA=R10
	.DEF R0XB=R11
	.DEF R0XC=R12
	.DEF R0XD=R13
	.DEF R0XE=R14
	.DEF R0XF=R15
	.DEF R0X10=R16
	.DEF R0X11=R17
	.DEF R0X12=R18
	.DEF R0X13=R19
	.DEF R0X14=R20
	.DEF R0X15=R21
	.DEF R0X16=R22
	.DEF R0X17=R23
	.DEF R0X18=R24
	.DEF R0X19=R25
	.DEF R0X1A=R26
	.DEF R0X1B=R27
	.DEF R0X1C=R28
	.DEF R0X1D=R29
	.DEF R0X1E=R30
	.DEF R0X1F=R31

	.EQU __SRAM_START=0x0060
	.EQU __SRAM_END=0x045F
	.EQU __DSTACK_SIZE=0x0100
	.EQU __HEAP_SIZE=0x0000
	.EQU __CLEAR_SRAM_SIZE=__SRAM_END-__SRAM_START+1

	.MACRO __CPD1N
	CPI  R30,LOW(@0)
	LDI  R26,HIGH(@0)
	CPC  R31,R26
	LDI  R26,BYTE3(@0)
	CPC  R22,R26
	LDI  R26,BYTE4(@0)
	CPC  R23,R26
	.ENDM

	.MACRO __CPD2N
	CPI  R26,LOW(@0)
	LDI  R30,HIGH(@0)
	CPC  R27,R30
	LDI  R30,BYTE3(@0)
	CPC  R24,R30
	LDI  R30,BYTE4(@0)
	CPC  R25,R30
	.ENDM

	.MACRO __CPWRR
	CP   R@0,R@2
	CPC  R@1,R@3
	.ENDM

	.MACRO __CPWRN
	CPI  R@0,LOW(@2)
	LDI  R30,HIGH(@2)
	CPC  R@1,R30
	.ENDM

	.MACRO __ADDB1MN
	SUBI R30,LOW(-@0-(@1))
	.ENDM

	.MACRO __ADDB2MN
	SUBI R26,LOW(-@0-(@1))
	.ENDM

	.MACRO __ADDW1MN
	SUBI R30,LOW(-@0-(@1))
	SBCI R31,HIGH(-@0-(@1))
	.ENDM

	.MACRO __ADDW2MN
	SUBI R26,LOW(-@0-(@1))
	SBCI R27,HIGH(-@0-(@1))
	.ENDM

	.MACRO __ADDW1FN
	SUBI R30,LOW(-2*@0-(@1))
	SBCI R31,HIGH(-2*@0-(@1))
	.ENDM

	.MACRO __ADDD1FN
	SUBI R30,LOW(-2*@0-(@1))
	SBCI R31,HIGH(-2*@0-(@1))
	SBCI R22,BYTE3(-2*@0-(@1))
	.ENDM

	.MACRO __ADDD1N
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	SBCI R22,BYTE3(-@0)
	SBCI R23,BYTE4(-@0)
	.ENDM

	.MACRO __ADDD2N
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	SBCI R24,BYTE3(-@0)
	SBCI R25,BYTE4(-@0)
	.ENDM

	.MACRO __SUBD1N
	SUBI R30,LOW(@0)
	SBCI R31,HIGH(@0)
	SBCI R22,BYTE3(@0)
	SBCI R23,BYTE4(@0)
	.ENDM

	.MACRO __SUBD2N
	SUBI R26,LOW(@0)
	SBCI R27,HIGH(@0)
	SBCI R24,BYTE3(@0)
	SBCI R25,BYTE4(@0)
	.ENDM

	.MACRO __ANDBMNN
	LDS  R30,@0+(@1)
	ANDI R30,LOW(@2)
	STS  @0+(@1),R30
	.ENDM

	.MACRO __ANDWMNN
	LDS  R30,@0+(@1)
	ANDI R30,LOW(@2)
	STS  @0+(@1),R30
	LDS  R30,@0+(@1)+1
	ANDI R30,HIGH(@2)
	STS  @0+(@1)+1,R30
	.ENDM

	.MACRO __ANDD1N
	ANDI R30,LOW(@0)
	ANDI R31,HIGH(@0)
	ANDI R22,BYTE3(@0)
	ANDI R23,BYTE4(@0)
	.ENDM

	.MACRO __ANDD2N
	ANDI R26,LOW(@0)
	ANDI R27,HIGH(@0)
	ANDI R24,BYTE3(@0)
	ANDI R25,BYTE4(@0)
	.ENDM

	.MACRO __ORBMNN
	LDS  R30,@0+(@1)
	ORI  R30,LOW(@2)
	STS  @0+(@1),R30
	.ENDM

	.MACRO __ORWMNN
	LDS  R30,@0+(@1)
	ORI  R30,LOW(@2)
	STS  @0+(@1),R30
	LDS  R30,@0+(@1)+1
	ORI  R30,HIGH(@2)
	STS  @0+(@1)+1,R30
	.ENDM

	.MACRO __ORD1N
	ORI  R30,LOW(@0)
	ORI  R31,HIGH(@0)
	ORI  R22,BYTE3(@0)
	ORI  R23,BYTE4(@0)
	.ENDM

	.MACRO __ORD2N
	ORI  R26,LOW(@0)
	ORI  R27,HIGH(@0)
	ORI  R24,BYTE3(@0)
	ORI  R25,BYTE4(@0)
	.ENDM

	.MACRO __DELAY_USB
	LDI  R24,LOW(@0)
__DELAY_USB_LOOP:
	DEC  R24
	BRNE __DELAY_USB_LOOP
	.ENDM

	.MACRO __DELAY_USW
	LDI  R24,LOW(@0)
	LDI  R25,HIGH(@0)
__DELAY_USW_LOOP:
	SBIW R24,1
	BRNE __DELAY_USW_LOOP
	.ENDM

	.MACRO __GETD1S
	LDD  R30,Y+@0
	LDD  R31,Y+@0+1
	LDD  R22,Y+@0+2
	LDD  R23,Y+@0+3
	.ENDM

	.MACRO __GETD2S
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	LDD  R24,Y+@0+2
	LDD  R25,Y+@0+3
	.ENDM

	.MACRO __PUTD1S
	STD  Y+@0,R30
	STD  Y+@0+1,R31
	STD  Y+@0+2,R22
	STD  Y+@0+3,R23
	.ENDM

	.MACRO __PUTD2S
	STD  Y+@0,R26
	STD  Y+@0+1,R27
	STD  Y+@0+2,R24
	STD  Y+@0+3,R25
	.ENDM

	.MACRO __PUTDZ2
	STD  Z+@0,R26
	STD  Z+@0+1,R27
	STD  Z+@0+2,R24
	STD  Z+@0+3,R25
	.ENDM

	.MACRO __CLRD1S
	STD  Y+@0,R30
	STD  Y+@0+1,R30
	STD  Y+@0+2,R30
	STD  Y+@0+3,R30
	.ENDM

	.MACRO __POINTB1MN
	LDI  R30,LOW(@0+(@1))
	.ENDM

	.MACRO __POINTW1MN
	LDI  R30,LOW(@0+(@1))
	LDI  R31,HIGH(@0+(@1))
	.ENDM

	.MACRO __POINTD1M
	LDI  R30,LOW(@0)
	LDI  R31,HIGH(@0)
	LDI  R22,BYTE3(@0)
	LDI  R23,BYTE4(@0)
	.ENDM

	.MACRO __POINTW1FN
	LDI  R30,LOW(2*@0+(@1))
	LDI  R31,HIGH(2*@0+(@1))
	.ENDM

	.MACRO __POINTD1FN
	LDI  R30,LOW(2*@0+(@1))
	LDI  R31,HIGH(2*@0+(@1))
	LDI  R22,BYTE3(2*@0+(@1))
	LDI  R23,BYTE4(2*@0+(@1))
	.ENDM

	.MACRO __POINTB2MN
	LDI  R26,LOW(@0+(@1))
	.ENDM

	.MACRO __POINTW2MN
	LDI  R26,LOW(@0+(@1))
	LDI  R27,HIGH(@0+(@1))
	.ENDM

	.MACRO __POINTW2FN
	LDI  R26,LOW(2*@0+(@1))
	LDI  R27,HIGH(2*@0+(@1))
	.ENDM

	.MACRO __POINTD2FN
	LDI  R26,LOW(2*@0+(@1))
	LDI  R27,HIGH(2*@0+(@1))
	LDI  R24,BYTE3(2*@0+(@1))
	LDI  R25,BYTE4(2*@0+(@1))
	.ENDM

	.MACRO __POINTBRM
	LDI  R@0,LOW(@1)
	.ENDM

	.MACRO __POINTWRM
	LDI  R@0,LOW(@2)
	LDI  R@1,HIGH(@2)
	.ENDM

	.MACRO __POINTBRMN
	LDI  R@0,LOW(@1+(@2))
	.ENDM

	.MACRO __POINTWRMN
	LDI  R@0,LOW(@2+(@3))
	LDI  R@1,HIGH(@2+(@3))
	.ENDM

	.MACRO __POINTWRFN
	LDI  R@0,LOW(@2*2+(@3))
	LDI  R@1,HIGH(@2*2+(@3))
	.ENDM

	.MACRO __GETD1N
	LDI  R30,LOW(@0)
	LDI  R31,HIGH(@0)
	LDI  R22,BYTE3(@0)
	LDI  R23,BYTE4(@0)
	.ENDM

	.MACRO __GETD2N
	LDI  R26,LOW(@0)
	LDI  R27,HIGH(@0)
	LDI  R24,BYTE3(@0)
	LDI  R25,BYTE4(@0)
	.ENDM

	.MACRO __GETB1MN
	LDS  R30,@0+(@1)
	.ENDM

	.MACRO __GETB1HMN
	LDS  R31,@0+(@1)
	.ENDM

	.MACRO __GETW1MN
	LDS  R30,@0+(@1)
	LDS  R31,@0+(@1)+1
	.ENDM

	.MACRO __GETD1MN
	LDS  R30,@0+(@1)
	LDS  R31,@0+(@1)+1
	LDS  R22,@0+(@1)+2
	LDS  R23,@0+(@1)+3
	.ENDM

	.MACRO __GETBRMN
	LDS  R@0,@1+(@2)
	.ENDM

	.MACRO __GETWRMN
	LDS  R@0,@2+(@3)
	LDS  R@1,@2+(@3)+1
	.ENDM

	.MACRO __GETWRZ
	LDD  R@0,Z+@2
	LDD  R@1,Z+@2+1
	.ENDM

	.MACRO __GETD2Z
	LDD  R26,Z+@0
	LDD  R27,Z+@0+1
	LDD  R24,Z+@0+2
	LDD  R25,Z+@0+3
	.ENDM

	.MACRO __GETB2MN
	LDS  R26,@0+(@1)
	.ENDM

	.MACRO __GETW2MN
	LDS  R26,@0+(@1)
	LDS  R27,@0+(@1)+1
	.ENDM

	.MACRO __GETD2MN
	LDS  R26,@0+(@1)
	LDS  R27,@0+(@1)+1
	LDS  R24,@0+(@1)+2
	LDS  R25,@0+(@1)+3
	.ENDM

	.MACRO __PUTB1MN
	STS  @0+(@1),R30
	.ENDM

	.MACRO __PUTW1MN
	STS  @0+(@1),R30
	STS  @0+(@1)+1,R31
	.ENDM

	.MACRO __PUTD1MN
	STS  @0+(@1),R30
	STS  @0+(@1)+1,R31
	STS  @0+(@1)+2,R22
	STS  @0+(@1)+3,R23
	.ENDM

	.MACRO __PUTB1EN
	LDI  R26,LOW(@0+(@1))
	LDI  R27,HIGH(@0+(@1))
	CALL __EEPROMWRB
	.ENDM

	.MACRO __PUTW1EN
	LDI  R26,LOW(@0+(@1))
	LDI  R27,HIGH(@0+(@1))
	CALL __EEPROMWRW
	.ENDM

	.MACRO __PUTD1EN
	LDI  R26,LOW(@0+(@1))
	LDI  R27,HIGH(@0+(@1))
	CALL __EEPROMWRD
	.ENDM

	.MACRO __PUTBR0MN
	STS  @0+(@1),R0
	.ENDM

	.MACRO __PUTBMRN
	STS  @0+(@1),R@2
	.ENDM

	.MACRO __PUTWMRN
	STS  @0+(@1),R@2
	STS  @0+(@1)+1,R@3
	.ENDM

	.MACRO __PUTBZR
	STD  Z+@1,R@0
	.ENDM

	.MACRO __PUTWZR
	STD  Z+@2,R@0
	STD  Z+@2+1,R@1
	.ENDM

	.MACRO __GETW1R
	MOV  R30,R@0
	MOV  R31,R@1
	.ENDM

	.MACRO __GETW2R
	MOV  R26,R@0
	MOV  R27,R@1
	.ENDM

	.MACRO __GETWRN
	LDI  R@0,LOW(@2)
	LDI  R@1,HIGH(@2)
	.ENDM

	.MACRO __PUTW1R
	MOV  R@0,R30
	MOV  R@1,R31
	.ENDM

	.MACRO __PUTW2R
	MOV  R@0,R26
	MOV  R@1,R27
	.ENDM

	.MACRO __ADDWRN
	SUBI R@0,LOW(-@2)
	SBCI R@1,HIGH(-@2)
	.ENDM

	.MACRO __ADDWRR
	ADD  R@0,R@2
	ADC  R@1,R@3
	.ENDM

	.MACRO __SUBWRN
	SUBI R@0,LOW(@2)
	SBCI R@1,HIGH(@2)
	.ENDM

	.MACRO __SUBWRR
	SUB  R@0,R@2
	SBC  R@1,R@3
	.ENDM

	.MACRO __ANDWRN
	ANDI R@0,LOW(@2)
	ANDI R@1,HIGH(@2)
	.ENDM

	.MACRO __ANDWRR
	AND  R@0,R@2
	AND  R@1,R@3
	.ENDM

	.MACRO __ORWRN
	ORI  R@0,LOW(@2)
	ORI  R@1,HIGH(@2)
	.ENDM

	.MACRO __ORWRR
	OR   R@0,R@2
	OR   R@1,R@3
	.ENDM

	.MACRO __EORWRR
	EOR  R@0,R@2
	EOR  R@1,R@3
	.ENDM

	.MACRO __GETWRS
	LDD  R@0,Y+@2
	LDD  R@1,Y+@2+1
	.ENDM

	.MACRO __PUTBSR
	STD  Y+@1,R@0
	.ENDM

	.MACRO __PUTWSR
	STD  Y+@2,R@0
	STD  Y+@2+1,R@1
	.ENDM

	.MACRO __MOVEWRR
	MOV  R@0,R@2
	MOV  R@1,R@3
	.ENDM

	.MACRO __INWR
	IN   R@0,@2
	IN   R@1,@2+1
	.ENDM

	.MACRO __OUTWR
	OUT  @2+1,R@1
	OUT  @2,R@0
	.ENDM

	.MACRO __CALL1MN
	LDS  R30,@0+(@1)
	LDS  R31,@0+(@1)+1
	ICALL
	.ENDM

	.MACRO __CALL1FN
	LDI  R30,LOW(2*@0+(@1))
	LDI  R31,HIGH(2*@0+(@1))
	CALL __GETW1PF
	ICALL
	.ENDM

	.MACRO __CALL2EN
	PUSH R26
	PUSH R27
	LDI  R26,LOW(@0+(@1))
	LDI  R27,HIGH(@0+(@1))
	CALL __EEPROMRDW
	POP  R27
	POP  R26
	ICALL
	.ENDM

	.MACRO __CALL2EX
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	CALL __EEPROMRDD
	ICALL
	.ENDM

	.MACRO __GETW1STACK
	IN   R30,SPL
	IN   R31,SPH
	ADIW R30,@0+1
	LD   R0,Z+
	LD   R31,Z
	MOV  R30,R0
	.ENDM

	.MACRO __GETD1STACK
	IN   R30,SPL
	IN   R31,SPH
	ADIW R30,@0+1
	LD   R0,Z+
	LD   R1,Z+
	LD   R22,Z
	MOVW R30,R0
	.ENDM

	.MACRO __NBST
	BST  R@0,@1
	IN   R30,SREG
	LDI  R31,0x40
	EOR  R30,R31
	OUT  SREG,R30
	.ENDM


	.MACRO __PUTB1SN
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1SN
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1SN
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1SNS
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	ADIW R26,@1
	ST   X,R30
	.ENDM

	.MACRO __PUTW1SNS
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	ADIW R26,@1
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1SNS
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	ADIW R26,@1
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1PMN
	LDS  R26,@0
	LDS  R27,@0+1
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1PMN
	LDS  R26,@0
	LDS  R27,@0+1
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1PMN
	LDS  R26,@0
	LDS  R27,@0+1
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1PMNS
	LDS  R26,@0
	LDS  R27,@0+1
	ADIW R26,@1
	ST   X,R30
	.ENDM

	.MACRO __PUTW1PMNS
	LDS  R26,@0
	LDS  R27,@0+1
	ADIW R26,@1
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1PMNS
	LDS  R26,@0
	LDS  R27,@0+1
	ADIW R26,@1
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1RN
	MOVW R26,R@0
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1RN
	MOVW R26,R@0
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1RN
	MOVW R26,R@0
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1RNS
	MOVW R26,R@0
	ADIW R26,@1
	ST   X,R30
	.ENDM

	.MACRO __PUTW1RNS
	MOVW R26,R@0
	ADIW R26,@1
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1RNS
	MOVW R26,R@0
	ADIW R26,@1
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1RON
	MOV  R26,R@0
	MOV  R27,R@1
	SUBI R26,LOW(-@2)
	SBCI R27,HIGH(-@2)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1RON
	MOV  R26,R@0
	MOV  R27,R@1
	SUBI R26,LOW(-@2)
	SBCI R27,HIGH(-@2)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1RON
	MOV  R26,R@0
	MOV  R27,R@1
	SUBI R26,LOW(-@2)
	SBCI R27,HIGH(-@2)
	CALL __PUTDP1
	.ENDM

	.MACRO __PUTB1RONS
	MOV  R26,R@0
	MOV  R27,R@1
	ADIW R26,@2
	ST   X,R30
	.ENDM

	.MACRO __PUTW1RONS
	MOV  R26,R@0
	MOV  R27,R@1
	ADIW R26,@2
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1RONS
	MOV  R26,R@0
	MOV  R27,R@1
	ADIW R26,@2
	CALL __PUTDP1
	.ENDM


	.MACRO __GETB1SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R30,Z
	.ENDM

	.MACRO __GETB1HSX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R31,Z
	.ENDM

	.MACRO __GETW1SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R0,Z+
	LD   R31,Z
	MOV  R30,R0
	.ENDM

	.MACRO __GETD1SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R0,Z+
	LD   R1,Z+
	LD   R22,Z+
	LD   R23,Z
	MOVW R30,R0
	.ENDM

	.MACRO __GETB2SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R26,X
	.ENDM

	.MACRO __GETW2SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R27,X
	MOV  R26,R0
	.ENDM

	.MACRO __GETD2SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R1,X+
	LD   R24,X+
	LD   R25,X
	MOVW R26,R0
	.ENDM

	.MACRO __GETBRSX
	MOVW R30,R28
	SUBI R30,LOW(-@1)
	SBCI R31,HIGH(-@1)
	LD   R@0,Z
	.ENDM

	.MACRO __GETWRSX
	MOVW R30,R28
	SUBI R30,LOW(-@2)
	SBCI R31,HIGH(-@2)
	LD   R@0,Z+
	LD   R@1,Z
	.ENDM

	.MACRO __GETBRSX2
	MOVW R26,R28
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	LD   R@0,X
	.ENDM

	.MACRO __GETWRSX2
	MOVW R26,R28
	SUBI R26,LOW(-@2)
	SBCI R27,HIGH(-@2)
	LD   R@0,X+
	LD   R@1,X
	.ENDM

	.MACRO __LSLW8SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R31,Z
	CLR  R30
	.ENDM

	.MACRO __PUTB1SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X+,R30
	ST   X+,R31
	ST   X+,R22
	ST   X,R23
	.ENDM

	.MACRO __CLRW1SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X+,R30
	ST   X,R30
	.ENDM

	.MACRO __CLRD1SX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X+,R30
	ST   X+,R30
	ST   X+,R30
	ST   X,R30
	.ENDM

	.MACRO __PUTB2SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z,R26
	.ENDM

	.MACRO __PUTW2SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z+,R26
	ST   Z,R27
	.ENDM

	.MACRO __PUTD2SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z+,R26
	ST   Z+,R27
	ST   Z+,R24
	ST   Z,R25
	.ENDM

	.MACRO __PUTBSRX
	MOVW R30,R28
	SUBI R30,LOW(-@1)
	SBCI R31,HIGH(-@1)
	ST   Z,R@0
	.ENDM

	.MACRO __PUTWSRX
	MOVW R30,R28
	SUBI R30,LOW(-@2)
	SBCI R31,HIGH(-@2)
	ST   Z+,R@0
	ST   Z,R@1
	.ENDM

	.MACRO __PUTB1SNX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R27,X
	MOV  R26,R0
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1SNX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R27,X
	MOV  R26,R0
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1SNX
	MOVW R26,R28
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R27,X
	MOV  R26,R0
	SUBI R26,LOW(-@1)
	SBCI R27,HIGH(-@1)
	ST   X+,R30
	ST   X+,R31
	ST   X+,R22
	ST   X,R23
	.ENDM

	.MACRO __MULBRR
	MULS R@0,R@1
	MOVW R30,R0
	.ENDM

	.MACRO __MULBRRU
	MUL  R@0,R@1
	MOVW R30,R0
	.ENDM

	.MACRO __MULBRR0
	MULS R@0,R@1
	.ENDM

	.MACRO __MULBRRU0
	MUL  R@0,R@1
	.ENDM

	.MACRO __MULBNWRU
	LDI  R26,@2
	MUL  R26,R@0
	MOVW R30,R0
	MUL  R26,R@1
	ADD  R31,R0
	.ENDM

;NAME DEFINITIONS FOR GLOBAL VARIABLES ALLOCATED TO REGISTERS
	.DEF _ESP_BufferIndex=R5
	.DEF __lcd_x=R4
	.DEF __lcd_y=R7
	.DEF __lcd_maxx=R6

	.CSEG
	.ORG 0x00

;START OF CODE MARKER
__START_OF_CODE:

;INTERRUPT VECTORS
	JMP  __RESET
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  _usart_rx_isr
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  0x00
	JMP  _ESP_CheckIRQ
	JMP  0x00

_ESP_Answer_OK:
	.DB  0x4F,0x4B,0xD,0x0
_ESP_Answer_Fail:
	.DB  0x46,0x61,0x69,0x6C,0xD,0x0
_ESP_Answer_Error:
	.DB  0x45,0x52,0x52,0x4F,0x52,0xD,0x0
_ESP_Answer_Diconnected:
	.DB  0x57,0x49,0x46,0x49,0x20,0x44,0x49,0x53
	.DB  0x43,0x4F,0x4E,0x4E,0x45,0x43,0x54,0xD
	.DB  0x0
_ESP_Answer_Connected:
	.DB  0x57,0x49,0x46,0x49,0x20,0x43,0x4F,0x4E
	.DB  0x4E,0x45,0x43,0x54,0x45,0x44,0xD,0x0
_ESP_Answer_ReceiveData:
	.DB  0x2B,0x49,0x50,0x44,0x2C,0x0
_ESP_Answer_GotIP:
	.DB  0x57,0x49,0x46,0x49,0x20,0x47,0x4F,0x54
	.DB  0x20,0x49,0x50,0xD,0x0
_ESP_Answer_TCP_Connect:
	.DB  0x43,0x4F,0x4E,0x4E,0x45,0x43,0x54,0xD
	.DB  0x0
_ESP_Answer_TCP_Close:
	.DB  0x43,0x4C,0x4F,0x53,0x45,0xD,0x0

;GLOBAL REGISTER VARIABLES INITIALIZATION
__REG_VARS:
	.DB  0x0

_0x0:
	.DB  0x54,0x65,0x73,0x74,0x0,0x4D,0x72,0x43
	.DB  0x72,0x61,0x7A,0x79,0x28,0x4D,0x6F,0x62
	.DB  0x69,0x6C,0x65,0x29,0x0,0x40,0x75,0x72
	.DB  0x53,0x65,0x72,0x76,0x69,0x63,0x65,0x32
	.DB  0x30,0x32,0x30,0x0,0x31,0x39,0x32,0x2E
	.DB  0x31,0x36,0x38,0x2E,0x34,0x33,0x2E,0x32
	.DB  0x35,0x30,0x0
_0x20003:
	.DB  0xFF
_0x20000:
	.DB  0x41,0x54,0xD,0xA,0x0,0x41,0x54,0x45
	.DB  0x0,0x41,0x54,0x2B,0x52,0x53,0x54,0xD
	.DB  0xA,0x0,0x41,0x54,0x2B,0x43,0x57,0x4D
	.DB  0x4F,0x44,0x45,0x3D,0x0,0x41,0x54,0x2B
	.DB  0x43,0x57,0x51,0x41,0x50,0xD,0xA,0x0
	.DB  0x41,0x54,0x2B,0x43,0x57,0x4A,0x41,0x50
	.DB  0x3D,0x22,0x0,0x22,0x2C,0x22,0x0,0x22
	.DB  0xD,0xA,0x0,0x41,0x54,0x2B,0x43,0x57
	.DB  0x53,0x41,0x50,0x3D,0x22,0x0,0x22,0x2C
	.DB  0x31,0x2C,0x0,0x30,0xD,0xA,0x0,0x33
	.DB  0xD,0xA,0x0,0x41,0x54,0x2B,0x43,0x49
	.DB  0x50,0x53,0x54,0x41,0x4D,0x41,0x43,0x3D
	.DB  0x22,0x0,0x41,0x54,0x2B,0x43,0x49,0x50
	.DB  0x41,0x50,0x4D,0x41,0x43,0x3D,0x22,0x0
	.DB  0x41,0x54,0x2B,0x43,0x49,0x50,0x53,0x54
	.DB  0x41,0x3D,0x22,0x0,0x41,0x54,0x2B,0x43
	.DB  0x49,0x50,0x41,0x50,0x3D,0x22,0x0,0x41
	.DB  0x54,0x2B,0x43,0x49,0x50,0x53,0x54,0x41
	.DB  0x52,0x54,0x3D,0x0,0x22,0x54,0x43,0x50
	.DB  0x22,0x2C,0x22,0x0,0x22,0x2C,0x0,0x41
	.DB  0x54,0x2B,0x43,0x49,0x50,0x53,0x45,0x4E
	.DB  0x44,0x3D,0x0,0x41,0x54,0x2B,0x43,0x49
	.DB  0x50,0x43,0x4C,0x4F,0x53,0x45,0xD,0xA
	.DB  0x0,0x41,0x54,0x2B,0x43,0x49,0x50,0x4D
	.DB  0x55,0x58,0x3D,0x0,0x41,0x54,0x2B,0x43
	.DB  0x49,0x50,0x53,0x45,0x52,0x56,0x45,0x52
	.DB  0x3D,0x31,0x2C,0x22,0x0
_0x2000060:
	.DB  0x1
_0x2000000:
	.DB  0x2D,0x4E,0x41,0x4E,0x0,0x49,0x4E,0x46
	.DB  0x0
_0x2040003:
	.DB  0x80,0xC0

__GLOBAL_INI_TBL:
	.DW  0x01
	.DW  0x05
	.DW  __REG_VARS*2

	.DW  0x10
	.DW  _0x4
	.DW  _0x0*2+5

	.DW  0x0F
	.DW  _0x4+16
	.DW  _0x0*2+21

	.DW  0x0F
	.DW  _0x4+31
	.DW  _0x0*2+36

	.DW  0x01
	.DW  _ESP_LastAnswer
	.DW  _0x20003*2

	.DW  0x05
	.DW  _0x20005
	.DW  _0x20000*2

	.DW  0x04
	.DW  _0x20009
	.DW  _0x20000*2+5

	.DW  0x03
	.DW  _0x20009+4
	.DW  _0x20000*2+2

	.DW  0x09
	.DW  _0x2000D
	.DW  _0x20000*2+9

	.DW  0x0B
	.DW  _0x2000E
	.DW  _0x20000*2+18

	.DW  0x03
	.DW  _0x2000E+11
	.DW  _0x20000*2+2

	.DW  0x0B
	.DW  _0x20012
	.DW  _0x20000*2+29

	.DW  0x0B
	.DW  _0x20016
	.DW  _0x20000*2+40

	.DW  0x04
	.DW  _0x20016+11
	.DW  _0x20000*2+51

	.DW  0x04
	.DW  _0x20016+15
	.DW  _0x20000*2+55

	.DW  0x0B
	.DW  _0x2001A
	.DW  _0x20000*2+59

	.DW  0x04
	.DW  _0x2001A+11
	.DW  _0x20000*2+51

	.DW  0x05
	.DW  _0x2001A+15
	.DW  _0x20000*2+70

	.DW  0x04
	.DW  _0x2001A+20
	.DW  _0x20000*2+75

	.DW  0x04
	.DW  _0x2001A+24
	.DW  _0x20000*2+79

	.DW  0x0F
	.DW  _0x20020
	.DW  _0x20000*2+83

	.DW  0x04
	.DW  _0x20020+15
	.DW  _0x20000*2+55

	.DW  0x0E
	.DW  _0x20024
	.DW  _0x20000*2+98

	.DW  0x04
	.DW  _0x20024+14
	.DW  _0x20000*2+55

	.DW  0x0C
	.DW  _0x20028
	.DW  _0x20000*2+112

	.DW  0x04
	.DW  _0x20028+12
	.DW  _0x20000*2+55

	.DW  0x0B
	.DW  _0x2002C
	.DW  _0x20000*2+124

	.DW  0x04
	.DW  _0x2002C+11
	.DW  _0x20000*2+55

	.DW  0x0D
	.DW  _0x20030
	.DW  _0x20000*2+135

	.DW  0x08
	.DW  _0x20030+13
	.DW  _0x20000*2+148

	.DW  0x03
	.DW  _0x20030+21
	.DW  _0x20000*2+156

	.DW  0x03
	.DW  _0x20030+24
	.DW  _0x20000*2+2

	.DW  0x0C
	.DW  _0x20034
	.DW  _0x20000*2+159

	.DW  0x03
	.DW  _0x20034+12
	.DW  _0x20000*2+2

	.DW  0x0E
	.DW  _0x2003E
	.DW  _0x20000*2+171

	.DW  0x0B
	.DW  _0x20042
	.DW  _0x20000*2+185

	.DW  0x03
	.DW  _0x20042+11
	.DW  _0x20000*2+2

	.DW  0x11
	.DW  _0x20046
	.DW  _0x20000*2+196

	.DW  0x04
	.DW  _0x20046+17
	.DW  _0x20000*2+55

	.DW  0x01
	.DW  __seed_G100
	.DW  _0x2000060*2

	.DW  0x02
	.DW  __base_y_G102
	.DW  _0x2040003*2

_0xFFFFFFFF:
	.DW  0

#define __GLOBAL_INI_TBL_PRESENT 1

__RESET:
	CLI
	CLR  R30
	OUT  EECR,R30

;INTERRUPT VECTORS ARE PLACED
;AT THE START OF FLASH
	LDI  R31,1
	OUT  GICR,R31
	OUT  GICR,R30
	OUT  MCUCR,R30

;CLEAR R2-R14
	LDI  R24,(14-2)+1
	LDI  R26,2
	CLR  R27
__CLEAR_REG:
	ST   X+,R30
	DEC  R24
	BRNE __CLEAR_REG

;CLEAR SRAM
	LDI  R24,LOW(__CLEAR_SRAM_SIZE)
	LDI  R25,HIGH(__CLEAR_SRAM_SIZE)
	LDI  R26,__SRAM_START
__CLEAR_SRAM:
	ST   X+,R30
	SBIW R24,1
	BRNE __CLEAR_SRAM

;GLOBAL VARIABLES INITIALIZATION
	LDI  R30,LOW(__GLOBAL_INI_TBL*2)
	LDI  R31,HIGH(__GLOBAL_INI_TBL*2)
__GLOBAL_INI_NEXT:
	LPM  R24,Z+
	LPM  R25,Z+
	SBIW R24,0
	BREQ __GLOBAL_INI_END
	LPM  R26,Z+
	LPM  R27,Z+
	LPM  R0,Z+
	LPM  R1,Z+
	MOVW R22,R30
	MOVW R30,R0
__GLOBAL_INI_LOOP:
	LPM  R0,Z+
	ST   X+,R0
	SBIW R24,1
	BRNE __GLOBAL_INI_LOOP
	MOVW R30,R22
	RJMP __GLOBAL_INI_NEXT
__GLOBAL_INI_END:

;HARDWARE STACK POINTER INITIALIZATION
	LDI  R30,LOW(__SRAM_END-__HEAP_SIZE)
	OUT  SPL,R30
	LDI  R30,HIGH(__SRAM_END-__HEAP_SIZE)
	OUT  SPH,R30

;DATA STACK POINTER INITIALIZATION
	LDI  R28,LOW(__SRAM_START+__DSTACK_SIZE)
	LDI  R29,HIGH(__SRAM_START+__DSTACK_SIZE)

	JMP  _main

	.ESEG
	.ORG 0

	.DSEG
	.ORG 0x160

	.CSEG
;#include <io.h>
	#ifndef __SLEEP_DEFINED__
	#define __SLEEP_DEFINED__
	.EQU __se_bit=0x40
	.EQU __sm_mask=0xB0
	.EQU __sm_powerdown=0x20
	.EQU __sm_powersave=0x30
	.EQU __sm_standby=0xA0
	.EQU __sm_ext_standby=0xB0
	.EQU __sm_adc_noise_red=0x10
	.SET power_ctrl_reg=mcucr
	#endif
;#include "ESP8266.h"
;#include "USART.h"
;#include <stdlib.h>
;#include <string.h>
;// Alphanumeric LCD functions
;#include <alcd.h>
;
;// Declare your global variables here
;
;#define DATA_REGISTER_EMPTY (1<<UDRE)
;#define RX_COMPLETE (1<<RXC)
;#define FRAMING_ERROR (1<<FE)
;#define PARITY_ERROR (1<<UPE)
;#define DATA_OVERRUN (1<<DOR)
;
;// USART Receiver interrupt service routine
;interrupt [USART_RXC] void usart_rx_isr(void)
; 0000 0013 {

	.CSEG
_usart_rx_isr:
; .FSTART _usart_rx_isr
	ST   -Y,R0
	ST   -Y,R1
	ST   -Y,R15
	ST   -Y,R22
	ST   -Y,R23
	ST   -Y,R24
	ST   -Y,R25
	ST   -Y,R26
	ST   -Y,R27
	ST   -Y,R30
	ST   -Y,R31
	IN   R30,SREG
	ST   -Y,R30
; 0000 0014 char status,data;
; 0000 0015 status=UCSRA;
	ST   -Y,R17
	ST   -Y,R16
;	status -> R17
;	data -> R16
	IN   R17,11
; 0000 0016 data=UDR;
	IN   R16,12
; 0000 0017 if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
	MOV  R30,R17
	ANDI R30,LOW(0x1C)
	BRNE _0x3
; 0000 0018    {
; 0000 0019     ESP_AppendChar(data);
	MOV  R26,R16
	RCALL _ESP_AppendChar
; 0000 001A    }
; 0000 001B }
_0x3:
	LD   R16,Y+
	LD   R17,Y+
	LD   R30,Y+
	OUT  SREG,R30
	LD   R31,Y+
	LD   R30,Y+
	LD   R27,Y+
	LD   R26,Y+
	LD   R25,Y+
	LD   R24,Y+
	LD   R23,Y+
	LD   R22,Y+
	LD   R15,Y+
	LD   R1,Y+
	LD   R0,Y+
	RETI
; .FEND
;
;interrupt [TIM0_COMP] void ESP_CheckIRQ(void){
; 0000 001D interrupt [20] void ESP_CheckIRQ(void){
_ESP_CheckIRQ:
; .FSTART _ESP_CheckIRQ
	ST   -Y,R0
	ST   -Y,R1
	ST   -Y,R15
	ST   -Y,R22
	ST   -Y,R23
	ST   -Y,R24
	ST   -Y,R25
	ST   -Y,R26
	ST   -Y,R27
	ST   -Y,R30
	ST   -Y,R31
	IN   R30,SREG
	ST   -Y,R30
; 0000 001E     ESP_CheckAnswer();
	RCALL _ESP_CheckAnswer
; 0000 001F }
	LD   R30,Y+
	OUT  SREG,R30
	LD   R31,Y+
	LD   R30,Y+
	LD   R27,Y+
	LD   R26,Y+
	LD   R25,Y+
	LD   R24,Y+
	LD   R23,Y+
	LD   R22,Y+
	LD   R15,Y+
	LD   R1,Y+
	LD   R0,Y+
	RETI
; .FEND
;
;void main(void)
; 0000 0022 {
_main:
; .FSTART _main
; 0000 0023 char TempBuffer[16];
; 0000 0024 
; 0000 0025 // Timer/Counter 0 initialization
; 0000 0026 // Clock source: System Clock
; 0000 0027 // Clock value: 7.813 kHz
; 0000 0028 // Mode: CTC top=OCR0
; 0000 0029 // OC0 output: Disconnected
; 0000 002A // Timer Period: 29.952 ms
; 0000 002B TCCR0=(0<<WGM00) | (0<<COM01) | (0<<COM00) | (1<<WGM01) | (1<<CS02) | (0<<CS01) | (1<<CS00);
	SBIW R28,16
;	TempBuffer -> Y+0
	LDI  R30,LOW(13)
	OUT  0x33,R30
; 0000 002C TCNT0=0x00;
	LDI  R30,LOW(0)
	OUT  0x32,R30
; 0000 002D OCR0=0xE9;
	LDI  R30,LOW(233)
	OUT  0x3C,R30
; 0000 002E 
; 0000 002F // Timer(s)/Counter(s) Interrupt(s) initialization
; 0000 0030 TIMSK=(0<<OCIE2) | (0<<TOIE2) | (0<<TICIE1) | (0<<OCIE1A) | (0<<OCIE1B) | (0<<TOIE1) | (1<<OCIE0) | (0<<TOIE0);
	LDI  R30,LOW(2)
	OUT  0x39,R30
; 0000 0031 
; 0000 0032 // USART initialization
; 0000 0033 // Communication Parameters: 8 Data, 1 Stop, No Parity
; 0000 0034 // USART Receiver: On
; 0000 0035 // USART Transmitter: On
; 0000 0036 // USART Mode: Asynchronous
; 0000 0037 // USART Baud Rate: 9600
; 0000 0038 UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
	LDI  R30,LOW(0)
	OUT  0xB,R30
; 0000 0039 UCSRB=(1<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
	LDI  R30,LOW(152)
	OUT  0xA,R30
; 0000 003A UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
	LDI  R30,LOW(134)
	OUT  0x20,R30
; 0000 003B UBRRH=0x00;
	LDI  R30,LOW(0)
	OUT  0x20,R30
; 0000 003C UBRRL=0x33;
	LDI  R30,LOW(51)
	OUT  0x9,R30
; 0000 003D 
; 0000 003E // Alphanumeric LCD initialization
; 0000 003F // Connections are specified in the
; 0000 0040 // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
; 0000 0041 // RS - PORTA Bit 0
; 0000 0042 // RD - PORTA Bit 1
; 0000 0043 // EN - PORTA Bit 2
; 0000 0044 // D4 - PORTA Bit 4
; 0000 0045 // D5 - PORTA Bit 5
; 0000 0046 // D6 - PORTA Bit 6
; 0000 0047 // D7 - PORTA Bit 7
; 0000 0048 // Characters/line: 16
; 0000 0049 lcd_init(16);
	LDI  R26,LOW(16)
	CALL _lcd_init
; 0000 004A 
; 0000 004B ESP_Init();
	RCALL _ESP_Init
; 0000 004C 
; 0000 004D lcd_putsf("Test");
	__POINTW2FN _0x0,0
	CALL _lcd_putsf
; 0000 004E lcd_gotoxy(0, 1);
	LDI  R30,LOW(0)
	ST   -Y,R30
	LDI  R26,LOW(1)
	CALL _lcd_gotoxy
; 0000 004F lcd_putsf(ESP_StaticStrs.Strs[ESP_Ok]);
	LDS  R26,_ESP_StaticStrs
	LDS  R27,_ESP_StaticStrs+1
	CALL _lcd_putsf
; 0000 0050 
; 0000 0051 // Global enable interrupts
; 0000 0052 #asm("sei")
	sei
; 0000 0053 
; 0000 0054 ESP_Echo(ESP_Echo_Off);
	LDI  R26,LOW(0)
	RCALL _ESP_Echo
; 0000 0055 ESP_WiFiMode(ESP_Station);
	LDI  R26,LOW(1)
	RCALL _ESP_WiFiMode
; 0000 0056 ESP_Connect("MrCrazy(Mobile)","@urService2020");
	__POINTW1MN _0x4,0
	ST   -Y,R31
	ST   -Y,R30
	__POINTW2MN _0x4,16
	RCALL _ESP_Connect
; 0000 0057 ESP_TCPConnect("192.168.43.250",8585);
	__POINTW1MN _0x4,31
	ST   -Y,R31
	ST   -Y,R30
	LDI  R26,LOW(8585)
	LDI  R27,HIGH(8585)
	RCALL _ESP_TCPConnect
; 0000 0058 
; 0000 0059 
; 0000 005A //USART_PutS("Hello");
; 0000 005B 
; 0000 005C while (1)
_0x5:
; 0000 005D       {
; 0000 005E         if(ESP_Flags.DataReceived){
	LDS  R30,_ESP_Flags
	ANDI R30,LOW(0x80)
	BREQ _0x8
; 0000 005F 			    strncpy(TempBuffer, (char*)ESP_ReceiveData, ESP_ReceiveData_Index);
	MOVW R30,R28
	ST   -Y,R31
	ST   -Y,R30
	LDI  R30,LOW(_ESP_ReceiveData)
	LDI  R31,HIGH(_ESP_ReceiveData)
	ST   -Y,R31
	ST   -Y,R30
	LDS  R26,_ESP_ReceiveData_Index
	CALL _strncpy
; 0000 0060           TempBuffer[ESP_ReceiveData_Index] = '\0';
	LDS  R30,_ESP_ReceiveData_Index
	LDS  R31,_ESP_ReceiveData_Index+1
	MOVW R26,R28
	ADD  R26,R30
	ADC  R27,R31
	LDI  R30,LOW(0)
	ST   X,R30
; 0000 0061 			    ESP_TCPSendData((uint8_t*)TempBuffer,ESP_ReceiveData_Index);
	MOVW R30,R28
	ST   -Y,R31
	ST   -Y,R30
	LDS  R26,_ESP_ReceiveData_Index
	LDS  R27,_ESP_ReceiveData_Index+1
	RCALL _ESP_TCPSendData
; 0000 0062 			    ESP_ReleaseReceiveBuffer();
	RCALL _ESP_ReleaseReceiveBuffer
; 0000 0063           lcd_clear();
	CALL _lcd_clear
; 0000 0064           lcd_puts(TempBuffer);
	MOVW R26,R28
	CALL _lcd_puts
; 0000 0065 		    }
; 0000 0066       }
_0x8:
	RJMP _0x5
; 0000 0067 }
_0x9:
	RJMP _0x9
; .FEND

	.DSEG
_0x4:
	.BYTE 0x2E
;
;void USART_PutChar(char c){
; 0000 0069 void USART_PutChar(char c){

	.CSEG
_USART_PutChar:
; .FSTART _USART_PutChar
; 0000 006A     USART_PutByte(c);
	ST   -Y,R26
;	c -> Y+0
	LD   R26,Y
	RCALL _USART_PutByte
; 0000 006B }
	JMP  _0x20A0001
; .FEND
;void USART_PutByte(unsigned char c){
; 0000 006C void USART_PutByte(unsigned char c){
_USART_PutByte:
; .FSTART _USART_PutByte
; 0000 006D     while ((UCSRA & (1 << UDRE)) == 0){}
	ST   -Y,R26
;	c -> Y+0
_0xA:
	SBIS 0xB,5
	RJMP _0xA
; 0000 006E     UDR = c;
	LD   R30,Y
	OUT  0xC,R30
; 0000 006F }
	JMP  _0x20A0001
; .FEND
;void USART_PutS(char* str){
; 0000 0070 void USART_PutS(char* str){
_USART_PutS:
; .FSTART _USART_PutS
; 0000 0071     while (*str != 0){
	ST   -Y,R27
	ST   -Y,R26
;	*str -> Y+0
_0xD:
	LD   R26,Y
	LDD  R27,Y+1
	LD   R30,X
	CPI  R30,0
	BREQ _0xF
; 0000 0072         USART_PutChar(*str++);
	LD   R30,X+
	ST   Y,R26
	STD  Y+1,R27
	MOV  R26,R30
	RCALL _USART_PutChar
; 0000 0073     }
	RJMP _0xD
_0xF:
; 0000 0074 }
	JMP  _0x20A0004
; .FEND
;void USART_PutN(int num){
; 0000 0075 void USART_PutN(int num){
_USART_PutN:
; .FSTART _USART_PutN
; 0000 0076     char Temp[7];
; 0000 0077     itoa(num, Temp);
	ST   -Y,R27
	ST   -Y,R26
	SBIW R28,7
;	num -> Y+7
;	Temp -> Y+0
	LDD  R30,Y+7
	LDD  R31,Y+7+1
	ST   -Y,R31
	ST   -Y,R30
	MOVW R26,R28
	ADIW R26,2
	CALL _itoa
; 0000 0078     USART_PutS(Temp);
	MOVW R26,R28
	RCALL _USART_PutS
; 0000 0079 }
	ADIW R28,9
	RET
; .FEND
;void USART_PutData(unsigned char* data, unsigned char length){
; 0000 007A void USART_PutData(unsigned char* data, unsigned char length){
_USART_PutData:
; .FSTART _USART_PutData
; 0000 007B     while (length--){
	ST   -Y,R26
;	*data -> Y+1
;	length -> Y+0
_0x10:
	LD   R30,Y
	SUBI R30,LOW(1)
	ST   Y,R30
	SUBI R30,-LOW(1)
	BREQ _0x12
; 0000 007C         USART_PutByte(*data++);
	LDD  R26,Y+1
	LDD  R27,Y+1+1
	LD   R30,X+
	STD  Y+1,R26
	STD  Y+1+1,R27
	MOV  R26,R30
	RCALL _USART_PutByte
; 0000 007D     }
	RJMP _0x10
_0x12:
; 0000 007E }
	JMP  _0x20A0003
; .FEND
;#include "ESP8266.h"
;#include "USART.h"
;
;ESP_flags ESP_Flags = {0};
;ESP_Answer ESP_LastAnswer = ESP_Nothing;

	.DSEG
;ESP_StrFinderDesc ESP_StaticStrs = {0};
;
;uint8_t ESP_BufferIndex = 0;
;uint8_t ESP_Buffer[ESP_BufferSize];
;
;uint16_t ESP_SearchIndex = 0;
;
;uint8_t  ESP_ReceiveData[ESP_ReceiveBufferSize];
;uint16_t ESP_ReceiveData_Index = 0;
;
;const char ESP_Answer_OK[]   		= "OK\r";
;const char ESP_Answer_Fail[] 		= "Fail\r";
;const char ESP_Answer_Error[] 		= "ERROR\r";
;const char ESP_Answer_Diconnected[] = "WIFI DISCONNECT\r";
;const char ESP_Answer_Connected[] 	= "WIFI CONNECTED\r";
;const char ESP_Answer_ReceiveData[] = "+IPD,";
;const char ESP_Answer_GotIP[] 		= "WIFI GOT IP\r";
;const char ESP_Answer_TCP_Connect[] = "CONNECT\r";
;const char ESP_Answer_TCP_Close[]   = "CLOSE\r";
;
;void ESP_Init(void)
; 0001 001B {

	.CSEG
_ESP_Init:
; .FSTART _ESP_Init
; 0001 001C 	//set ESP_StaticStrs
; 0001 001D 	// ESP_Ok == 0
; 0001 001E 	ESP_StaticStrs.Strs[ESP_Ok] = ESP_Answer_OK;
	LDI  R30,LOW(_ESP_Answer_OK*2)
	LDI  R31,HIGH(_ESP_Answer_OK*2)
	STS  _ESP_StaticStrs,R30
	STS  _ESP_StaticStrs+1,R31
; 0001 001F 	// ESP_Fail == 1
; 0001 0020 	ESP_StaticStrs.Strs[ESP_Fail] = ESP_Answer_Fail;
	__POINTW2MN _ESP_StaticStrs,2
	LDI  R30,LOW(_ESP_Answer_Fail*2)
	LDI  R31,HIGH(_ESP_Answer_Fail*2)
	ST   X+,R30
	ST   X,R31
; 0001 0021 	// ESP_Error  == 2
; 0001 0022 	ESP_StaticStrs.Strs[ESP_Error] = ESP_Answer_Error;
	__POINTW2MN _ESP_StaticStrs,4
	LDI  R30,LOW(_ESP_Answer_Error*2)
	LDI  R31,HIGH(_ESP_Answer_Error*2)
	ST   X+,R30
	ST   X,R31
; 0001 0023 	// ESP_Disconncted == 3
; 0001 0024 	ESP_StaticStrs.Strs[ESP_Disconnected] = ESP_Answer_Diconnected;
	__POINTW2MN _ESP_StaticStrs,6
	LDI  R30,LOW(_ESP_Answer_Diconnected*2)
	LDI  R31,HIGH(_ESP_Answer_Diconnected*2)
	ST   X+,R30
	ST   X,R31
; 0001 0025 	// ESP_Connected == 4
; 0001 0026 	ESP_StaticStrs.Strs[ESP_Connected] = ESP_Answer_Connected;
	__POINTW2MN _ESP_StaticStrs,8
	LDI  R30,LOW(_ESP_Answer_Connected*2)
	LDI  R31,HIGH(_ESP_Answer_Connected*2)
	ST   X+,R30
	ST   X,R31
; 0001 0027 	// ESP_ReceiveData == 5
; 0001 0028 	ESP_StaticStrs.Strs[ESP_ReceiveDataAnswer] = ESP_Answer_ReceiveData;
	__POINTW2MN _ESP_StaticStrs,10
	LDI  R30,LOW(_ESP_Answer_ReceiveData*2)
	LDI  R31,HIGH(_ESP_Answer_ReceiveData*2)
	ST   X+,R30
	ST   X,R31
; 0001 0029 	// ESP_GotIP == 6
; 0001 002A 	ESP_StaticStrs.Strs[ESP_GotIP] = ESP_Answer_GotIP;
	__POINTW2MN _ESP_StaticStrs,12
	LDI  R30,LOW(_ESP_Answer_GotIP*2)
	LDI  R31,HIGH(_ESP_Answer_GotIP*2)
	ST   X+,R30
	ST   X,R31
; 0001 002B 	// ESP_TCPConnect == 7
; 0001 002C 	ESP_StaticStrs.Strs[ESP_TCP_Connect] = ESP_Answer_TCP_Connect;
	__POINTW2MN _ESP_StaticStrs,14
	LDI  R30,LOW(_ESP_Answer_TCP_Connect*2)
	LDI  R31,HIGH(_ESP_Answer_TCP_Connect*2)
	ST   X+,R30
	ST   X,R31
; 0001 002D 	// ESP_TCPClose == 8
; 0001 002E 	ESP_StaticStrs.Strs[ESP_TCP_Close] = ESP_Answer_TCP_Close;
	__POINTW2MN _ESP_StaticStrs,16
	LDI  R30,LOW(_ESP_Answer_TCP_Close*2)
	LDI  R31,HIGH(_ESP_Answer_TCP_Close*2)
	ST   X+,R30
	ST   X,R31
; 0001 002F 	// Length == sum of all messsages
; 0001 0030 	ESP_StaticStrs.Length = ESP_NumOfAnswers;
	LDI  R30,LOW(9)
	__PUTB1MN _ESP_StaticStrs,18
; 0001 0031 }
	RET
; .FEND
;void ESP_AppendChar(char c){
; 0001 0032 void ESP_AppendChar(char c){
_ESP_AppendChar:
; .FSTART _ESP_AppendChar
; 0001 0033     ESP_Buffer[ESP_BufferIndex++] = c;
	ST   -Y,R26
;	c -> Y+0
	MOV  R30,R5
	INC  R5
	LDI  R31,0
	SUBI R30,LOW(-_ESP_Buffer)
	SBCI R31,HIGH(-_ESP_Buffer)
	LD   R26,Y
	STD  Z+0,R26
; 0001 0034     if (ESP_BufferIndex >= ESP_BufferSize){
	LDI  R30,LOW(128)
	CP   R5,R30
	BRLO _0x20004
; 0001 0035         ESP_BufferIndex = 0;
	CLR  R5
; 0001 0036     }
; 0001 0037 }
_0x20004:
	JMP  _0x20A0001
; .FEND
;void ESP_Check(void)
; 0001 0039 {
; 0001 003A 	ESP_SearchIndex = ESP_BufferIndex;
; 0001 003B 	ESP_LastAnswer = ESP_Nothing;
; 0001 003C 	ESP_Sends("AT\r\n");
; 0001 003D 	ESP_Flags.WaitingForAnswer = 1;
; 0001 003E 	#ifdef ESP_Delay
; 0001 003F 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 0040 	#endif //ESP_Delay
; 0001 0041 }

	.DSEG
_0x20005:
	.BYTE 0x5
;void ESP_Echo(uint8_t State)
; 0001 0043 {

	.CSEG
_ESP_Echo:
; .FSTART _ESP_Echo
; 0001 0044 	ESP_SearchIndex = ESP_BufferIndex;
	ST   -Y,R26
;	State -> Y+0
	MOV  R30,R5
	LDI  R31,0
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 0045 	ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 0046 	ESP_Sends("ATE");
	__POINTW2MN _0x20009,0
	RCALL _USART_PutS
; 0001 0047 	ESP_Sendn(State);
	LD   R26,Y
	CLR  R27
	RCALL _USART_PutN
; 0001 0048 	ESP_Sends("\r\n");
	__POINTW2MN _0x20009,4
	RCALL _USART_PutS
; 0001 0049 	ESP_Flags.WaitingForAnswer = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x10
	STS  _ESP_Flags,R30
; 0001 004A 	#ifdef ESP_Delay
; 0001 004B 	while(ESP_LastAnswer == ESP_Nothing);
_0x2000A:
	LDS  R26,_ESP_LastAnswer
	CPI  R26,LOW(0xFF)
	BREQ _0x2000A
; 0001 004C 	#endif //ESP_Delay
; 0001 004D }
	JMP  _0x20A0001
; .FEND

	.DSEG
_0x20009:
	.BYTE 0x7
;void ESP_Restart(void)
; 0001 004F {

	.CSEG
; 0001 0050 	ESP_SearchIndex = ESP_BufferIndex;
; 0001 0051 	ESP_LastAnswer = ESP_Nothing;
; 0001 0052 	ESP_Sends("AT+RST\r\n");
; 0001 0053 	ESP_Flags.WaitingForAnswer = 1;
; 0001 0054 }

	.DSEG
_0x2000D:
	.BYTE 0x9
;void ESP_WiFiMode(uint8_t Mode)
; 0001 0056 {

	.CSEG
_ESP_WiFiMode:
; .FSTART _ESP_WiFiMode
; 0001 0057 	ESP_SearchIndex = ESP_BufferIndex;
	ST   -Y,R26
;	Mode -> Y+0
	MOV  R30,R5
	LDI  R31,0
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 0058 	ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 0059 	ESP_Sends("AT+CWMODE=");
	__POINTW2MN _0x2000E,0
	RCALL _USART_PutS
; 0001 005A 	ESP_Sendn(Mode);
	LD   R26,Y
	CLR  R27
	RCALL _USART_PutN
; 0001 005B 	ESP_Sends("\r\n");
	__POINTW2MN _0x2000E,11
	RCALL _USART_PutS
; 0001 005C 	ESP_Flags.WaitingForAnswer = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x10
	STS  _ESP_Flags,R30
; 0001 005D 	#ifdef ESP_Delay
; 0001 005E 	while(ESP_LastAnswer == ESP_Nothing);
_0x2000F:
	LDS  R26,_ESP_LastAnswer
	CPI  R26,LOW(0xFF)
	BREQ _0x2000F
; 0001 005F 	#endif //ESP_Delay
; 0001 0060 }
	JMP  _0x20A0001
; .FEND

	.DSEG
_0x2000E:
	.BYTE 0xE
;void ESP_Disconnect(void)
; 0001 0062 {

	.CSEG
; 0001 0063 	ESP_SearchIndex = ESP_BufferIndex;
; 0001 0064 	ESP_LastAnswer = ESP_Nothing;
; 0001 0065 	ESP_Sends("AT+CWQAP\r\n");
; 0001 0066 	ESP_Flags.WaitingForAnswer = 1;
; 0001 0067 	#ifdef ESP_Delay
; 0001 0068 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 0069 	#endif //ESP_Delay
; 0001 006A }

	.DSEG
_0x20012:
	.BYTE 0xB
;void ESP_Connect(char* SSID, char* Password)
; 0001 006C {

	.CSEG
_ESP_Connect:
; .FSTART _ESP_Connect
; 0001 006D 	ESP_SearchIndex = ESP_BufferIndex;
	ST   -Y,R27
	ST   -Y,R26
;	*SSID -> Y+2
;	*Password -> Y+0
	MOV  R30,R5
	LDI  R31,0
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 006E 	ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 006F 	ESP_Sends("AT+CWJAP=\"");
	__POINTW2MN _0x20016,0
	RCALL _USART_PutS
; 0001 0070 	ESP_Sends(SSID);
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	RCALL _USART_PutS
; 0001 0071 	ESP_Sends("\",\"");
	__POINTW2MN _0x20016,11
	RCALL _USART_PutS
; 0001 0072 	ESP_Sends(Password);
	LD   R26,Y
	LDD  R27,Y+1
	RCALL _USART_PutS
; 0001 0073 	ESP_Sends("\"\r\n");
	__POINTW2MN _0x20016,15
	RCALL _USART_PutS
; 0001 0074 	ESP_Flags.WaitingForAnswer = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x10
	STS  _ESP_Flags,R30
; 0001 0075 	#ifdef ESP_Delay
; 0001 0076 	while(ESP_LastAnswer == ESP_Nothing);
_0x20017:
	LDS  R26,_ESP_LastAnswer
	CPI  R26,LOW(0xFF)
	BREQ _0x20017
; 0001 0077 	#endif //ESP_Delay
; 0001 0078 }
	RJMP _0x20A0008
; .FEND

	.DSEG
_0x20016:
	.BYTE 0x13
;void ESP_setAccessPoint(char* SSID, char* Password)
; 0001 007A {

	.CSEG
; 0001 007B 	ESP_SearchIndex = ESP_BufferIndex;
;	*SSID -> Y+2
;	*Password -> Y+0
; 0001 007C 	ESP_LastAnswer = ESP_Nothing;
; 0001 007D 	ESP_Sends("AT+CWSAP=\"");
; 0001 007E 	ESP_Sends(SSID);
; 0001 007F 	ESP_Sends("\",\"");
; 0001 0080 	ESP_Sends(Password);
; 0001 0081 	ESP_Sends("\",1,");
; 0001 0082 	//no password ?
; 0001 0083 	if(Password[0] == '\0')
; 0001 0084 		ESP_Sends("0\r\n");
; 0001 0085 	else
; 0001 0086 		ESP_Sends("3\r\n");
; 0001 0087 	ESP_Flags.WaitingForAnswer = 1;
; 0001 0088 	#ifdef ESP_Delay
; 0001 0089 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 008A 	#endif //ESP_Delay
; 0001 008B }

	.DSEG
_0x2001A:
	.BYTE 0x1C
;void ESP_setMAC_Station(char* MAC)
; 0001 008D {

	.CSEG
; 0001 008E 	ESP_SearchIndex = ESP_BufferIndex;
;	*MAC -> Y+0
; 0001 008F 	ESP_LastAnswer = ESP_Nothing;
; 0001 0090 	ESP_Sends("AT+CIPSTAMAC=\"");
; 0001 0091 	ESP_Sends(MAC);
; 0001 0092 	ESP_Sends("\"\r\n");
; 0001 0093 	ESP_Flags.WaitingForAnswer = 1;
; 0001 0094 	#ifdef ESP_Delay
; 0001 0095 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 0096 	#endif //ESP_Delay
; 0001 0097 }

	.DSEG
_0x20020:
	.BYTE 0x13
;void ESP_setMAC_AccessPoint(char* MAC)
; 0001 0099 {

	.CSEG
; 0001 009A 	ESP_SearchIndex = ESP_BufferIndex;
;	*MAC -> Y+0
; 0001 009B 	ESP_LastAnswer = ESP_Nothing;
; 0001 009C 	ESP_Sends("AT+CIPAPMAC=\"");
; 0001 009D 	ESP_Sends(MAC);
; 0001 009E 	ESP_Sends("\"\r\n");
; 0001 009F 	ESP_Flags.WaitingForAnswer = 1;
; 0001 00A0 	#ifdef ESP_Delay
; 0001 00A1 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 00A2 	#endif //ESP_Delay
; 0001 00A3 }

	.DSEG
_0x20024:
	.BYTE 0x12
;void ESP_setIP_Station(char* IP)
; 0001 00A5 {

	.CSEG
; 0001 00A6 	ESP_SearchIndex = ESP_BufferIndex;
;	*IP -> Y+0
; 0001 00A7 	ESP_LastAnswer = ESP_Nothing;
; 0001 00A8 	ESP_Sends("AT+CIPSTA=\"");
; 0001 00A9 	ESP_Sends(IP);
; 0001 00AA 	ESP_Sends("\"\r\n");
; 0001 00AB 	ESP_Flags.WaitingForAnswer = 1;
; 0001 00AC 	#ifdef ESP_Delay
; 0001 00AD 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 00AE 	#endif //ESP_Delay
; 0001 00AF }

	.DSEG
_0x20028:
	.BYTE 0x10
;void ESP_setIP_AccessPoint(char* IP)
; 0001 00B1 {

	.CSEG
; 0001 00B2 	ESP_SearchIndex = ESP_BufferIndex;
;	*IP -> Y+0
; 0001 00B3 	ESP_LastAnswer = ESP_Nothing;
; 0001 00B4 	ESP_Sends("AT+CIPAP=\"");
; 0001 00B5 	ESP_Sends(IP);
; 0001 00B6 	ESP_Sends("\"\r\n");
; 0001 00B7 	ESP_Flags.WaitingForAnswer = 1;
; 0001 00B8 	#ifdef ESP_Delay
; 0001 00B9 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 00BA 	#endif //ESP_Delay
; 0001 00BB }

	.DSEG
_0x2002C:
	.BYTE 0xF
;void ESP_TCPConnect(char* RemoteIP,uint16_t RemotePort)
; 0001 00BD {

	.CSEG
_ESP_TCPConnect:
; .FSTART _ESP_TCPConnect
; 0001 00BE 	ESP_SearchIndex = ESP_BufferIndex;
	ST   -Y,R27
	ST   -Y,R26
;	*RemoteIP -> Y+2
;	RemotePort -> Y+0
	MOV  R30,R5
	LDI  R31,0
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 00BF 	ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 00C0 	ESP_Sends("AT+CIPSTART=");
	__POINTW2MN _0x20030,0
	RCALL _USART_PutS
; 0001 00C1 	ESP_Sends("\"TCP\",\"");
	__POINTW2MN _0x20030,13
	RCALL _USART_PutS
; 0001 00C2 	ESP_Sends(RemoteIP);
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	RCALL _USART_PutS
; 0001 00C3 	ESP_Sends("\",");
	__POINTW2MN _0x20030,21
	RCALL _USART_PutS
; 0001 00C4 	ESP_Sendn(RemotePort);
	LD   R26,Y
	LDD  R27,Y+1
	RCALL _USART_PutN
; 0001 00C5 	ESP_Sends("\r\n");
	__POINTW2MN _0x20030,24
	RCALL _USART_PutS
; 0001 00C6 	ESP_Flags.WaitingForAnswer = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x10
	STS  _ESP_Flags,R30
; 0001 00C7 	#ifdef ESP_Delay
; 0001 00C8 	while(ESP_LastAnswer == ESP_Nothing);
_0x20031:
	LDS  R26,_ESP_LastAnswer
	CPI  R26,LOW(0xFF)
	BREQ _0x20031
; 0001 00C9 	#endif //ESP_Delay
; 0001 00CA }
	RJMP _0x20A0008
; .FEND

	.DSEG
_0x20030:
	.BYTE 0x1B
;void ESP_TCPSendData(uint8_t* Data, uint16_t Length)
; 0001 00CC {

	.CSEG
_ESP_TCPSendData:
; .FSTART _ESP_TCPSendData
; 0001 00CD 	uint16_t i;
; 0001 00CE 	ESP_SearchIndex = ESP_BufferIndex;
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
	ST   -Y,R16
;	*Data -> Y+4
;	Length -> Y+2
;	i -> R16,R17
	MOV  R30,R5
	LDI  R31,0
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 00CF 	ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 00D0 	ESP_Sends("AT+CIPSEND=");
	__POINTW2MN _0x20034,0
	RCALL _USART_PutS
; 0001 00D1 	ESP_Sendn(Length);
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	RCALL _USART_PutN
; 0001 00D2 	ESP_Sends("\r\n");
	__POINTW2MN _0x20034,12
	RCALL _USART_PutS
; 0001 00D3 	//waiting for "> " (two chars)
; 0001 00D4 	for(i=0; i < 7000 ;i++);
	__GETWRN 16,17,0
_0x20036:
	__CPWRN 16,17,7000
	BRSH _0x20037
	__ADDWRN 16,17,1
	RJMP _0x20036
_0x20037:
; 0001 00D5 	ESP_SendData(Data,Length);
	LDD  R30,Y+4
	LDD  R31,Y+4+1
	ST   -Y,R31
	ST   -Y,R30
	LDD  R26,Y+4
	RCALL _USART_PutData
; 0001 00D6 	ESP_Flags.WaitingForAnswer = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x10
	STS  _ESP_Flags,R30
; 0001 00D7 	#ifdef ESP_Delay
; 0001 00D8 	while(ESP_LastAnswer == ESP_Nothing);//for OK
_0x20038:
	LDS  R26,_ESP_LastAnswer
	CPI  R26,LOW(0xFF)
	BREQ _0x20038
; 0001 00D9 	ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 00DA 	while(ESP_LastAnswer == ESP_Nothing);//for SEND OK
_0x2003B:
	LDS  R26,_ESP_LastAnswer
	CPI  R26,LOW(0xFF)
	BREQ _0x2003B
; 0001 00DB 	#endif //ESP_Delay
; 0001 00DC }
	LDD  R17,Y+1
	LDD  R16,Y+0
	RJMP _0x20A0006
; .FEND

	.DSEG
_0x20034:
	.BYTE 0xF
;void ESP_TCPClose(void)
; 0001 00DE {

	.CSEG
; 0001 00DF 	ESP_SearchIndex = ESP_BufferIndex;
; 0001 00E0 	ESP_LastAnswer = ESP_Nothing;
; 0001 00E1 	ESP_Sends("AT+CIPCLOSE\r\n");
; 0001 00E2 	ESP_Flags.WaitingForAnswer = 1;
; 0001 00E3 	#ifdef ESP_Delay
; 0001 00E4 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 00E5 	#endif //ESP_Delay
; 0001 00E6 }

	.DSEG
_0x2003E:
	.BYTE 0xE
;void ESP_MultiConnection(uint8_t State)
; 0001 00E8 {

	.CSEG
; 0001 00E9 	ESP_SearchIndex = ESP_BufferIndex;
;	State -> Y+0
; 0001 00EA 	ESP_LastAnswer = ESP_Nothing;
; 0001 00EB 	ESP_Sends("AT+CIPMUX=");
; 0001 00EC 	ESP_Sendn(State);
; 0001 00ED 	ESP_Sends("\r\n");
; 0001 00EE 	ESP_Flags.WaitingForAnswer = 1;
; 0001 00EF 	#ifdef ESP_Delay
; 0001 00F0 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 00F1 	#endif //ESP_Delay
; 0001 00F2 }

	.DSEG
_0x20042:
	.BYTE 0xE
;void ESP_TCPServer(uint16_t Port)
; 0001 00F4 {

	.CSEG
; 0001 00F5 	ESP_SearchIndex = ESP_BufferIndex;
;	Port -> Y+0
; 0001 00F6 	ESP_LastAnswer = ESP_Nothing;
; 0001 00F7 	ESP_Sends("AT+CIPSERVER=1,\"");
; 0001 00F8 	ESP_Sendn(Port);
; 0001 00F9 	ESP_Sends("\"\r\n");
; 0001 00FA 	ESP_Flags.WaitingForAnswer = 1;
; 0001 00FB 	#ifdef ESP_Delay
; 0001 00FC 	while(ESP_LastAnswer == ESP_Nothing);
; 0001 00FD 	#endif //ESP_Delay
; 0001 00FE }

	.DSEG
_0x20046:
	.BYTE 0x15
;void ESP_ReleaseReceiveBuffer(void)
; 0001 0100 {

	.CSEG
_ESP_ReleaseReceiveBuffer:
; .FSTART _ESP_ReleaseReceiveBuffer
; 0001 0101 	ESP_BufferIndex = 0;
	CLR  R5
; 0001 0102     ESP_ReceiveData_Index = 0;
	LDI  R30,LOW(0)
	STS  _ESP_ReceiveData_Index,R30
	STS  _ESP_ReceiveData_Index+1,R30
; 0001 0103 	ESP_Flags.DataReceived = 0;
	LDS  R30,_ESP_Flags
	ANDI R30,0x7F
	STS  _ESP_Flags,R30
; 0001 0104 }
	RET
; .FEND
;//tools function
;uint8_t strcomp(flash const char* src,char* dest){
; 0001 0106 uint8_t strcomp(flash const char* src,char* dest){
_strcomp:
; .FSTART _strcomp
; 0001 0107 	while(*src !='\0'){
	ST   -Y,R27
	ST   -Y,R26
;	*src -> Y+2
;	*dest -> Y+0
_0x2004A:
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	LPM  R30,Z
	CPI  R30,0
	BREQ _0x2004C
; 0001 0108 		if(*src++ != *dest++)
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	LPM  R0,Z+
	STD  Y+2,R30
	STD  Y+2+1,R31
	LD   R26,Y
	LDD  R27,Y+1
	LD   R30,X+
	ST   Y,R26
	STD  Y+1,R27
	CP   R30,R0
	BREQ _0x2004D
; 0001 0109 			return 0;
	LDI  R30,LOW(0)
	RJMP _0x20A0008
; 0001 010A 	}
_0x2004D:
	RJMP _0x2004A
_0x2004C:
; 0001 010B 	return 1;
	LDI  R30,LOW(1)
	RJMP _0x20A0008
; 0001 010C }
; .FEND
;int16_t strchar(char* src, char c, uint16_t top)
; 0001 010E {
_strchar:
; .FSTART _strchar
; 0001 010F 	uint16_t index = 0;
; 0001 0110 	while(src != '\0' && index < top){
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
	ST   -Y,R16
;	*src -> Y+5
;	c -> Y+4
;	top -> Y+2
;	index -> R16,R17
	__GETWRN 16,17,0
_0x2004E:
	LDD  R26,Y+5
	LDD  R27,Y+5+1
	SBIW R26,0
	BREQ _0x20051
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	CP   R16,R30
	CPC  R17,R31
	BRLO _0x20052
_0x20051:
	RJMP _0x20050
_0x20052:
; 0001 0111 		if(src[index++] == c)
	MOVW R30,R16
	__ADDWRN 16,17,1
	LDD  R26,Y+5
	LDD  R27,Y+5+1
	ADD  R26,R30
	ADC  R27,R31
	LD   R26,X
	LDD  R30,Y+4
	CP   R30,R26
	BRNE _0x20053
; 0001 0112 			return index - 1;
	MOVW R30,R16
	SBIW R30,1
	RJMP _0x20A000B
; 0001 0113 	}
_0x20053:
	RJMP _0x2004E
_0x20050:
; 0001 0114 	return -1;
	LDI  R30,LOW(65535)
	LDI  R31,HIGH(65535)
_0x20A000B:
	LDD  R17,Y+1
	LDD  R16,Y+0
	ADIW R28,7
	RET
; 0001 0115 }
; .FEND
;void strget(char* src, char* dest, uint16_t start, uint16_t end)
; 0001 0117 {
_strget:
; .FSTART _strget
; 0001 0118 	uint16_t i = 0;
; 0001 0119 	while(start < end){
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
	ST   -Y,R16
;	*src -> Y+8
;	*dest -> Y+6
;	start -> Y+4
;	end -> Y+2
;	i -> R16,R17
	__GETWRN 16,17,0
_0x20054:
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	LDD  R26,Y+4
	LDD  R27,Y+4+1
	CP   R26,R30
	CPC  R27,R31
	BRSH _0x20056
; 0001 011A 		dest[i++] = src[start++];
	MOVW R30,R16
	__ADDWRN 16,17,1
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	ADD  R30,R26
	ADC  R31,R27
	MOVW R0,R30
	LDD  R30,Y+4
	LDD  R31,Y+4+1
	ADIW R30,1
	STD  Y+4,R30
	STD  Y+4+1,R31
	SBIW R30,1
	LDD  R26,Y+8
	LDD  R27,Y+8+1
	ADD  R26,R30
	ADC  R27,R31
	LD   R30,X
	MOVW R26,R0
	ST   X,R30
; 0001 011B 	}
	RJMP _0x20054
_0x20056:
; 0001 011C 	dest[i] = '\0';
	MOVW R30,R16
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	ADD  R26,R30
	ADC  R27,R31
	LDI  R30,LOW(0)
	ST   X,R30
; 0001 011D }
	LDD  R17,Y+1
	LDD  R16,Y+0
	RJMP _0x20A000A
; .FEND
;int8_t strgetc(char* src, char* dest, char start, char end)
; 0001 011F {
_strgetc:
; .FSTART _strgetc
; 0001 0120 	int16_t A,B;
; 0001 0121 	A = strchar(src, start, 0xff);//0xff for too long string
	ST   -Y,R26
	CALL __SAVELOCR4
;	*src -> Y+8
;	*dest -> Y+6
;	start -> Y+5
;	end -> Y+4
;	A -> R16,R17
;	B -> R18,R19
	LDD  R30,Y+8
	LDD  R31,Y+8+1
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+7
	ST   -Y,R30
	LDI  R26,LOW(255)
	LDI  R27,0
	RCALL _strchar
	MOVW R16,R30
; 0001 0122 	if(A != -1){
	LDI  R30,LOW(65535)
	LDI  R31,HIGH(65535)
	CP   R30,R16
	CPC  R31,R17
	BREQ _0x20057
; 0001 0123 		B = strchar(&src[A+1], end, 0xff);
	MOVW R30,R16
	ADIW R30,1
	LDD  R26,Y+8
	LDD  R27,Y+8+1
	ADD  R30,R26
	ADC  R31,R27
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+6
	ST   -Y,R30
	LDI  R26,LOW(255)
	LDI  R27,0
	RCALL _strchar
	MOVW R18,R30
; 0001 0124 		if(B != -1){
	LDI  R30,LOW(65535)
	LDI  R31,HIGH(65535)
	CP   R30,R18
	CPC  R31,R19
	BREQ _0x20058
; 0001 0125 			strget(src, dest, A+1, A+B+1);
	LDD  R30,Y+8
	LDD  R31,Y+8+1
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+8
	LDD  R31,Y+8+1
	ST   -Y,R31
	ST   -Y,R30
	MOVW R30,R16
	ADIW R30,1
	ST   -Y,R31
	ST   -Y,R30
	MOVW R30,R18
	ADD  R30,R16
	ADC  R31,R17
	ADIW R30,1
	MOVW R26,R30
	RCALL _strget
; 0001 0126 			return 1;
	LDI  R30,LOW(1)
	RJMP _0x20A0009
; 0001 0127 		}
; 0001 0128 		else{
_0x20058:
; 0001 0129 			return -2;
	LDI  R30,LOW(254)
	RJMP _0x20A0009
; 0001 012A 		}
; 0001 012B 	}
; 0001 012C 	else{
_0x20057:
; 0001 012D 		return -1;//can't finde start char
	LDI  R30,LOW(255)
; 0001 012E 	}
; 0001 012F }
_0x20A0009:
	CALL __LOADLOCR4
_0x20A000A:
	ADIW R28,10
	RET
; .FEND
;uint16_t strtonum(char* str)
; 0001 0131 {
_strtonum:
; .FSTART _strtonum
; 0001 0132 	uint16_t z = 0;
; 0001 0133 	while(*str != '\0'){
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
	ST   -Y,R16
;	*str -> Y+2
;	z -> R16,R17
	__GETWRN 16,17,0
_0x2005B:
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	LD   R30,X
	CPI  R30,0
	BREQ _0x2005D
; 0001 0134 		if(*str <= '9' && *str >= '0')
	LD   R26,X
	CPI  R26,LOW(0x3A)
	BRSH _0x2005F
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	LD   R26,X
	CPI  R26,LOW(0x30)
	BRSH _0x20060
_0x2005F:
	RJMP _0x2005E
_0x20060:
; 0001 0135 			z = (z * 10) + ( *str - 0x30);
	__MULBNWRU 16,17,10
	MOVW R0,R30
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	LD   R30,X
	LDI  R31,0
	SBIW R30,48
	ADD  R30,R0
	ADC  R31,R1
	MOVW R16,R30
; 0001 0136 		else
	RJMP _0x20061
_0x2005E:
; 0001 0137 			break;
	RJMP _0x2005D
; 0001 0138 		str++;
_0x20061:
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	ADIW R30,1
	STD  Y+2,R30
	STD  Y+2+1,R31
; 0001 0139 	}
	RJMP _0x2005B
_0x2005D:
; 0001 013A 	return z;
	RJMP _0x20A0007
; 0001 013B }
; .FEND
;uint16_t strlength(char* str)
; 0001 013D {
_strlength:
; .FSTART _strlength
; 0001 013E 	uint16_t i;
; 0001 013F 	for(i=0;str[i] != '\0';i++);
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
	ST   -Y,R16
;	*str -> Y+2
;	i -> R16,R17
	__GETWRN 16,17,0
_0x20063:
	MOVW R30,R16
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	ADD  R26,R30
	ADC  R27,R31
	LD   R30,X
	CPI  R30,0
	BREQ _0x20064
	__ADDWRN 16,17,1
	RJMP _0x20063
_0x20064:
; 0001 0140 	return i;
_0x20A0007:
	MOVW R30,R16
	LDD  R17,Y+1
	LDD  R16,Y+0
_0x20A0008:
	ADIW R28,4
	RET
; 0001 0141 }
; .FEND
;void readdata(uint8_t* src, uint8_t* buff, uint16_t size)
; 0001 0143 {
_readdata:
; .FSTART _readdata
; 0001 0144 	while(size > 0){
	ST   -Y,R27
	ST   -Y,R26
;	*src -> Y+4
;	*buff -> Y+2
;	size -> Y+0
_0x20065:
	LD   R26,Y
	LDD  R27,Y+1
	CALL __CPW02
	BRSH _0x20067
; 0001 0145 		*buff++ = *src++;
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	ADIW R30,1
	STD  Y+2,R30
	STD  Y+2+1,R31
	SBIW R30,1
	MOVW R0,R30
	LDD  R26,Y+4
	LDD  R27,Y+4+1
	LD   R30,X+
	STD  Y+4,R26
	STD  Y+4+1,R27
	MOVW R26,R0
	ST   X,R30
; 0001 0146 		size--;
	LD   R30,Y
	LDD  R31,Y+1
	SBIW R30,1
	ST   Y,R30
	STD  Y+1,R31
; 0001 0147 	}
	RJMP _0x20065
_0x20067:
; 0001 0148 }
_0x20A0006:
	ADIW R28,6
	RET
; .FEND
;ESP_Answer AnswerFinder(void)
; 0001 014A {
_AnswerFinder:
; .FSTART _AnswerFinder
; 0001 014B 	//nothing == 0xff
; 0001 014C 	ESP_Answer answer = ESP_Nothing;
; 0001 014D 	uint16_t index;
; 0001 014E 	uint8_t AnswerLength;
; 0001 014F 	char length[5];
; 0001 0150 	uint16_t datasize = 0;
; 0001 0151 	uint16_t i;
; 0001 0152 	for(index = ESP_SearchIndex; index < ESP_BufferIndex ; index++){
	SBIW R28,7
	CALL __SAVELOCR6
;	answer -> R17
;	index -> R18,R19
;	AnswerLength -> R16
;	length -> Y+8
;	datasize -> R20,R21
;	i -> Y+6
	LDI  R17,255
	__GETWRN 20,21,0
	__GETWRMN 18,19,0,_ESP_SearchIndex
_0x20069:
	MOV  R30,R5
	MOVW R26,R18
	LDI  R31,0
	CP   R26,R30
	CPC  R27,R31
	BRLO PC+2
	RJMP _0x2006A
; 0001 0153 		for(i=0; i<ESP_StaticStrs.Length;i++){
	LDI  R30,LOW(0)
	STD  Y+6,R30
	STD  Y+6+1,R30
_0x2006C:
	__GETB1MN _ESP_StaticStrs,18
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	LDI  R31,0
	CP   R26,R30
	CPC  R27,R31
	BRLO PC+2
	RJMP _0x2006D
; 0001 0154 			if(ESP_StaticStrs.Strs[i][0] == ESP_Buffer[index]){
	LDD  R30,Y+6
	LDD  R31,Y+6+1
	LDI  R26,LOW(_ESP_StaticStrs)
	LDI  R27,HIGH(_ESP_StaticStrs)
	LSL  R30
	ROL  R31
	ADD  R26,R30
	ADC  R27,R31
	CALL __GETW1P
	LPM  R0,Z
	LDI  R26,LOW(_ESP_Buffer)
	LDI  R27,HIGH(_ESP_Buffer)
	ADD  R26,R18
	ADC  R27,R19
	LD   R30,X
	CP   R30,R0
	BREQ PC+2
	RJMP _0x2006E
; 0001 0155 				if(strcomp(ESP_StaticStrs.Strs[i],(char*)&ESP_Buffer[index])){
	LDD  R30,Y+6
	LDD  R31,Y+6+1
	LDI  R26,LOW(_ESP_StaticStrs)
	LDI  R27,HIGH(_ESP_StaticStrs)
	LSL  R30
	ROL  R31
	ADD  R26,R30
	ADC  R27,R31
	CALL __GETW1P
	ST   -Y,R31
	ST   -Y,R30
	LDI  R26,LOW(_ESP_Buffer)
	LDI  R27,HIGH(_ESP_Buffer)
	ADD  R26,R18
	ADC  R27,R19
	RCALL _strcomp
	CPI  R30,0
	BRNE PC+2
	RJMP _0x2006F
; 0001 0156 					//check is data?
; 0001 0157 					if(i == ESP_ReceiveDataAnswer){
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	SBIW R26,5
	BREQ PC+2
	RJMP _0x20070
; 0001 0158 						ESP_Flags.DataReceiving = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x40
	STS  _ESP_Flags,R30
; 0001 0159 						if(strchar((char*)&ESP_Buffer[index], ':', ESP_BufferIndex - index + 1) != -1){
	MOVW R30,R18
	SUBI R30,LOW(-_ESP_Buffer)
	SBCI R31,HIGH(-_ESP_Buffer)
	ST   -Y,R31
	ST   -Y,R30
	LDI  R30,LOW(58)
	ST   -Y,R30
	MOV  R30,R5
	LDI  R31,0
	SUB  R30,R18
	SBC  R31,R19
	ADIW R30,1
	MOVW R26,R30
	RCALL _strchar
	CPI  R30,LOW(0xFFFF)
	LDI  R26,HIGH(0xFFFF)
	CPC  R31,R26
	BRNE PC+2
	RJMP _0x20071
; 0001 015A 							// get data length
; 0001 015B 							if(ESP_Flags.MultiConnection){
	LDS  R30,_ESP_Flags
	ANDI R30,LOW(0x8)
	BREQ _0x20072
; 0001 015C 
; 0001 015D 							}
; 0001 015E 							else{
	RJMP _0x20073
_0x20072:
; 0001 015F 								if(strgetc((char*)&ESP_Buffer[index], length, ',', ':') == 1){
	MOVW R30,R18
	SUBI R30,LOW(-_ESP_Buffer)
	SBCI R31,HIGH(-_ESP_Buffer)
	ST   -Y,R31
	ST   -Y,R30
	MOVW R30,R28
	ADIW R30,10
	ST   -Y,R31
	ST   -Y,R30
	LDI  R30,LOW(44)
	ST   -Y,R30
	LDI  R26,LOW(58)
	RCALL _strgetc
	CPI  R30,LOW(0x1)
	BREQ PC+2
	RJMP _0x20074
; 0001 0160 									AnswerLength = 6 + strlength(length);
	MOVW R26,R28
	ADIW R26,8
	RCALL _strlength
	SUBI R30,-LOW(6)
	MOV  R16,R30
; 0001 0161 									datasize = strtonum(length);
	MOVW R26,R28
	ADIW R26,8
	RCALL _strtonum
	MOVW R20,R30
; 0001 0162 									//check all data recived?
; 0001 0163 									if((ESP_BufferIndex - (index + AnswerLength)) >= datasize){
	MOV  R26,R5
	CLR  R27
	MOV  R30,R16
	LDI  R31,0
	ADD  R30,R18
	ADC  R31,R19
	SUB  R26,R30
	SBC  R27,R31
	CP   R26,R20
	CPC  R27,R21
	BRLO _0x20075
; 0001 0164 										//get all data
; 0001 0165 										readdata(&ESP_Buffer[index + AnswerLength ], &ESP_ReceiveData[ESP_ReceiveData_Index], datasize);
	MOV  R30,R16
	LDI  R31,0
	ADD  R30,R18
	ADC  R31,R19
	SUBI R30,LOW(-_ESP_Buffer)
	SBCI R31,HIGH(-_ESP_Buffer)
	ST   -Y,R31
	ST   -Y,R30
	LDS  R30,_ESP_ReceiveData_Index
	LDS  R31,_ESP_ReceiveData_Index+1
	SUBI R30,LOW(-_ESP_ReceiveData)
	SBCI R31,HIGH(-_ESP_ReceiveData)
	ST   -Y,R31
	ST   -Y,R30
	MOVW R26,R20
	RCALL _readdata
; 0001 0166 										ESP_ReceiveData_Index +=  datasize;
	MOVW R30,R20
	LDS  R26,_ESP_ReceiveData_Index
	LDS  R27,_ESP_ReceiveData_Index+1
	ADD  R30,R26
	ADC  R31,R27
	STS  _ESP_ReceiveData_Index,R30
	STS  _ESP_ReceiveData_Index+1,R31
; 0001 0167 										ESP_Flags.DataReceived = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x80
	STS  _ESP_Flags,R30
; 0001 0168 										ESP_Flags.DataReceiving = 0;
	ANDI R30,0xBF
	STS  _ESP_Flags,R30
; 0001 0169 										//remove past answer
; 0001 016A 										ESP_SearchIndex = index + AnswerLength + datasize + 1;
	MOV  R30,R16
	LDI  R31,0
	ADD  R30,R18
	ADC  R31,R19
	ADD  R30,R20
	ADC  R31,R21
	ADIW R30,1
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 016B 									}
; 0001 016C 								}
_0x20075:
; 0001 016D 							}
_0x20074:
_0x20073:
; 0001 016E 						}
; 0001 016F 					}
_0x20071:
; 0001 0170 					else{
	RJMP _0x20076
_0x20070:
; 0001 0171 						//remove past answer
; 0001 0172 						ESP_SearchIndex = index + 1;
	MOVW R30,R18
	ADIW R30,1
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R31
; 0001 0173 					}
_0x20076:
; 0001 0174 					//i == answer type
; 0001 0175 					return (ESP_Answer)i;
	LDD  R30,Y+6
	RJMP _0x20A0005
; 0001 0176 				}
; 0001 0177 			}
_0x2006F:
; 0001 0178 		}
_0x2006E:
	LDD  R30,Y+6
	LDD  R31,Y+6+1
	ADIW R30,1
	STD  Y+6,R30
	STD  Y+6+1,R31
	RJMP _0x2006C
_0x2006D:
; 0001 0179 	}
	__ADDWRN 18,19,1
	RJMP _0x20069
_0x2006A:
; 0001 017A 	return answer;
	MOV  R30,R17
_0x20A0005:
	CALL __LOADLOCR6
	ADIW R28,13
	RET
; 0001 017B }
; .FEND
;void ESP_CheckAnswer(void)
; 0001 017D {
_ESP_CheckAnswer:
; .FSTART _ESP_CheckAnswer
; 0001 017E     switch(AnswerFinder())
	RCALL _AnswerFinder
; 0001 017F     {
; 0001 0180         case ESP_Nothing: // 0xff
	CPI  R30,LOW(0xFF)
	BRNE _0x2007A
; 0001 0181             ESP_LastAnswer = ESP_Nothing;
	LDI  R30,LOW(255)
	STS  _ESP_LastAnswer,R30
; 0001 0182             break;
	RJMP _0x20079
; 0001 0183         case ESP_Ok: 			// 0
_0x2007A:
	CPI  R30,0
	BRNE _0x2007B
; 0001 0184             ESP_LastAnswer = ESP_Ok;
	LDI  R30,LOW(0)
	STS  _ESP_LastAnswer,R30
; 0001 0185             ESP_Flags.WaitingForAnswer = 0;
	LDS  R30,_ESP_Flags
	ANDI R30,0xEF
	STS  _ESP_Flags,R30
; 0001 0186             ESP_Flags.Answer_Received = 1;
	ORI  R30,4
	STS  _ESP_Flags,R30
; 0001 0187             ESP_BufferIndex = 0;
	CLR  R5
; 0001 0188             ESP_SearchIndex = 0;
	LDI  R30,LOW(0)
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R30
; 0001 0189             break;
	RJMP _0x20079
; 0001 018A         case ESP_Fail: 		// 1
_0x2007B:
	CPI  R30,LOW(0x1)
	BRNE _0x2007C
; 0001 018B             ESP_LastAnswer = ESP_Fail;
	LDI  R30,LOW(1)
	STS  _ESP_LastAnswer,R30
; 0001 018C             ESP_Flags.WaitingForAnswer = 0;
	LDS  R30,_ESP_Flags
	ANDI R30,0xEF
	STS  _ESP_Flags,R30
; 0001 018D             ESP_Flags.Answer_Received = 1;
	ORI  R30,4
	STS  _ESP_Flags,R30
; 0001 018E             ESP_BufferIndex = 0;
	CLR  R5
; 0001 018F             ESP_SearchIndex = 0;
	LDI  R30,LOW(0)
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R30
; 0001 0190             break;
	RJMP _0x20079
; 0001 0191         case ESP_Error:		// 2
_0x2007C:
	CPI  R30,LOW(0x2)
	BRNE _0x2007D
; 0001 0192             ESP_LastAnswer = ESP_Error;
	LDI  R30,LOW(2)
	STS  _ESP_LastAnswer,R30
; 0001 0193             ESP_Flags.WaitingForAnswer = 0;
	LDS  R30,_ESP_Flags
	ANDI R30,0xEF
	STS  _ESP_Flags,R30
; 0001 0194             ESP_Flags.Answer_Received = 1;
	ORI  R30,4
	STS  _ESP_Flags,R30
; 0001 0195             ESP_BufferIndex = 0;
	CLR  R5
; 0001 0196             ESP_SearchIndex = 0;
	LDI  R30,LOW(0)
	STS  _ESP_SearchIndex,R30
	STS  _ESP_SearchIndex+1,R30
; 0001 0197             break;
	RJMP _0x20079
; 0001 0198         case ESP_Disconnected: // 3
_0x2007D:
	CPI  R30,LOW(0x3)
	BRNE _0x2007E
; 0001 0199             ESP_Flags.WIFI_Connected = 0;
	LDS  R30,_ESP_Flags
	ANDI R30,0xFE
	STS  _ESP_Flags,R30
; 0001 019A             ESP_Flags.Answer_Received = 1;
	ORI  R30,4
	RJMP _0x20085
; 0001 019B             break;
; 0001 019C         case ESP_Connected: // 4
_0x2007E:
	CPI  R30,LOW(0x4)
	BRNE _0x2007F
; 0001 019D             ESP_Flags.WIFI_Connected = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,1
	STS  _ESP_Flags,R30
; 0001 019E             ESP_Flags.Answer_Received = 1;
	ORI  R30,4
	RJMP _0x20085
; 0001 019F             break;
; 0001 01A0         case ESP_ReceiveDataAnswer: // 5
_0x2007F:
	CPI  R30,LOW(0x5)
	BREQ _0x20079
; 0001 01A1 
; 0001 01A2             break;
; 0001 01A3         case ESP_GotIP: // 6
	CPI  R30,LOW(0x6)
	BRNE _0x20081
; 0001 01A4             ESP_Flags.WIFI_GotIP = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,2
	STS  _ESP_Flags,R30
; 0001 01A5             ESP_Flags.Answer_Received = 1;
	ORI  R30,4
	RJMP _0x20085
; 0001 01A6             break;
; 0001 01A7         case ESP_TCP_Connect: // 7
_0x20081:
	CPI  R30,LOW(0x7)
	BRNE _0x20082
; 0001 01A8             ESP_Flags.TCPConnected = 1;
	LDS  R30,_ESP_Flags
	ORI  R30,0x20
	RJMP _0x20085
; 0001 01A9             break;
; 0001 01AA         case ESP_TCP_Close: // 8
_0x20082:
	CPI  R30,LOW(0x8)
	BRNE _0x20079
; 0001 01AB             ESP_Flags.TCPConnected = 0;
	LDS  R30,_ESP_Flags
	ANDI R30,0xDF
_0x20085:
	STS  _ESP_Flags,R30
; 0001 01AC             break;
; 0001 01AD     }
_0x20079:
; 0001 01AE }
	RET
; .FEND
;

	.CSEG
_itoa:
; .FSTART _itoa
	ST   -Y,R27
	ST   -Y,R26
    ld   r26,y+
    ld   r27,y+
    ld   r30,y+
    ld   r31,y+
    adiw r30,0
    brpl __itoa0
    com  r30
    com  r31
    adiw r30,1
    ldi  r22,'-'
    st   x+,r22
__itoa0:
    clt
    ldi  r24,low(10000)
    ldi  r25,high(10000)
    rcall __itoa1
    ldi  r24,low(1000)
    ldi  r25,high(1000)
    rcall __itoa1
    ldi  r24,100
    clr  r25
    rcall __itoa1
    ldi  r24,10
    rcall __itoa1
    mov  r22,r30
    rcall __itoa5
    clr  r22
    st   x,r22
    ret

__itoa1:
    clr	 r22
__itoa2:
    cp   r30,r24
    cpc  r31,r25
    brlo __itoa3
    inc  r22
    sub  r30,r24
    sbc  r31,r25
    brne __itoa2
__itoa3:
    tst  r22
    brne __itoa4
    brts __itoa5
    ret
__itoa4:
    set
__itoa5:
    subi r22,-0x30
    st   x+,r22
    ret
; .FEND

	.DSEG

	.CSEG

	.CSEG
_strncpy:
; .FSTART _strncpy
	ST   -Y,R26
    ld   r23,y+
    ld   r30,y+
    ld   r31,y+
    ld   r26,y+
    ld   r27,y+
    movw r24,r26
strncpy0:
    tst  r23
    breq strncpy1
    dec  r23
    ld   r22,z+
    st   x+,r22
    tst  r22
    brne strncpy0
strncpy2:
    tst  r23
    breq strncpy1
    dec  r23
    st   x+,r22
    rjmp strncpy2
strncpy1:
    movw r30,r24
    ret
; .FEND
	#ifndef __SLEEP_DEFINED__
	#define __SLEEP_DEFINED__
	.EQU __se_bit=0x40
	.EQU __sm_mask=0xB0
	.EQU __sm_powerdown=0x20
	.EQU __sm_powersave=0x30
	.EQU __sm_standby=0xA0
	.EQU __sm_ext_standby=0xB0
	.EQU __sm_adc_noise_red=0x10
	.SET power_ctrl_reg=mcucr
	#endif

	.DSEG

	.CSEG
__lcd_write_nibble_G102:
; .FSTART __lcd_write_nibble_G102
	ST   -Y,R26
	IN   R30,0x1B
	ANDI R30,LOW(0xF)
	MOV  R26,R30
	LD   R30,Y
	ANDI R30,LOW(0xF0)
	OR   R30,R26
	OUT  0x1B,R30
	__DELAY_USB 13
	SBI  0x1B,2
	__DELAY_USB 13
	CBI  0x1B,2
	__DELAY_USB 13
	RJMP _0x20A0001
; .FEND
__lcd_write_data:
; .FSTART __lcd_write_data
	ST   -Y,R26
	LD   R26,Y
	RCALL __lcd_write_nibble_G102
    ld    r30,y
    swap  r30
    st    y,r30
	LD   R26,Y
	RCALL __lcd_write_nibble_G102
	__DELAY_USB 133
	RJMP _0x20A0001
; .FEND
_lcd_gotoxy:
; .FSTART _lcd_gotoxy
	ST   -Y,R26
	LD   R30,Y
	LDI  R31,0
	SUBI R30,LOW(-__base_y_G102)
	SBCI R31,HIGH(-__base_y_G102)
	LD   R30,Z
	LDD  R26,Y+1
	ADD  R26,R30
	RCALL __lcd_write_data
	LDD  R4,Y+1
	LDD  R7,Y+0
_0x20A0004:
	ADIW R28,2
	RET
; .FEND
_lcd_clear:
; .FSTART _lcd_clear
	LDI  R26,LOW(2)
	RCALL __lcd_write_data
	LDI  R26,LOW(3)
	LDI  R27,0
	CALL _delay_ms
	LDI  R26,LOW(12)
	RCALL __lcd_write_data
	LDI  R26,LOW(1)
	RCALL __lcd_write_data
	LDI  R26,LOW(3)
	LDI  R27,0
	CALL _delay_ms
	LDI  R30,LOW(0)
	MOV  R7,R30
	MOV  R4,R30
	RET
; .FEND
_lcd_putchar:
; .FSTART _lcd_putchar
	ST   -Y,R26
	LD   R26,Y
	CPI  R26,LOW(0xA)
	BREQ _0x2040005
	CP   R4,R6
	BRLO _0x2040004
_0x2040005:
	LDI  R30,LOW(0)
	ST   -Y,R30
	INC  R7
	MOV  R26,R7
	RCALL _lcd_gotoxy
	LD   R26,Y
	CPI  R26,LOW(0xA)
	BRNE _0x2040007
	RJMP _0x20A0001
_0x2040007:
_0x2040004:
	INC  R4
	SBI  0x1B,0
	LD   R26,Y
	RCALL __lcd_write_data
	CBI  0x1B,0
	RJMP _0x20A0001
; .FEND
_lcd_puts:
; .FSTART _lcd_puts
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
_0x2040008:
	LDD  R26,Y+1
	LDD  R27,Y+1+1
	LD   R30,X+
	STD  Y+1,R26
	STD  Y+1+1,R27
	MOV  R17,R30
	CPI  R30,0
	BREQ _0x204000A
	MOV  R26,R17
	RCALL _lcd_putchar
	RJMP _0x2040008
_0x204000A:
	RJMP _0x20A0002
; .FEND
_lcd_putsf:
; .FSTART _lcd_putsf
	ST   -Y,R27
	ST   -Y,R26
	ST   -Y,R17
_0x204000B:
	LDD  R30,Y+1
	LDD  R31,Y+1+1
	ADIW R30,1
	STD  Y+1,R30
	STD  Y+1+1,R31
	SBIW R30,1
	LPM  R30,Z
	MOV  R17,R30
	CPI  R30,0
	BREQ _0x204000D
	MOV  R26,R17
	RCALL _lcd_putchar
	RJMP _0x204000B
_0x204000D:
_0x20A0002:
	LDD  R17,Y+0
_0x20A0003:
	ADIW R28,3
	RET
; .FEND
_lcd_init:
; .FSTART _lcd_init
	ST   -Y,R26
	IN   R30,0x1A
	ORI  R30,LOW(0xF0)
	OUT  0x1A,R30
	SBI  0x1A,2
	SBI  0x1A,0
	SBI  0x1A,1
	CBI  0x1B,2
	CBI  0x1B,0
	CBI  0x1B,1
	LDD  R6,Y+0
	LD   R30,Y
	SUBI R30,-LOW(128)
	__PUTB1MN __base_y_G102,2
	LD   R30,Y
	SUBI R30,-LOW(192)
	__PUTB1MN __base_y_G102,3
	LDI  R26,LOW(20)
	LDI  R27,0
	CALL _delay_ms
	LDI  R26,LOW(48)
	RCALL __lcd_write_nibble_G102
	__DELAY_USW 200
	LDI  R26,LOW(48)
	RCALL __lcd_write_nibble_G102
	__DELAY_USW 200
	LDI  R26,LOW(48)
	RCALL __lcd_write_nibble_G102
	__DELAY_USW 200
	LDI  R26,LOW(32)
	RCALL __lcd_write_nibble_G102
	__DELAY_USW 200
	LDI  R26,LOW(40)
	RCALL __lcd_write_data
	LDI  R26,LOW(4)
	RCALL __lcd_write_data
	LDI  R26,LOW(133)
	RCALL __lcd_write_data
	LDI  R26,LOW(6)
	RCALL __lcd_write_data
	RCALL _lcd_clear
_0x20A0001:
	ADIW R28,1
	RET
; .FEND

	.CSEG

	.CSEG

	.DSEG
_ESP_Flags:
	.BYTE 0x1
_ESP_LastAnswer:
	.BYTE 0x1
_ESP_StaticStrs:
	.BYTE 0x13
_ESP_ReceiveData:
	.BYTE 0x40
_ESP_ReceiveData_Index:
	.BYTE 0x2
_ESP_SearchIndex:
	.BYTE 0x2
_ESP_Buffer:
	.BYTE 0x80
__seed_G100:
	.BYTE 0x4
__base_y_G102:
	.BYTE 0x4

	.CSEG

	.CSEG
_delay_ms:
	adiw r26,0
	breq __delay_ms1
__delay_ms0:
	__DELAY_USW 0x7D0
	wdr
	sbiw r26,1
	brne __delay_ms0
__delay_ms1:
	ret

__GETW1P:
	LD   R30,X+
	LD   R31,X
	SBIW R26,1
	RET

__CPW02:
	CLR  R0
	CP   R0,R26
	CPC  R0,R27
	RET

__SAVELOCR6:
	ST   -Y,R21
__SAVELOCR5:
	ST   -Y,R20
__SAVELOCR4:
	ST   -Y,R19
__SAVELOCR3:
	ST   -Y,R18
__SAVELOCR2:
	ST   -Y,R17
	ST   -Y,R16
	RET

__LOADLOCR6:
	LDD  R21,Y+5
__LOADLOCR5:
	LDD  R20,Y+4
__LOADLOCR4:
	LDD  R19,Y+3
__LOADLOCR3:
	LDD  R18,Y+2
__LOADLOCR2:
	LDD  R17,Y+1
	LD   R16,Y
	RET

;END OF CODE MARKER
__END_OF_CODE:
