;CodeVisionAVR C Compiler V1.24.6 Professional
;(C) Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
;http://www.hpinfotech.com
;e-mail:office@hpinfotech.com

;Chip type              : ATmega16
;Program type           : Application
;Clock frequency        : 12,000000 MHz
;Memory model           : Small
;Optimize for           : Size
;(s)printf features     : int, width
;(s)scanf features      : int, width
;External SRAM size     : 0
;Data Stack size        : 256 byte(s)
;Heap size              : 0 byte(s)
;Promote char to int    : No
;char is unsigned       : Yes
;8 bit enums            : Yes
;Word align FLASH struct: No
;Enhanced core instructions    : On
;Automatic register allocation : On

	.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 __se_bit=0x40
	.EQU __sm_mask=0xB0
	.EQU __sm_adc_noise_red=0x10
	.EQU __sm_powerdown=0x20
	.EQU __sm_powersave=0x30
	.EQU __sm_standby=0xA0
	.EQU __sm_ext_standby=0xB0

	.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 __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 __ANDD1N
	ANDI R30,LOW(@0)
	ANDI R31,HIGH(@0)
	ANDI R22,BYTE3(@0)
	ANDI R23,BYTE4(@0)
	.ENDM

	.MACRO __ORD1N
	ORI  R30,LOW(@0)
	ORI  R31,HIGH(@0)
	ORI  R22,BYTE3(@0)
	ORI  R23,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 __CLRD1S
	LDI  R30,0
	STD  Y+@0,R30
	STD  Y+@0+1,R30
	STD  Y+@0+2,R30
	STD  Y+@0+3,R30
	.ENDM

	.MACRO __GETD1S
	LDD  R30,Y+@0
	LDD  R31,Y+@0+1
	LDD  R22,Y+@0+2
	LDD  R23,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 __POINTB1MN
	LDI  R30,LOW(@0+@1)
	.ENDM

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

	.MACRO __POINTW1FN
	LDI  R30,LOW(2*@0+@1)
	LDI  R31,HIGH(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 __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 __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 __GETD2S
	LDD  R26,Y+@0
	LDD  R27,Y+@0+1
	LDD  R24,Y+@0+2
	LDD  R25,Y+@0+3
	.ENDM

	.MACRO __GETB1MN
	LDS  R30,@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 __PUTDZ2
	STD  Z+@0,R26
	STD  Z+@0+1,R27
	STD  Z+@0+2,R24
	STD  Z+@0+3,R25
	.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 __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
	LDI  R26,LOW(@0+@1)
	LDI  R27,HIGH(@0+@1)
	CALL __EEPROMRDW
	ICALL
	.ENDM


	.MACRO __GETW1STACK
	IN   R26,SPL
	IN   R27,SPH
	ADIW R26,@0+1
	LD   R30,X+
	LD   R31,X
	.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 __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 __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 R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	CLR  R0
	ST   Z+,R0
	ST   Z,R0
	.ENDM

	.MACRO __CLRD1SX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	CLR  R0
	ST   Z+,R0
	ST   Z+,R0
	ST   Z+,R0
	ST   Z,R0
	.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 __PUTBSRX
	MOVW R30,R28
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z,R@1
	.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
	MOV  R30,R0
	.ENDM

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

	.CSEG
	.ORG 0

	.INCLUDE "robot.vec"
	.INCLUDE "robot.inc"

__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

;DISABLE WATCHDOG
	LDI  R31,0x18
	OUT  WDTCR,R31
	OUT  WDTCR,R30

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

;CLEAR SRAM
	LDI  R24,LOW(0x400)
	LDI  R25,HIGH(0x400)
	LDI  R26,0x60
__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:

;STACK POINTER INITIALIZATION
	LDI  R30,LOW(0x45F)
	OUT  SPL,R30
	LDI  R30,HIGH(0x45F)
	OUT  SPH,R30

;DATA STACK POINTER INITIALIZATION
	LDI  R28,LOW(0x160)
	LDI  R29,HIGH(0x160)

	JMP  _main

	.ESEG
	.ORG 0

	.DSEG
	.ORG 0x160
;       1 #include <mega16.h>
;       2 #include <delay.h> 
;       3 
;       4 #include <stdio.h>  // Standard Input/Output functions
;       5 #include <math.h>   // matematicke funkce
;       6 
;       7 unsigned char Enc1a,Enc1b,Enc1c,Enc1d,Enc2a,Enc2b,Enc2c,Enc2d,baterie,bat,M1I,M2I,stav,UhelCHR,BezpSoucet;  
_M2I:
	.BYTE 0x1
_stav:
	.BYTE 0x1
_UhelCHR:
	.BYTE 0x1
_BezpSoucet:
	.BYTE 0x1
;       8 int PocitadloZnaku,UhelDEG,uh;
_PocitadloZnaku:
	.BYTE 0x2
_UhelDEG:
	.BYTE 0x2
_uh:
	.BYTE 0x2
;       9 char Znak,rychlost,Smer, Cidla, Zabezpeceni,Nasobek;
_Znak:
	.BYTE 0x1
_rychlost:
	.BYTE 0x1
_Smer:
	.BYTE 0x1
_Cidla:
	.BYTE 0x1
_Zabezpeceni:
	.BYTE 0x1
_Nasobek:
	.BYTE 0x1
;      10 long int ENC1,ENC2;
_ENC1:
	.BYTE 0x4
_ENC2:
	.BYTE 0x4
;      11 
;      12 unsigned char PrijateSlovo[10];
_PrijateSlovo:
	.BYTE 0xA
;      13 unsigned char BAT[5];
_BAT:
	.BYTE 0x5
;      14 
;      15 int POM;
_POM:
	.BYTE 0x2
;      16 
;      17 // I2C Bus functions
;      18 #asm
;      19    .equ __i2c_port=0x1B ;PORTA
   .equ __i2c_port=0x1B ;PORTA
;      20    .equ __sda_bit=6
   .equ __sda_bit=6
;      21    .equ __scl_bit=7
   .equ __scl_bit=7
;      22 #endasm
;      23 #include <i2c.h>
;      24 
;      25 // Alphanumeric LCD Module functions
;      26 #asm
;      27    .equ __lcd_port=0x15 ;PORTC
   .equ __lcd_port=0x15 ;PORTC
;      28 #endasm
;      29 #include <lcd.h>
;      30 
;      31 #define RXB8 1
;      32 #define TXB8 0
;      33 #define UPE 2
;      34 #define OVR 3
;      35 #define FE 4
;      36 #define UDRE 5
;      37 #define RXC 7
;      38 
;      39 #define FRAMING_ERROR (1<<FE)
;      40 #define PARITY_ERROR (1<<UPE)
;      41 #define DATA_OVERRUN (1<<OVR)
;      42 #define DATA_REGISTER_EMPTY (1<<UDRE)
;      43 #define RX_COMPLETE (1<<RXC)
;      44 
;      45 // USART Receiver buffer
;      46 #define RX_BUFFER_SIZE 8
;      47 char rx_buffer[RX_BUFFER_SIZE];
_rx_buffer:
	.BYTE 0x8
;      48 
;      49 
;      50 void IICzapis(unsigned char adresa, unsigned char data) //I2C pro desku MD23
;      51 {

	.CSEG
_IICzapis:
;      52   i2c_start();
	CALL SUBOPT_0x0
;      53   i2c_write(0xB0);
;      54   delay_ms(2);
	CALL SUBOPT_0x1
;      55   i2c_write(adresa); 
	CALL SUBOPT_0x2
;      56   delay_ms(2);
	CALL SUBOPT_0x1
;      57   i2c_write(data);delay_ms(5);
	LD   R30,Y
	CALL SUBOPT_0x3
;      58   i2c_stop();
	CALL _i2c_stop
;      59   delay_ms(3);
	LDI  R30,LOW(3)
	LDI  R31,HIGH(3)
	ST   -Y,R31
	ST   -Y,R30
	CALL _delay_ms
;      60 }              
	ADIW R28,2
	RET
;      61 
;      62 unsigned char IICcteni(unsigned char adresa) //I2C pro desku MD23
;      63 { 
_IICcteni:
;      64 unsigned char Data;
;      65   i2c_start();
	ST   -Y,R16
;	adresa -> Y+1
;	Data -> R16
	CALL SUBOPT_0x0
;      66   i2c_write(0xB0); 
;      67 delay_ms(5);
	CALL SUBOPT_0x4
;      68   i2c_write(adresa);
	CALL SUBOPT_0x2
;      69 delay_ms(5);
	CALL SUBOPT_0x4
;      70   i2c_start();
	CALL _i2c_start
;      71   i2c_write(0xB1); 
	LDI  R30,LOW(177)
	CALL SUBOPT_0x3
;      72 delay_ms(5);
;      73   Data=i2c_read(0);
	CALL SUBOPT_0x5
;      74   i2c_stop();
;      75   return Data;                    
	RJMP _0xAA
;      76   
;      77 }
;      78 
;      79 void IICzapis2(unsigned char adresa, unsigned char data) //I2C pro desku CMPS03
;      80 {
;      81   i2c_start();
;      82   i2c_write(0xC0);
;      83   delay_ms(2);
;      84   i2c_write(adresa); 
;      85   delay_ms(2);
;      86   i2c_write(data);delay_ms(5);
;      87   i2c_stop();
;      88   delay_ms(3);
;      89 }              
;      90 
;      91 unsigned char IICcteni2(unsigned char adresa) //I2C pro desku CMPS03
;      92 { 
_IICcteni2:
;      93 unsigned char Data;
;      94   i2c_start();
	ST   -Y,R16
;	adresa -> Y+1
;	Data -> R16
	CALL _i2c_start
;      95   i2c_write(0xC0); 
	LDI  R30,LOW(192)
	CALL SUBOPT_0x3
;      96 delay_ms(5);
;      97   i2c_write(adresa);
	CALL SUBOPT_0x2
;      98 delay_ms(5);
	CALL SUBOPT_0x4
;      99   i2c_start();
	CALL _i2c_start
;     100   i2c_write(0xC1); 
	LDI  R30,LOW(193)
	CALL SUBOPT_0x3
;     101 delay_ms(5);
;     102   Data=i2c_read(0);
	CALL SUBOPT_0x5
;     103   i2c_stop();
;     104   return Data;                    
_0xAA:
	LDD  R16,Y+0
	ADIW R28,2
	RET
;     105   
;     106 }
;     107 
;     108  void ZjistiHodnoty(void)
;     109  {
_ZjistiHodnoty:
;     110  
;     111  baterie=IICcteni(10); 
	LDI  R30,LOW(10)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R12,R30
;     112  UhelCHR=IICcteni2(1);                               
	CALL SUBOPT_0x6
;     113         
;     114         Enc1a=IICcteni(2);
	LDI  R30,LOW(2)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R4,R30
;     115         Enc1b=IICcteni(3);
	LDI  R30,LOW(3)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R5,R30
;     116         Enc1c=IICcteni(4);
	LDI  R30,LOW(4)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R6,R30
;     117         Enc1d=IICcteni(5);  
	LDI  R30,LOW(5)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R7,R30
;     118         
;     119         Enc2a=IICcteni(6); 
	LDI  R30,LOW(6)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R8,R30
;     120         Enc2b=IICcteni(7);
	LDI  R30,LOW(7)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R9,R30
;     121         Enc2c=IICcteni(8);
	LDI  R30,LOW(8)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R10,R30
;     122         Enc2d=IICcteni(9);  
	LDI  R30,LOW(9)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R11,R30
;     123      
;     124         ENC1=Enc1c;
	MOV  R30,R6
	CLR  R31
	CLR  R22
	CLR  R23
	STS  _ENC1,R30
	STS  _ENC1+1,R31
	STS  _ENC1+2,R22
	STS  _ENC1+3,R23
;     125         ENC1<<=8;
	LDS  R26,_ENC1
	LDS  R27,_ENC1+1
	LDS  R24,_ENC1+2
	LDS  R25,_ENC1+3
	LDI  R30,LOW(8)
	CALL __LSLD12
	STS  _ENC1,R30
	STS  _ENC1+1,R31
	STS  _ENC1+2,R22
	STS  _ENC1+3,R23
;     126         ENC1=ENC1+Enc1d;    
	MOV  R30,R7
	LDS  R26,_ENC1
	LDS  R27,_ENC1+1
	LDS  R24,_ENC1+2
	LDS  R25,_ENC1+3
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD12
	STS  _ENC1,R30
	STS  _ENC1+1,R31
	STS  _ENC1+2,R22
	STS  _ENC1+3,R23
;     127         
;     128         ENC2=Enc2c;
	MOV  R30,R10
	CLR  R31
	CLR  R22
	CLR  R23
	STS  _ENC2,R30
	STS  _ENC2+1,R31
	STS  _ENC2+2,R22
	STS  _ENC2+3,R23
;     129         ENC2<<=8;
	LDS  R26,_ENC2
	LDS  R27,_ENC2+1
	LDS  R24,_ENC2+2
	LDS  R25,_ENC2+3
	LDI  R30,LOW(8)
	CALL __LSLD12
	STS  _ENC2,R30
	STS  _ENC2+1,R31
	STS  _ENC2+2,R22
	STS  _ENC2+3,R23
;     130         ENC2=ENC2+Enc2d; 
	MOV  R30,R11
	LDS  R26,_ENC2
	LDS  R27,_ENC2+1
	LDS  R24,_ENC2+2
	LDS  R25,_ENC2+3
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD12
	STS  _ENC2,R30
	STS  _ENC2+1,R31
	STS  _ENC2+2,R22
	STS  _ENC2+3,R23
;     131           
;     132         M1I=IICcteni(11);
	LDI  R30,LOW(11)
	ST   -Y,R30
	CALL _IICcteni
	MOV  R14,R30
;     133         M2I=IICcteni(12);
	LDI  R30,LOW(12)
	ST   -Y,R30
	CALL _IICcteni
	STS  _M2I,R30
;     134         BezpSoucet=baterie+ENC1+ENC2+ M1I+M2I+PINB.0+PINB.1+PINB.2+PINB.3+PINB.4+stav+UhelCHR;
	LDS  R30,_ENC1
	LDS  R31,_ENC1+1
	LDS  R22,_ENC1+2
	LDS  R23,_ENC1+3
	MOV  R26,R12
	CLR  R27
	CLR  R24
	CLR  R25
	CALL __ADDD12
	LDS  R26,_ENC2
	LDS  R27,_ENC2+1
	LDS  R24,_ENC2+2
	LDS  R25,_ENC2+3
	CALL __ADDD21
	MOV  R30,R14
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDS  R30,_M2I
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDI  R30,0
	SBIC 0x16,0
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDI  R30,0
	SBIC 0x16,1
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDI  R30,0
	SBIC 0x16,2
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDI  R30,0
	SBIC 0x16,3
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDI  R30,0
	SBIC 0x16,4
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDS  R30,_stav
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD21
	LDS  R30,_UhelCHR
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD12
	STS  _BezpSoucet,R30
;     135        
;     136           printf("#%03d%06d%06d%03d%d%d%d%d%d%d%03d%03d*\n%c ",baterie,ENC1,ENC2, M1I+M2I,PINB.0,PINB.1,PINB.2,PINB.3,PINB.4,stav,UhelCHR,BezpSoucet,13);    //ENC1 a ENC2 nabyvaji hodnot int coz je 5 mist a znamenko je 6te misto  
	__POINTW1FN _0,0
	ST   -Y,R31
	ST   -Y,R30
	MOV  R30,R12
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDS  R30,_ENC1
	LDS  R31,_ENC1+1
	LDS  R22,_ENC1+2
	LDS  R23,_ENC1+3
	CALL __PUTPARD1
	LDS  R30,_ENC2
	LDS  R31,_ENC2+1
	LDS  R22,_ENC2+2
	LDS  R23,_ENC2+3
	CALL __PUTPARD1
	LDS  R30,_M2I
	ADD  R30,R14
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDI  R30,0
	SBIC 0x16,0
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDI  R30,0
	SBIC 0x16,1
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDI  R30,0
	SBIC 0x16,2
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDI  R30,0
	SBIC 0x16,3
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDI  R30,0
	SBIC 0x16,4
	LDI  R30,1
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDS  R30,_stav
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDS  R30,_UhelCHR
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	LDS  R30,_BezpSoucet
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __PUTPARD1
	__GETD1N 0xD
	CALL __PUTPARD1
	LDI  R24,52
	CALL _printf
	ADIW R28,54
;     137         
;     138          // printf("B:%03d E1:%03d%03d%03d%03d E2:%03d%03d%03d%03d I1:%03d I2:%03d \n %c ",baterie,Enc1a,Enc1b,Enc1c,Enc1d, Enc2a,Enc2b,Enc2c,Enc2d, M1I,M2I,13);      
;     139     
;     140          lcd_gotoxy(13,0);
	LDI  R30,LOW(13)
	CALL SUBOPT_0x7
;     141          lcd_putsf(". V");
	__POINTW1FN _0,43
	ST   -Y,R31
	ST   -Y,R30
	CALL _lcd_putsf
;     142          bat=ceil(baterie/100);  
	MOV  R26,R12
	CALL SUBOPT_0x8
	CALL SUBOPT_0x9
;     143          baterie=baterie-bat*100;
	LDI  R30,LOW(100)
	MUL  R30,R26
	MOV  R30,R0
	SUB  R12,R30
;     144          lcd_gotoxy(11,0); 
	LDI  R30,LOW(11)
	CALL SUBOPT_0x7
;     145          lcd_putchar(bat+48);
	CALL SUBOPT_0xA
;     146          bat=ceil(baterie/10);  
	MOV  R26,R12
	CALL SUBOPT_0xB
	CALL SUBOPT_0x9
;     147          baterie=baterie-bat*10;
	LDI  R30,LOW(10)
	MUL  R30,R26
	MOV  R30,R0
	SUB  R12,R30
;     148          lcd_gotoxy(12,0); 
	LDI  R30,LOW(12)
	CALL SUBOPT_0x7
;     149          lcd_putchar(bat+48);  
	CALL SUBOPT_0xA
;     150          bat=ceil(baterie);  
	MOV  R30,R12
	CALL SUBOPT_0xC
	CALL __CFD1
	MOV  R13,R30
;     151          baterie=baterie-bat;
	SUB  R12,R13
;     152          lcd_gotoxy(14,0); 
	LDI  R30,LOW(14)
	CALL SUBOPT_0x7
;     153          lcd_putchar(bat+48);
	CALL SUBOPT_0xA
;     154          
;     155          UhelCHR=IICcteni2(1); 
	CALL SUBOPT_0x6
;     156           
;     157          UhelDEG=UhelCHR*1411; 
	LDS  R26,_UhelCHR
	LDI  R27,0
	LDI  R30,LOW(1411)
	LDI  R31,HIGH(1411)
	CALL __MULW12U
	STS  _UhelDEG,R30
	STS  _UhelDEG+1,R31
;     158          
;     159          uh=ceil(UhelCHR/100); 
	LDS  R26,_UhelCHR
	CALL SUBOPT_0x8
	CALL __CFD1
	STS  _uh,R30
	STS  _uh+1,R31
;     160          lcd_gotoxy(1,1); 
	LDI  R30,LOW(1)
	CALL SUBOPT_0xD
;     161          lcd_putchar(uh+48);
;     162          UhelCHR=UhelCHR-uh*100;
	LDI  R30,LOW(100)
	LDI  R31,HIGH(100)
	CALL SUBOPT_0xE
;     163          
;     164          uh=ceil(UhelCHR/10); 
	LDS  R26,_UhelCHR
	CALL SUBOPT_0xB
	CALL __CFD1
	STS  _uh,R30
	STS  _uh+1,R31
;     165          lcd_gotoxy(2,1); 
	LDI  R30,LOW(2)
	CALL SUBOPT_0xD
;     166          lcd_putchar(uh+48);
;     167          UhelCHR=UhelCHR-uh*10; 
	LDI  R30,LOW(10)
	LDI  R31,HIGH(10)
	CALL SUBOPT_0xE
;     168          
;     169          uh=ceil(UhelCHR); 
	LDS  R30,_UhelCHR
	CALL SUBOPT_0xC
	CALL __CFD1
	STS  _uh,R30
	STS  _uh+1,R31
;     170          lcd_gotoxy(3,1); 
	LDI  R30,LOW(3)
	ST   -Y,R30
	LDI  R30,LOW(1)
	ST   -Y,R30
	CALL _lcd_gotoxy
;     171          lcd_putchar(uh+48);
	LDS  R30,_uh
	LDS  R31,_uh+1
	ADIW R30,48
	ST   -Y,R30
	CALL _lcd_putchar
;     172       
;     173  }
	RET
;     174 
;     175 
;     176 #if RX_BUFFER_SIZE<256
;     177 unsigned char rx_wr_index,rx_rd_index,rx_counter;

	.DSEG
_rx_wr_index:
	.BYTE 0x1
_rx_rd_index:
	.BYTE 0x1
_rx_counter:
	.BYTE 0x1
;     178 #else
;     179 unsigned int rx_wr_index,rx_rd_index,rx_counter;
;     180 #endif
;     181 
;     182 // This flag is set on USART Receiver buffer overflow
;     183 bit rx_buffer_overflow;
;     184 
;     185 // USART Receiver interrupt service routine
;     186 interrupt [USART_RXC] void usart_rx_isr(void)
;     187 {

	.CSEG
_usart_rx_isr:
	ST   -Y,R26
	ST   -Y,R27
	ST   -Y,R30
	ST   -Y,R31
	IN   R30,SREG
	ST   -Y,R30
;     188 char status,data;
;     189 status=UCSRA;
	ST   -Y,R17
	ST   -Y,R16
;	status -> R16
;	data -> R17
	IN   R16,11
;     190 data=UDR;
	IN   R17,12
;     191 if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
	MOV  R30,R16
	ANDI R30,LOW(0x1C)
	BRNE _0x3
;     192    {
;     193    rx_buffer[rx_wr_index]=data;
	LDS  R26,_rx_wr_index
	LDI  R27,0
	SUBI R26,LOW(-_rx_buffer)
	SBCI R27,HIGH(-_rx_buffer)
	ST   X,R17
;     194    if (++rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0;
	LDS  R26,_rx_wr_index
	SUBI R26,-LOW(1)
	STS  _rx_wr_index,R26
	CPI  R26,LOW(0x8)
	BRNE _0x4
	LDI  R30,LOW(0)
	STS  _rx_wr_index,R30
;     195    if (++rx_counter == RX_BUFFER_SIZE)
_0x4:
	LDS  R26,_rx_counter
	SUBI R26,-LOW(1)
	STS  _rx_counter,R26
	CPI  R26,LOW(0x8)
	BRNE _0x5
;     196       {
;     197       rx_counter=0;
	LDI  R30,LOW(0)
	STS  _rx_counter,R30
;     198       rx_buffer_overflow=1;
	SET
	BLD  R2,0
;     199       };
_0x5:
;     200    };
_0x3:
;     201    
;     202    
;     203    if((data=='#') || (data=='@') || (data=='$'))
	CPI  R17,35
	BREQ _0x7
	CPI  R17,64
	BREQ _0x7
	CPI  R17,36
	BRNE _0x6
_0x7:
;     204    {
;     205      PocitadloZnaku=0;
	LDI  R30,0
	STS  _PocitadloZnaku,R30
	STS  _PocitadloZnaku+1,R30
;     206    }                  
;     207    
;     208    PocitadloZnaku++;
_0x6:
	LDS  R30,_PocitadloZnaku
	LDS  R31,_PocitadloZnaku+1
	ADIW R30,1
	STS  _PocitadloZnaku,R30
	STS  _PocitadloZnaku+1,R31
;     209    PrijateSlovo[PocitadloZnaku]=data;
	LDS  R26,_PocitadloZnaku
	LDS  R27,_PocitadloZnaku+1
	SUBI R26,LOW(-_PrijateSlovo)
	SBCI R27,HIGH(-_PrijateSlovo)
	ST   X,R17
;     210  
;     211 }
	LD   R16,Y+
	LD   R17,Y+
	LD   R30,Y+
	OUT  SREG,R30
	LD   R31,Y+
	LD   R30,Y+
	LD   R27,Y+
	LD   R26,Y+
	RETI
;     212 
;     213 #ifndef _DEBUG_TERMINAL_IO_
;     214 // Get a character from the USART Receiver buffer
;     215 #define _ALTERNATE_GETCHAR_
;     216 #pragma used+
;     217 char getchar(void)
;     218 {
;     219 char data;
;     220 while (rx_counter==0);
;	data -> R16
;     221 data=rx_buffer[rx_rd_index];
;     222 if (++rx_rd_index == RX_BUFFER_SIZE) rx_rd_index=0;
;     223 #asm("cli")
;     224 --rx_counter;
;     225 #asm("sei")
;     226 return data;
;     227 }
;     228 #pragma used-
;     229 #endif
;     230 
;     231 // USART Transmitter buffer
;     232 #define TX_BUFFER_SIZE 8
;     233 char tx_buffer[TX_BUFFER_SIZE];

	.DSEG
_tx_buffer:
	.BYTE 0x8
;     234 
;     235 #if TX_BUFFER_SIZE<256
;     236 unsigned char tx_wr_index,tx_rd_index,tx_counter;
_tx_wr_index:
	.BYTE 0x1
_tx_rd_index:
	.BYTE 0x1
_tx_counter:
	.BYTE 0x1
;     237 #else
;     238 unsigned int tx_wr_index,tx_rd_index,tx_counter;
;     239 #endif
;     240 
;     241 // USART Transmitter interrupt service routine
;     242 interrupt [USART_TXC] void usart_tx_isr(void)
;     243 {

	.CSEG
_usart_tx_isr:
	ST   -Y,R26
	ST   -Y,R30
	ST   -Y,R31
	IN   R30,SREG
	ST   -Y,R30
;     244 if (tx_counter)
	LDS  R30,_tx_counter
	CPI  R30,0
	BREQ _0xD
;     245    {
;     246    --tx_counter;
	SUBI R30,LOW(1)
	STS  _tx_counter,R30
;     247    UDR=tx_buffer[tx_rd_index];
	LDS  R30,_tx_rd_index
	LDI  R31,0
	SUBI R30,LOW(-_tx_buffer)
	SBCI R31,HIGH(-_tx_buffer)
	LD   R30,Z
	OUT  0xC,R30
;     248    if (++tx_rd_index == TX_BUFFER_SIZE) tx_rd_index=0;
	LDS  R26,_tx_rd_index
	SUBI R26,-LOW(1)
	STS  _tx_rd_index,R26
	CPI  R26,LOW(0x8)
	BRNE _0xE
	LDI  R30,LOW(0)
	STS  _tx_rd_index,R30
;     249    };
_0xE:
_0xD:
;     250 }
	LD   R30,Y+
	OUT  SREG,R30
	LD   R31,Y+
	LD   R30,Y+
	LD   R26,Y+
	RETI
;     251 
;     252 #ifndef _DEBUG_TERMINAL_IO_
;     253 // Write a character to the USART Transmitter buffer
;     254 #define _ALTERNATE_PUTCHAR_
;     255 #pragma used+
;     256 void putchar(char c)
;     257 {
_putchar:
;     258 while (tx_counter == TX_BUFFER_SIZE);
_0xF:
	LDS  R26,_tx_counter
	CPI  R26,LOW(0x8)
	BREQ _0xF
;     259 #asm("cli")
	cli
;     260 if (tx_counter || ((UCSRA & DATA_REGISTER_EMPTY)==0))
	LDS  R30,_tx_counter
	CPI  R30,0
	BRNE _0x13
	SBIC 0xB,5
	RJMP _0x12
_0x13:
;     261    {
;     262    tx_buffer[tx_wr_index]=c;
	LDS  R30,_tx_wr_index
	LDI  R31,0
	SUBI R30,LOW(-_tx_buffer)
	SBCI R31,HIGH(-_tx_buffer)
	LD   R26,Y
	STD  Z+0,R26
;     263    if (++tx_wr_index == TX_BUFFER_SIZE) tx_wr_index=0;
	LDS  R26,_tx_wr_index
	SUBI R26,-LOW(1)
	STS  _tx_wr_index,R26
	CPI  R26,LOW(0x8)
	BRNE _0x15
	LDI  R30,LOW(0)
	STS  _tx_wr_index,R30
;     264    ++tx_counter;
_0x15:
	LDS  R30,_tx_counter
	SUBI R30,-LOW(1)
	STS  _tx_counter,R30
;     265    }
;     266 else
	RJMP _0x16
_0x12:
;     267    UDR=c;
	LD   R30,Y
	OUT  0xC,R30
;     268 #asm("sei")
_0x16:
	sei
;     269 }
	RJMP _0xA9
;     270 #pragma used-
;     271 #endif
;     272 
;     273 
;     274 void Stop(void)
;     275 {
_Stop:
;     276   IICzapis(0,128);
	CALL SUBOPT_0xF
;     277   IICzapis(1,128);
	CALL SUBOPT_0x10
;     278 }
	RET
;     279 
;     280 void Vpred(unsigned char R)
;     281 {
_Vpred:
;     282   IICzapis(0,128+R); 
	LDI  R30,LOW(0)
	ST   -Y,R30
	LDD  R30,Y+1
	CALL SUBOPT_0x11
;     283 
;     284 } 
	RJMP _0xA9
;     285 void Vzad(unsigned char R)
;     286 {
_Vzad:
;     287   IICzapis(0,128-R); 
	LDI  R30,LOW(0)
	ST   -Y,R30
	LDD  R26,Y+1
	LDI  R30,LOW(128)
	SUB  R30,R26
	ST   -Y,R30
	CALL _IICzapis
;     288 
;     289 }
	RJMP _0xA9
;     290 void Vlevo(unsigned char R)
;     291 {
_Vlevo:
;     292   IICzapis(1,128-R/2); 
	CALL SUBOPT_0x12
	LDI  R26,LOW(128)
	SUB  R26,R30
	ST   -Y,R26
	CALL _IICzapis
;     293 
;     294 }
	RJMP _0xA9
;     295 void Vpravo(unsigned char R)
;     296 { 
_Vpravo:
;     297   IICzapis(1,128+R/2);
	CALL SUBOPT_0x12
	CALL SUBOPT_0x11
;     298 
;     299 }
_0xA9:
	ADIW R28,1
	RET
;     300 
;     301 void JedDrahu(void)
;     302 { 
_JedDrahu:
;     303   unsigned int rychlostPamatuj, DrahovyRozdil;
;     304   long int Draha;
;     305   char Hotovo;
;     306   rychlostPamatuj=rychlost;
	SBIW R28,4
	CALL __SAVELOCR5
;	rychlostPamatuj -> R16,R17
;	DrahovyRozdil -> R18,R19
;	Draha -> Y+5
;	Hotovo -> R20
	LDS  R30,_rychlost
	LDI  R31,0
	__PUTW1R 16,17
;     307   rychlost=30;
	LDI  R30,LOW(30)
	STS  _rychlost,R30
;     308   Hotovo=0; 
	LDI  R20,LOW(0)
;     309   Smer=PrijateSlovo[2];  
	__GETB1MN _PrijateSlovo,2
	STS  _Smer,R30
;     310   
;     311   //Draha=(PrijateSlovo[3]-48)*10000+(PrijateSlovo[4]-48)*1000+(PrijateSlovo[5]-48)*100+(PrijateSlovo[6]-48)*10+(PrijateSlovo[7]-48);
;     312   
;     313   Draha= (PrijateSlovo[3]-48);
	__GETB1MN _PrijateSlovo,3
	SUBI R30,LOW(48)
	CLR  R31
	CLR  R22
	CLR  R23
	CALL SUBOPT_0x13
;     314   Draha=Draha*10 + (PrijateSlovo[4]-48);
	__GETB1MN _PrijateSlovo,4
	CALL SUBOPT_0x14
;     315   Draha=Draha*10 + (PrijateSlovo[5]-48);
	__GETB1MN _PrijateSlovo,5
	CALL SUBOPT_0x14
;     316   Draha=Draha*10 + (PrijateSlovo[6]-48);
	__GETB1MN _PrijateSlovo,6
	CALL SUBOPT_0x14
;     317   Draha=Draha*10 + (PrijateSlovo[7]-48);
	__GETB1MN _PrijateSlovo,7
	SUBI R30,LOW(48)
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD12
	__PUTD1S 5
;     318        
;     319   for(;Hotovo==0;)
_0x18:
	CPI  R20,0
	BREQ PC+3
	JMP _0x19
;     320   {  
;     321      switch (Smer)
	LDS  R30,_Smer
;     322           {
;     323           case 0: Stop();
	CPI  R30,0
	BRNE _0x1D
	CALL _Stop
;     324                   break;
	RJMP _0x1C
;     325           case 1: Vpred(rychlost);
_0x1D:
	CPI  R30,LOW(0x1)
	BRNE _0x1E
	CALL SUBOPT_0x15
;     326                   break;  
	RJMP _0x1C
;     327           case 2: Vzad(rychlost);
_0x1E:
	CPI  R30,LOW(0x2)
	BRNE _0x1F
	CALL SUBOPT_0x16
;     328                   break;          
	RJMP _0x1C
;     329           case 3: Vlevo(rychlost);
_0x1F:
	CPI  R30,LOW(0x3)
	BRNE _0x20
	CALL SUBOPT_0x17
;     330                   break;    
	RJMP _0x1C
;     331           case 4: Vpravo(rychlost);
_0x20:
	CPI  R30,LOW(0x4)
	BRNE _0x1C
	CALL SUBOPT_0x18
;     332                   break;
;     333           } 
_0x1C:
;     334           
;     335           DrahovyRozdil=Draha-((abs(ENC1)+abs(ENC2))/ 2);
	CALL SUBOPT_0x19
	PUSH R31
	PUSH R30
	CALL SUBOPT_0x1A
	POP  R26
	POP  R27
	CALL SUBOPT_0x1B
	__GETD2S 5
	CLR  R22
	CLR  R23
	CALL __SWAPD12
	CALL __SUBD12
	__PUTW1R 18,19
;     336           
;     337           if ( (DrahovyRozdil<=250) &&(DrahovyRozdil>100))
	LDI  R30,LOW(250)
	LDI  R31,HIGH(250)
	CP   R30,R18
	CPC  R31,R19
	BRLO _0x23
	LDI  R30,LOW(100)
	LDI  R31,HIGH(100)
	CP   R30,R18
	CPC  R31,R19
	BRLO _0x24
_0x23:
	RJMP _0x22
_0x24:
;     338           {
;     339            rychlost=12;
	LDI  R30,LOW(12)
	STS  _rychlost,R30
;     340           } 
;     341           if ( (DrahovyRozdil<=100) )
_0x22:
	LDI  R30,LOW(100)
	LDI  R31,HIGH(100)
	CP   R30,R18
	CPC  R31,R19
	BRLO _0x25
;     342           {
;     343            rychlost=7;
	LDI  R30,LOW(7)
	STS  _rychlost,R30
;     344           }
;     345           
;     346            Cidla= PINB.0+ PINB.1*2+ PINB.2*4+ PINB.3*8+PINB.4*16;
_0x25:
	LDI  R30,0
	SBIC 0x16,0
	LDI  R30,1
	PUSH R30
	LDI  R30,0
	SBIC 0x16,1
	LDI  R30,1
	CALL SUBOPT_0x1C
	POP  R26
	ADD  R30,R26
	PUSH R30
	LDI  R30,0
	SBIC 0x16,2
	LDI  R30,1
	CALL SUBOPT_0x1D
	POP  R26
	ADD  R30,R26
	PUSH R30
	LDI  R30,0
	SBIC 0x16,3
	LDI  R30,1
	CALL SUBOPT_0x1E
	POP  R26
	ADD  R30,R26
	PUSH R30
	LDI  R30,0
	SBIC 0x16,4
	LDI  R30,1
	CALL SUBOPT_0x1F
	POP  R26
	CALL SUBOPT_0x20
;     347            if (Cidla != 31) //nekde je prekazka
	BREQ _0x26
;     348            {
;     349              stav = 2;
	CALL SUBOPT_0x21
;     350              Stop(); 
;     351              Smer=0;
;     352              PrijateSlovo[1]='A';
	__PUTB1MN _PrijateSlovo,1
;     353              PocitadloZnaku=0;
	LDI  R30,0
	STS  _PocitadloZnaku,R30
	STS  _PocitadloZnaku+1,R30
;     354              break;
	RJMP _0x19
;     355            } 
;     356            
;     357            
;     358            ZjistiHodnoty();    
_0x26:
	CALL _ZjistiHodnoty
;     359                 
;     360            if( ((abs(ENC1)+abs(ENC2))/ 2)  >=  Draha)
	CALL SUBOPT_0x19
	PUSH R31
	PUSH R30
	CALL SUBOPT_0x1A
	POP  R26
	POP  R27
	CALL SUBOPT_0x1B
	MOVW R26,R30
	__GETD1S 5
	CLR  R24
	CLR  R25
	CALL __CPD21
	BRLT _0x27
;     361            {
;     362              
;     363              Stop();
	CALL _Stop
;     364              Smer=0;
	LDI  R30,LOW(0)
	STS  _Smer,R30
;     365              Hotovo=1;
	LDI  R20,LOW(1)
;     366              PocitadloZnaku=0;
	LDI  R30,0
	STS  _PocitadloZnaku,R30
	STS  _PocitadloZnaku+1,R30
;     367              delay_ms(500);
	CALL SUBOPT_0x22
;     368              IICzapis(16,32); // snuluj pocitadla
	CALL SUBOPT_0x23
;     369              rychlost=rychlostPamatuj; // nastav puivodni rychlost
	__GETW1R 16,17
	STS  _rychlost,R30
;     370              //break;
;     371            } 
;     372    }
_0x27:
	RJMP _0x18
_0x19:
;     373  stav=0;
	LDI  R30,LOW(0)
	STS  _stav,R30
;     374  PrijateSlovo[1]='A';
	LDI  R30,LOW(65)
	__PUTB1MN _PrijateSlovo,1
;     375  PocitadloZnaku=0;
	LDI  R30,0
	STS  _PocitadloZnaku,R30
	STS  _PocitadloZnaku+1,R30
;     376 }
	CALL __LOADLOCR5
	ADIW R28,9
	RET
;     377 
;     378 
;     379 // Timer 0 overflow interrupt service routine
;     380 interrupt [TIM0_OVF] void timer0_ovf_isr(void)
;     381 {
_timer0_ovf_isr:
;     382 // Place your code here   
;     383 
;     384 
;     385 }
	RETI
;     386 
;     387 // Timer 1 overflow interrupt service routine
;     388 interrupt [TIM1_OVF] void timer1_ovf_isr(void)
;     389 {
_timer1_ovf_isr:
	ST   -Y,R30
	ST   -Y,R31
	IN   R30,SREG
	ST   -Y,R30
;     390 // Place your code here 
;     391 POM++; 
	LDS  R30,_POM
	LDS  R31,_POM+1
	ADIW R30,1
	STS  _POM,R30
	STS  _POM+1,R31
;     392   
;     393 
;     394 
;     395 
;     396 }
	LD   R30,Y+
	OUT  SREG,R30
	LD   R31,Y+
	LD   R30,Y+
	RETI
;     397 
;     398 // Timer 2 overflow interrupt service routine
;     399 interrupt [TIM2_OVF] void timer2_ovf_isr(void)
;     400 {
_timer2_ovf_isr:
;     401 // Place your code here
;     402 
;     403 }
	RETI
;     404 
;     405 // Declare your global variables here
;     406 
;     407 void main(void)
;     408 {
_main:
;     409 // Declare your local variables here
;     410 
;     411 // Input/Output Ports initialization
;     412 // Port A initialization
;     413 // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
;     414 // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
;     415 PORTA=0x00;
	LDI  R30,LOW(0)
	OUT  0x1B,R30
;     416 DDRA=0x00;
	OUT  0x1A,R30
;     417 
;     418 // Port B initialization
;     419 // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
;     420 // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
;     421 PORTB=0xFF;
	LDI  R30,LOW(255)
	OUT  0x18,R30
;     422 DDRB=0x00;
	LDI  R30,LOW(0)
	OUT  0x17,R30
;     423 
;     424 // Port C initialization
;     425 // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
;     426 // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
;     427 PORTC=0x00;
	OUT  0x15,R30
;     428 DDRC=0x00;
	OUT  0x14,R30
;     429 
;     430 // Port D initialization
;     431 // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
;     432 // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
;     433 PORTD=0x00;
	OUT  0x12,R30
;     434 DDRD=0x00;
	OUT  0x11,R30
;     435 
;     436 // Timer/Counter 0 initialization
;     437 // Clock source: System Clock
;     438 // Clock value: 10,800 kHz
;     439 // Mode: Normal top=FFh
;     440 // OC0 output: Disconnected
;     441 TCCR0=0x05;
	LDI  R30,LOW(5)
	OUT  0x33,R30
;     442 TCNT0=0x00;
	LDI  R30,LOW(0)
	OUT  0x32,R30
;     443 OCR0=0x00;
	OUT  0x3C,R30
;     444 
;     445 // Timer/Counter 1 initialization
;     446 // Clock source: System Clock
;     447 // Clock value: 10,800 kHz
;     448 // Mode: Normal top=FFFFh
;     449 // OC1A output: Discon.
;     450 // OC1B output: Discon.
;     451 // Noise Canceler: Off
;     452 // Input Capture on Falling Edge
;     453 // Timer 1 Overflow Interrupt: On
;     454 // Input Capture Interrupt: Off
;     455 // Compare A Match Interrupt: Off
;     456 // Compare B Match Interrupt: Off
;     457 TCCR1A=0x00;
	OUT  0x2F,R30
;     458 TCCR1B=0x03;
	LDI  R30,LOW(3)
	OUT  0x2E,R30
;     459 TCNT1H=0x00;
	LDI  R30,LOW(0)
	OUT  0x2D,R30
;     460 TCNT1L=0x00;
	OUT  0x2C,R30
;     461 ICR1H=0x00;
	OUT  0x27,R30
;     462 ICR1L=0x00;
	OUT  0x26,R30
;     463 OCR1AH=0x00;
	OUT  0x2B,R30
;     464 OCR1AL=0x00;
	OUT  0x2A,R30
;     465 OCR1BH=0x00;
	OUT  0x29,R30
;     466 OCR1BL=0x00;
	OUT  0x28,R30
;     467 
;     468 // Timer/Counter 2 initialization
;     469 // Clock source: System Clock
;     470 // Clock value: 10,800 kHz
;     471 // Mode: Normal top=FFh
;     472 // OC2 output: Disconnected
;     473 ASSR=0x00;
	OUT  0x22,R30
;     474 TCCR2=0x07;
	LDI  R30,LOW(7)
	OUT  0x25,R30
;     475 TCNT2=0x00;
	LDI  R30,LOW(0)
	OUT  0x24,R30
;     476 OCR2=0x00;
	OUT  0x23,R30
;     477 
;     478 // External Interrupt(s) initialization
;     479 // INT0: Off
;     480 // INT1: Off
;     481 // INT2: Off
;     482 MCUCR=0x00;
	OUT  0x35,R30
;     483 MCUCSR=0x00;
	OUT  0x34,R30
;     484 
;     485 // Timer(s)/Counter(s) Interrupt(s) initialization
;     486 TIMSK=0x45;
	LDI  R30,LOW(69)
	OUT  0x39,R30
;     487 
;     488 // USART initialization
;     489 // Communication Parameters: 8 Data, 1 Stop, No Parity
;     490 // USART Receiver: On
;     491 // USART Transmitter: On
;     492 // USART Mode: Asynchronous
;     493 // USART Baud rate: 9600
;     494 UCSRA=0x00;
	LDI  R30,LOW(0)
	OUT  0xB,R30
;     495 UCSRB=0xD8;
	LDI  R30,LOW(216)
	OUT  0xA,R30
;     496 UCSRC=0x86;
	LDI  R30,LOW(134)
	OUT  0x20,R30
;     497 UBRRH=0x00;
	LDI  R30,LOW(0)
	OUT  0x20,R30
;     498 UBRRL=0x47;
	LDI  R30,LOW(71)
	OUT  0x9,R30
;     499 
;     500 // Analog Comparator initialization
;     501 // Analog Comparator: Off
;     502 // Analog Comparator Input Capture by Timer/Counter 1: Off
;     503 ACSR=0x80;
	LDI  R30,LOW(128)
	OUT  0x8,R30
;     504 SFIOR=0x00;
	LDI  R30,LOW(0)
	OUT  0x30,R30
;     505 
;     506 // I2C Bus initialization
;     507 i2c_init();
	CALL _i2c_init
;     508 
;     509 // LCD module initialization
;     510 lcd_init(16);
	LDI  R30,LOW(16)
	ST   -Y,R30
	CALL _lcd_init
;     511 lcd_clear();  
	CALL _lcd_clear
;     512 
;     513 lcd_gotoxy(0,0);
	LDI  R30,LOW(0)
	CALL SUBOPT_0x7
;     514 lcd_putchar('A'); 
	LDI  R30,LOW(65)
	ST   -Y,R30
	CALL _lcd_putchar
;     515 lcd_putchar('B');
	LDI  R30,LOW(66)
	ST   -Y,R30
	CALL _lcd_putchar
;     516 
;     517 	
;     518 
;     519 	
;     520 
;     521 IICzapis(14,10);  //  nabehy motoru  1-pomalu 5-default 10-nejrychleji
	LDI  R30,LOW(14)
	ST   -Y,R30
	LDI  R30,LOW(10)
	CALL SUBOPT_0x24
;     522 delay_ms(20);
;     523 IICzapis(16,0x20);      // reset pocitadel enkoderu     
	CALL SUBOPT_0x23
;     524 delay_ms(20);
	CALL SUBOPT_0x25
;     525 IICzapis(15,2); 
	LDI  R30,LOW(15)
	ST   -Y,R30
	LDI  R30,LOW(2)
	CALL SUBOPT_0x24
;     526 delay_ms(20);
;     527 IICzapis(1,128); 
	CALL SUBOPT_0x10
;     528 delay_ms(20);
	CALL SUBOPT_0x25
;     529 IICzapis(0,128);
	CALL SUBOPT_0xF
;     530 delay_ms(10); 
	LDI  R30,LOW(10)
	LDI  R31,HIGH(10)
	ST   -Y,R31
	ST   -Y,R30
	CALL _delay_ms
;     531 rychlost=20;
	LDI  R30,LOW(20)
	STS  _rychlost,R30
;     532 stav=0;
	LDI  R30,LOW(0)
	STS  _stav,R30
;     533 
;     534 // Global enable interrupts
;     535 #asm("sei")
	sei
;     536 
;     537 
;     538 POM=0;
	LDI  R30,0
	STS  _POM,R30
	STS  _POM+1,R30
;     539 while (1)   // nekonecna smycka
_0x28:
;     540       {
;     541      Cidla= PINB.0+ PINB.1*2+ PINB.2*4+ PINB.3*8+PINB.4*16;
	LDI  R30,0
	SBIC 0x16,0
	LDI  R30,1
	PUSH R30
	LDI  R30,0
	SBIC 0x16,1
	LDI  R30,1
	CALL SUBOPT_0x1C
	POP  R26
	ADD  R30,R26
	PUSH R30
	LDI  R30,0
	SBIC 0x16,2
	LDI  R30,1
	CALL SUBOPT_0x1D
	POP  R26
	ADD  R30,R26
	PUSH R30
	LDI  R30,0
	SBIC 0x16,3
	LDI  R30,1
	CALL SUBOPT_0x1E
	POP  R26
	ADD  R30,R26
	PUSH R30
	LDI  R30,0
	SBIC 0x16,4
	LDI  R30,1
	CALL SUBOPT_0x1F
	POP  R26
	CALL SUBOPT_0x20
;     542      if (Cidla != 31) //nekde je prekazka
	BREQ _0x2B
;     543      {
;     544       stav = 2;
	CALL SUBOPT_0x21
;     545       Stop();
;     546       Smer=0;
;     547       PrijateSlovo[1]='A'; //znehodnot prikaz z PC
	__PUTB1MN _PrijateSlovo,1
;     548       PocitadloZnaku=0;
	LDI  R30,0
	STS  _PocitadloZnaku,R30
	STS  _PocitadloZnaku+1,R30
;     549      }
;     550   
;     551      ZjistiHodnoty();
_0x2B:
	CALL _ZjistiHodnoty
;     552      
;     553      if(PocitadloZnaku==9 && (PrijateSlovo[1]=='$') && (PrijateSlovo[9]=='*'))
	LDS  R26,_PocitadloZnaku
	LDS  R27,_PocitadloZnaku+1
	CPI  R26,LOW(0x9)
	LDI  R30,HIGH(0x9)
	CPC  R27,R30
	BRNE _0x2D
	__GETB1MN _PrijateSlovo,1
	CPI  R30,LOW(0x24)
	BRNE _0x2D
	__GETB1MN _PrijateSlovo,9
	CPI  R30,LOW(0x2A)
	BREQ _0x2E
_0x2D:
	RJMP _0x2C
_0x2E:
;     554      {
;     555       Zabezpeceni=PrijateSlovo[2]+(PrijateSlovo[3]-48)+(PrijateSlovo[4]-48)+(PrijateSlovo[5]-48)+(PrijateSlovo[6]-48)+(PrijateSlovo[7]-48);
	__GETB2MN _PrijateSlovo,2
	__GETB1MN _PrijateSlovo,3
	SUBI R30,LOW(48)
	ADD  R26,R30
	__GETB1MN _PrijateSlovo,4
	SUBI R30,LOW(48)
	ADD  R26,R30
	__GETB1MN _PrijateSlovo,5
	SUBI R30,LOW(48)
	ADD  R26,R30
	__GETB1MN _PrijateSlovo,6
	SUBI R30,LOW(48)
	ADD  R26,R30
	__GETB1MN _PrijateSlovo,7
	SUBI R30,LOW(48)
	ADD  R30,R26
	STS  _Zabezpeceni,R30
;     556       if (Zabezpeceni >=10)
	LDS  R26,_Zabezpeceni
	CPI  R26,LOW(0xA)
	BRLO _0x2F
;     557       {
;     558         Nasobek=(Zabezpeceni/10);
	LDI  R30,LOW(10)
	CALL __DIVB21U
	STS  _Nasobek,R30
;     559         Zabezpeceni=Zabezpeceni-Nasobek*10;
	LDS  R26,_Nasobek
	LDI  R30,LOW(10)
	MUL  R30,R26
	MOV  R30,R0
	LDS  R26,_Zabezpeceni
	SUB  R26,R30
	STS  _Zabezpeceni,R26
;     560       }
;     561       
;     562       if(Zabezpeceni == (PrijateSlovo[8]-48))
_0x2F:
	__GETB1MN _PrijateSlovo,8
	SUBI R30,LOW(48)
	LDS  R26,_Zabezpeceni
	CP   R30,R26
	BRNE _0x30
;     563       {
;     564         stav=1;
	LDI  R30,LOW(1)
	STS  _stav,R30
;     565         ZjistiHodnoty();
	CALL _ZjistiHodnoty
;     566         delay_ms(500);
	CALL SUBOPT_0x22
;     567         JedDrahu();  
	CALL _JedDrahu
;     568       }
;     569      }
_0x30:
;     570      
;     571       if(PocitadloZnaku==4);
_0x2C:
	LDS  R26,_PocitadloZnaku
	LDS  R27,_PocitadloZnaku+1
	CPI  R26,LOW(0x4)
	LDI  R30,HIGH(0x4)
	CPC  R27,R30
	BRNE _0x31
;     572       { 
_0x31:
;     573         if((PrijateSlovo[1]=='#') && (PrijateSlovo[4]=='*') && (PrijateSlovo[2]==PrijateSlovo[3]) )
	__GETB1MN _PrijateSlovo,1
	CPI  R30,LOW(0x23)
	BRNE _0x33
	__GETB1MN _PrijateSlovo,4
	CPI  R30,LOW(0x2A)
	BRNE _0x33
	__GETB2MN _PrijateSlovo,2
	__GETB1MN _PrijateSlovo,3
	CP   R30,R26
	BREQ _0x34
_0x33:
	RJMP _0x32
_0x34:
;     574         {
;     575           Smer=PrijateSlovo[2];
	__GETB1MN _PrijateSlovo,2
	STS  _Smer,R30
;     576         }
;     577         
;     578         if((PrijateSlovo[1]=='@') && (PrijateSlovo[4]=='*') && (PrijateSlovo[2]==PrijateSlovo[3]) )
_0x32:
	__GETB1MN _PrijateSlovo,1
	CPI  R30,LOW(0x40)
	BRNE _0x36
	__GETB1MN _PrijateSlovo,4
	CPI  R30,LOW(0x2A)
	BRNE _0x36
	__GETB2MN _PrijateSlovo,2
	__GETB1MN _PrijateSlovo,3
	CP   R30,R26
	BREQ _0x37
_0x36:
	RJMP _0x35
_0x37:
;     579         {
;     580           switch(PrijateSlovo[2])
	__GETB1MN _PrijateSlovo,2
;     581             {
;     582               case 5:rychlost=5;                
	CPI  R30,LOW(0x5)
	BRNE _0x3B
	LDI  R30,LOW(5)
	RJMP _0xAB
;     583                   break;  
;     584               case 6:rychlost=15;
_0x3B:
	CPI  R30,LOW(0x6)
	BRNE _0x3C
	LDI  R30,LOW(15)
	RJMP _0xAB
;     585                   break; 
;     586               case 7:rychlost=30;
_0x3C:
	CPI  R30,LOW(0x7)
	BRNE _0x3D
	LDI  R30,LOW(30)
	RJMP _0xAB
;     587                   break; 
;     588               case 8:rychlost=50;
_0x3D:
	CPI  R30,LOW(0x8)
	BRNE _0x3E
	LDI  R30,LOW(50)
	RJMP _0xAB
;     589                   break; 
;     590               case 9:rychlost=80;
_0x3E:
	CPI  R30,LOW(0x9)
	BRNE _0x3A
	LDI  R30,LOW(80)
_0xAB:
	STS  _rychlost,R30
;     591                   break;    
;     592             }
_0x3A:
;     593         }
;     594         
;     595         switch (Smer)
_0x35:
	LDS  R30,_Smer
;     596           {
;     597           case 0: Stop();
	CPI  R30,0
	BRNE _0x43
	CALL _Stop
;     598                   break;
	RJMP _0x42
;     599           case 1: Vpred(rychlost);
_0x43:
	CPI  R30,LOW(0x1)
	BRNE _0x44
	CALL SUBOPT_0x15
;     600                   break;  
	RJMP _0x42
;     601           case 2: Vzad(rychlost);
_0x44:
	CPI  R30,LOW(0x2)
	BRNE _0x45
	CALL SUBOPT_0x16
;     602                   break;          
	RJMP _0x42
;     603           case 3: Vlevo(rychlost);
_0x45:
	CPI  R30,LOW(0x3)
	BRNE _0x46
	CALL SUBOPT_0x17
;     604                   break;    
	RJMP _0x42
;     605           case 4: Vpravo(rychlost);
_0x46:
	CPI  R30,LOW(0x4)
	BRNE _0x47
	CALL SUBOPT_0x18
;     606                   break;
	RJMP _0x42
;     607           case 'X': IICzapis(16,32);
_0x47:
	CPI  R30,LOW(0x58)
	BRNE _0x42
	CALL SUBOPT_0x23
;     608                    break;    
;     609           }
_0x42:
;     610       
;     611       } 
;     612       
;     613       // Place your code here
;     614 
;     615       };
	RJMP _0x28
;     616 }
_0x49:
	RJMP _0x49

__put_G2:
	put:
	LD   R26,Y
	LDD  R27,Y+1
	CALL __GETW1P
	SBIW R30,0
	BREQ _0x4A
	CALL __GETW1P
	ADIW R30,1
	ST   X+,R30
	ST   X,R31
	SBIW R30,1
	LDD  R26,Y+2
	STD  Z+0,R26
	RJMP _0x4B
_0x4A:
	LDD  R30,Y+2
	ST   -Y,R30
	CALL _putchar
_0x4B:
	ADIW R28,3
	RET
__print_G2:
	SBIW R28,6
	CALL __SAVELOCR6
	LDI  R16,0
_0x4C:
	LDD  R30,Y+16
	LDD  R31,Y+16+1
	ADIW R30,1
	STD  Y+16,R30
	STD  Y+16+1,R31
	SBIW R30,1
	LPM  R30,Z
	MOV  R19,R30
	CPI  R30,0
	BRNE PC+3
	JMP _0x4E
	MOV  R30,R16
	CPI  R30,0
	BRNE _0x52
	CPI  R19,37
	BRNE _0x53
	LDI  R16,LOW(1)
	RJMP _0x54
_0x53:
	CALL SUBOPT_0x26
_0x54:
	RJMP _0x51
_0x52:
	CPI  R30,LOW(0x1)
	BRNE _0x55
	CPI  R19,37
	BRNE _0x56
	CALL SUBOPT_0x26
	LDI  R16,LOW(0)
	RJMP _0x51
_0x56:
	LDI  R16,LOW(2)
	LDI  R21,LOW(0)
	LDI  R17,LOW(0)
	CPI  R19,45
	BRNE _0x57
	LDI  R17,LOW(1)
	RJMP _0x51
_0x57:
	CPI  R19,43
	BRNE _0x58
	LDI  R21,LOW(43)
	RJMP _0x51
_0x58:
	CPI  R19,32
	BRNE _0x59
	LDI  R21,LOW(32)
	RJMP _0x51
_0x59:
	RJMP _0x5A
_0x55:
	CPI  R30,LOW(0x2)
	BRNE _0x5B
_0x5A:
	LDI  R20,LOW(0)
	LDI  R16,LOW(3)
	CPI  R19,48
	BRNE _0x5C
	ORI  R17,LOW(128)
	RJMP _0x51
_0x5C:
	RJMP _0x5D
_0x5B:
	CPI  R30,LOW(0x3)
	BREQ PC+3
	JMP _0x51
_0x5D:
	CPI  R19,48
	BRLO _0x60
	CPI  R19,58
	BRLO _0x61
_0x60:
	RJMP _0x5F
_0x61:
	MOV  R26,R20
	LDI  R30,LOW(10)
	MUL  R30,R26
	MOV  R30,R0
	MOV  R20,R30
	MOV  R30,R19
	SUBI R30,LOW(48)
	ADD  R20,R30
	RJMP _0x51
_0x5F:
	MOV  R30,R19
	CPI  R30,LOW(0x63)
	BRNE _0x65
	CALL SUBOPT_0x27
	LD   R30,X
	CALL SUBOPT_0x28
	RJMP _0x66
_0x65:
	CPI  R30,LOW(0x73)
	BRNE _0x68
	CALL SUBOPT_0x27
	CALL SUBOPT_0x29
	CALL _strlen
	MOV  R16,R30
	RJMP _0x69
_0x68:
	CPI  R30,LOW(0x70)
	BRNE _0x6B
	CALL SUBOPT_0x27
	CALL SUBOPT_0x29
	CALL _strlenf
	MOV  R16,R30
	ORI  R17,LOW(8)
_0x69:
	ORI  R17,LOW(2)
	ANDI R17,LOW(127)
	LDI  R18,LOW(0)
	RJMP _0x6C
_0x6B:
	CPI  R30,LOW(0x64)
	BREQ _0x6F
	CPI  R30,LOW(0x69)
	BRNE _0x70
_0x6F:
	ORI  R17,LOW(4)
	RJMP _0x71
_0x70:
	CPI  R30,LOW(0x75)
	BRNE _0x72
_0x71:
	LDI  R30,LOW(_tbl10_G2*2)
	LDI  R31,HIGH(_tbl10_G2*2)
	STD  Y+6,R30
	STD  Y+6+1,R31
	LDI  R16,LOW(5)
	RJMP _0x73
_0x72:
	CPI  R30,LOW(0x58)
	BRNE _0x75
	ORI  R17,LOW(8)
	RJMP _0x76
_0x75:
	CPI  R30,LOW(0x78)
	BREQ PC+3
	JMP _0xA4
_0x76:
	LDI  R30,LOW(_tbl16_G2*2)
	LDI  R31,HIGH(_tbl16_G2*2)
	STD  Y+6,R30
	STD  Y+6+1,R31
	LDI  R16,LOW(4)
_0x73:
	SBRS R17,2
	RJMP _0x78
	CALL SUBOPT_0x27
	CALL __GETW1P
	STD  Y+10,R30
	STD  Y+10+1,R31
	LDD  R26,Y+10
	LDD  R27,Y+10+1
	SBIW R26,0
	BRGE _0x79
	CALL __ANEGW1
	STD  Y+10,R30
	STD  Y+10+1,R31
	LDI  R21,LOW(45)
_0x79:
	CPI  R21,0
	BREQ _0x7A
	SUBI R16,-LOW(1)
	RJMP _0x7B
_0x7A:
	ANDI R17,LOW(251)
_0x7B:
	RJMP _0x7C
_0x78:
	CALL SUBOPT_0x27
	CALL __GETW1P
	STD  Y+10,R30
	STD  Y+10+1,R31
_0x7C:
_0x6C:
	SBRC R17,0
	RJMP _0x7D
_0x7E:
	CP   R16,R20
	BRSH _0x80
	SBRS R17,7
	RJMP _0x81
	SBRS R17,2
	RJMP _0x82
	ANDI R17,LOW(251)
	MOV  R19,R21
	SUBI R16,LOW(1)
	RJMP _0x83
_0x82:
	LDI  R19,LOW(48)
_0x83:
	RJMP _0x84
_0x81:
	LDI  R19,LOW(32)
_0x84:
	CALL SUBOPT_0x26
	SUBI R20,LOW(1)
	RJMP _0x7E
_0x80:
_0x7D:
	MOV  R18,R16
	SBRS R17,1
	RJMP _0x85
_0x86:
	CPI  R18,0
	BREQ _0x88
	SBRS R17,3
	RJMP _0x89
	LDD  R30,Y+6
	LDD  R31,Y+6+1
	ADIW R30,1
	STD  Y+6,R30
	STD  Y+6+1,R31
	SBIW R30,1
	LPM  R30,Z
	RJMP _0xAC
_0x89:
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	LD   R30,X+
	STD  Y+6,R26
	STD  Y+6+1,R27
_0xAC:
	ST   -Y,R30
	CALL SUBOPT_0x2A
	CPI  R20,0
	BREQ _0x8B
	SUBI R20,LOW(1)
_0x8B:
	SUBI R18,LOW(1)
	RJMP _0x86
_0x88:
	RJMP _0x8C
_0x85:
_0x8E:
	LDI  R19,LOW(48)
	LDD  R30,Y+6
	LDD  R31,Y+6+1
	ADIW R30,2
	STD  Y+6,R30
	STD  Y+6+1,R31
	SBIW R30,2
	CALL __GETW1PF
	STD  Y+8,R30
	STD  Y+8+1,R31
                                      ldd  r26,y+10  ;R26,R27=n
                                      ldd  r27,y+11
                                  calc_digit:
                                      cp   r26,r30
                                      cpc  r27,r31
                                      brlo calc_digit_done
	SUBI R19,-LOW(1)
	                                  sub  r26,r30
	                                  sbc  r27,r31
	                                  brne calc_digit
                                  calc_digit_done:
                                      std  Y+10,r26 ;n=R26,R27
                                      std  y+11,r27
	LDI  R30,LOW(57)
	CP   R30,R19
	BRSH _0x90
	SBRS R17,3
	RJMP _0x91
	SUBI R19,-LOW(7)
	RJMP _0x92
_0x91:
	SUBI R19,-LOW(39)
_0x92:
_0x90:
	SBRC R17,4
	RJMP _0x94
	LDI  R30,LOW(48)
	CP   R30,R19
	BRLO _0x96
	LDD  R26,Y+8
	LDD  R27,Y+8+1
	CPI  R26,LOW(0x1)
	LDI  R30,HIGH(0x1)
	CPC  R27,R30
	BRNE _0x95
_0x96:
	ORI  R17,LOW(16)
	RJMP _0x98
_0x95:
	CP   R20,R18
	BRLO _0x9A
	SBRS R17,0
	RJMP _0x9B
_0x9A:
	RJMP _0x99
_0x9B:
	LDI  R19,LOW(32)
	SBRS R17,7
	RJMP _0x9C
	LDI  R19,LOW(48)
	ORI  R17,LOW(16)
_0x98:
	SBRS R17,2
	RJMP _0x9D
	ANDI R17,LOW(251)
	ST   -Y,R21
	CALL SUBOPT_0x2A
	CPI  R20,0
	BREQ _0x9E
	SUBI R20,LOW(1)
_0x9E:
_0x9D:
_0x9C:
_0x94:
	CALL SUBOPT_0x26
	CPI  R20,0
	BREQ _0x9F
	SUBI R20,LOW(1)
_0x9F:
_0x99:
	SUBI R18,LOW(1)
	LDD  R26,Y+8
	LDD  R27,Y+8+1
	LDI  R30,LOW(1)
	LDI  R31,HIGH(1)
	CP   R30,R26
	CPC  R31,R27
	BRSH _0x8F
	RJMP _0x8E
_0x8F:
_0x8C:
	SBRS R17,0
	RJMP _0xA0
_0xA1:
	CPI  R20,0
	BREQ _0xA3
	SUBI R20,LOW(1)
	LDI  R30,LOW(32)
	CALL SUBOPT_0x28
	RJMP _0xA1
_0xA3:
_0xA0:
_0xA4:
_0x66:
	LDI  R16,LOW(0)
_0x51:
	RJMP _0x4C
_0x4E:
	CALL __LOADLOCR6
	ADIW R28,18
	RET
_printf:
	PUSH R15
	MOV  R15,R24
	SBIW R28,2
	ST   -Y,R17
	ST   -Y,R16
	MOVW R26,R28
	CALL __ADDW2R15
	__PUTW2R 16,17
	LDI  R30,0
	STD  Y+2,R30
	STD  Y+2+1,R30
	MOVW R26,R28
	ADIW R26,4
	CALL __ADDW2R15
	CALL __GETW1P
	ST   -Y,R31
	ST   -Y,R30
	ST   -Y,R17
	ST   -Y,R16
	MOVW R30,R28
	ADIW R30,6
	ST   -Y,R31
	ST   -Y,R30
	CALL __print_G2
	LDD  R17,Y+1
	LDD  R16,Y+0
	ADIW R28,4
	POP  R15
	RET
_abs:
    ld   r30,y+
    ld   r31,y+
    sbiw r30,0
    brpl __abs0
    com  r30
    com  r31
    adiw r30,1
__abs0:
    ret
    .equ __lcd_direction=__lcd_port-1
    .equ __lcd_pin=__lcd_port-2
    .equ __lcd_rs=0
    .equ __lcd_rd=1
    .equ __lcd_enable=2
    .equ __lcd_busy_flag=7

	.DSEG
__base_y_G4:
	.BYTE 0x4
__lcd_x:
	.BYTE 0x1
__lcd_y:
	.BYTE 0x1
__lcd_maxx:
	.BYTE 0x1

	.CSEG
__lcd_delay_G4:
    ldi   r31,15
__lcd_delay0:
    dec   r31
    brne  __lcd_delay0
	RET
__lcd_ready:
    in    r26,__lcd_direction
    andi  r26,0xf                 ;set as input
    out   __lcd_direction,r26
    sbi   __lcd_port,__lcd_rd     ;RD=1
    cbi   __lcd_port,__lcd_rs     ;RS=0
__lcd_busy:
	CALL __lcd_delay_G4
    sbi   __lcd_port,__lcd_enable ;EN=1
	CALL __lcd_delay_G4
    in    r26,__lcd_pin
    cbi   __lcd_port,__lcd_enable ;EN=0
	CALL __lcd_delay_G4
    sbi   __lcd_port,__lcd_enable ;EN=1
	CALL __lcd_delay_G4
    cbi   __lcd_port,__lcd_enable ;EN=0
    sbrc  r26,__lcd_busy_flag
    rjmp  __lcd_busy
	RET
__lcd_write_nibble_G4:
    andi  r26,0xf0
    or    r26,r27
    out   __lcd_port,r26          ;write
    sbi   __lcd_port,__lcd_enable ;EN=1
	CALL __lcd_delay_G4
    cbi   __lcd_port,__lcd_enable ;EN=0
	CALL __lcd_delay_G4
	RET
__lcd_write_data:
    cbi  __lcd_port,__lcd_rd 	  ;RD=0
    in    r26,__lcd_direction
    ori   r26,0xf0 | (1<<__lcd_rs) | (1<<__lcd_rd) | (1<<__lcd_enable) ;set as output    
    out   __lcd_direction,r26
    in    r27,__lcd_port
    andi  r27,0xf
    ld    r26,y
	CALL __lcd_write_nibble_G4
    ld    r26,y
    swap  r26
	CALL __lcd_write_nibble_G4
    sbi   __lcd_port,__lcd_rd     ;RD=1
	ADIW R28,1
	RET
__lcd_read_nibble_G4:
    sbi   __lcd_port,__lcd_enable ;EN=1
	CALL __lcd_delay_G4
    in    r30,__lcd_pin           ;read
    cbi   __lcd_port,__lcd_enable ;EN=0
	CALL __lcd_delay_G4
    andi  r30,0xf0
	RET
_lcd_read_byte0_G4:
	CALL __lcd_delay_G4
	CALL __lcd_read_nibble_G4
    mov   r26,r30
	CALL __lcd_read_nibble_G4
    cbi   __lcd_port,__lcd_rd     ;RD=0
    swap  r30
    or    r30,r26
	RET
_lcd_gotoxy:
	CALL __lcd_ready
	LD   R30,Y
	LDI  R31,0
	SUBI R30,LOW(-__base_y_G4)
	SBCI R31,HIGH(-__base_y_G4)
	LD   R30,Z
	LDD  R26,Y+1
	ADD  R30,R26
	ST   -Y,R30
	CALL __lcd_write_data
	LDD  R30,Y+1
	STS  __lcd_x,R30
	LD   R30,Y
	STS  __lcd_y,R30
	ADIW R28,2
	RET
_lcd_clear:
	CALL __lcd_ready
	LDI  R30,LOW(2)
	CALL SUBOPT_0x2B
	LDI  R30,LOW(12)
	CALL SUBOPT_0x2B
	LDI  R30,LOW(1)
	ST   -Y,R30
	CALL __lcd_write_data
	LDI  R30,LOW(0)
	STS  __lcd_y,R30
	STS  __lcd_x,R30
	RET
_lcd_putchar:
    push r30
    push r31
    ld   r26,y
    set
    cpi  r26,10
    breq __lcd_putchar1
    clt
	LDS  R30,__lcd_x
	SUBI R30,-LOW(1)
	STS  __lcd_x,R30
	LDS  R30,__lcd_maxx
	LDS  R26,__lcd_x
	CP   R30,R26
	BRSH _0xA6
	__lcd_putchar1:
	LDS  R30,__lcd_y
	SUBI R30,-LOW(1)
	STS  __lcd_y,R30
	LDI  R30,LOW(0)
	ST   -Y,R30
	LDS  R30,__lcd_y
	ST   -Y,R30
	CALL _lcd_gotoxy
	brts __lcd_putchar0
_0xA6:
    rcall __lcd_ready
    sbi  __lcd_port,__lcd_rs ;RS=1
    ld   r26,y
    st   -y,r26
    rcall __lcd_write_data
__lcd_putchar0:
    pop  r31
    pop  r30
	ADIW R28,1
	RET
_lcd_putsf:
    ld   r30,y
    ldd  r31,y+1
__lcd_putsf0:
	lpm
    tst  r0
    breq __lcd_putsf1
    adiw r30,1
    st   -y,r0
    rcall _lcd_putchar
    rjmp __lcd_putsf0
__lcd_putsf1:
	ADIW R28,2
	RET
__long_delay_G4:
    clr   r26
    clr   r27
__long_delay0:
    sbiw  r26,1         ;2 cycles
    brne  __long_delay0 ;2 cycles
	RET
__lcd_init_write_G4:
    cbi  __lcd_port,__lcd_rd 	  ;RD=0
    in    r26,__lcd_direction
    ori   r26,0xf7                ;set as output
    out   __lcd_direction,r26
    in    r27,__lcd_port
    andi  r27,0xf
    ld    r26,y
	CALL __lcd_write_nibble_G4
    sbi   __lcd_port,__lcd_rd     ;RD=1
	ADIW R28,1
	RET
_lcd_init:
    cbi   __lcd_port,__lcd_enable ;EN=0
    cbi   __lcd_port,__lcd_rs     ;RS=0
	LD   R30,Y
	STS  __lcd_maxx,R30
	SUBI R30,-LOW(128)
	__PUTB1MN __base_y_G4,2
	LD   R30,Y
	SUBI R30,-LOW(192)
	__PUTB1MN __base_y_G4,3
	CALL SUBOPT_0x2C
	CALL SUBOPT_0x2C
	CALL SUBOPT_0x2C
	CALL __long_delay_G4
	LDI  R30,LOW(32)
	ST   -Y,R30
	CALL __lcd_init_write_G4
	CALL __long_delay_G4
	LDI  R30,LOW(40)
	CALL SUBOPT_0x2D
	LDI  R30,LOW(4)
	CALL SUBOPT_0x2D
	LDI  R30,LOW(133)
	CALL SUBOPT_0x2D
    in    r26,__lcd_direction
    andi  r26,0xf                 ;set as input
    out   __lcd_direction,r26
    sbi   __lcd_port,__lcd_rd     ;RD=1
	CALL _lcd_read_byte0_G4
	CPI  R30,LOW(0x5)
	BREQ _0xA7
	LDI  R30,LOW(0)
	RJMP _0xA8
_0xA7:
	CALL __lcd_ready
	LDI  R30,LOW(6)
	ST   -Y,R30
	CALL __lcd_write_data
	CALL _lcd_clear
	LDI  R30,LOW(1)
_0xA8:
	ADIW R28,1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x0:
	CALL _i2c_start
	LDI  R30,LOW(176)
	ST   -Y,R30
	JMP  _i2c_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1:
	LDI  R30,LOW(2)
	LDI  R31,HIGH(2)
	ST   -Y,R31
	ST   -Y,R30
	JMP  _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2:
	LDD  R30,Y+1
	ST   -Y,R30
	JMP  _i2c_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x3:
	ST   -Y,R30
	CALL _i2c_write
	LDI  R30,LOW(5)
	LDI  R31,HIGH(5)
	ST   -Y,R31
	ST   -Y,R30
	JMP  _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x4:
	LDI  R30,LOW(5)
	LDI  R31,HIGH(5)
	ST   -Y,R31
	ST   -Y,R30
	JMP  _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x5:
	LDI  R30,LOW(0)
	ST   -Y,R30
	CALL _i2c_read
	MOV  R16,R30
	CALL _i2c_stop
	MOV  R30,R16
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x6:
	LDI  R30,LOW(1)
	ST   -Y,R30
	CALL _IICcteni2
	STS  _UhelCHR,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x7:
	ST   -Y,R30
	LDI  R30,LOW(0)
	ST   -Y,R30
	JMP  _lcd_gotoxy

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x8:
	LDI  R30,LOW(100)
	CALL __DIVB21U
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __CDF1
	CALL __PUTPARD1
	JMP  _ceil

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x9:
	CALL __CFD1
	MOV  R13,R30
	MOV  R26,R13
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0xA:
	MOV  R30,R13
	SUBI R30,-LOW(48)
	ST   -Y,R30
	JMP  _lcd_putchar

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xB:
	LDI  R30,LOW(10)
	CALL __DIVB21U
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __CDF1
	CALL __PUTPARD1
	JMP  _ceil

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xC:
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __CDF1
	CALL __PUTPARD1
	JMP  _ceil

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xD:
	ST   -Y,R30
	LDI  R30,LOW(1)
	ST   -Y,R30
	CALL _lcd_gotoxy
	LDS  R30,_uh
	LDS  R31,_uh+1
	ADIW R30,48
	ST   -Y,R30
	CALL _lcd_putchar
	LDS  R26,_uh
	LDS  R27,_uh+1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xE:
	CALL __MULW12
	LDS  R26,_UhelCHR
	LDI  R27,0
	CALL __SWAPW12
	SUB  R30,R26
	SBC  R31,R27
	STS  _UhelCHR,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xF:
	LDI  R30,LOW(0)
	ST   -Y,R30
	LDI  R30,LOW(128)
	ST   -Y,R30
	JMP  _IICzapis

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x10:
	LDI  R30,LOW(1)
	ST   -Y,R30
	LDI  R30,LOW(128)
	ST   -Y,R30
	JMP  _IICzapis

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x11:
	SUBI R30,-LOW(128)
	ST   -Y,R30
	JMP  _IICzapis

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x12:
	LDI  R30,LOW(1)
	ST   -Y,R30
	LDD  R30,Y+1
	LSR  R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x13:
	__PUTD1S 5
	__GETD2S 5
	__GETD1N 0xA
	CALL __MULD12
	MOVW R26,R30
	MOVW R24,R22
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x14:
	SUBI R30,LOW(48)
	CLR  R31
	CLR  R22
	CLR  R23
	CALL __ADDD12
	RJMP SUBOPT_0x13

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x15:
	LDS  R30,_rychlost
	ST   -Y,R30
	JMP  _Vpred

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x16:
	LDS  R30,_rychlost
	ST   -Y,R30
	JMP  _Vzad

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x17:
	LDS  R30,_rychlost
	ST   -Y,R30
	JMP  _Vlevo

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x18:
	LDS  R30,_rychlost
	ST   -Y,R30
	JMP  _Vpravo

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x19:
	LDS  R30,_ENC1
	LDS  R31,_ENC1+1
	ST   -Y,R31
	ST   -Y,R30
	JMP  _abs

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1A:
	LDS  R30,_ENC2
	LDS  R31,_ENC2+1
	ST   -Y,R31
	ST   -Y,R30
	JMP  _abs

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1B:
	ADD  R26,R30
	ADC  R27,R31
	MOVW R30,R26
	LSR  R31
	ROR  R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1C:
	MOV  R26,R30
	LDI  R30,LOW(2)
	MUL  R30,R26
	MOV  R30,R0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1D:
	MOV  R26,R30
	LDI  R30,LOW(4)
	MUL  R30,R26
	MOV  R30,R0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1E:
	MOV  R26,R30
	LDI  R30,LOW(8)
	MUL  R30,R26
	MOV  R30,R0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1F:
	MOV  R26,R30
	LDI  R30,LOW(16)
	MUL  R30,R26
	MOV  R30,R0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x20:
	ADD  R30,R26
	STS  _Cidla,R30
	LDS  R26,_Cidla
	CPI  R26,LOW(0x1F)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x21:
	LDI  R30,LOW(2)
	STS  _stav,R30
	CALL _Stop
	LDI  R30,LOW(0)
	STS  _Smer,R30
	LDI  R30,LOW(65)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x22:
	LDI  R30,LOW(500)
	LDI  R31,HIGH(500)
	ST   -Y,R31
	ST   -Y,R30
	JMP  _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x23:
	LDI  R30,LOW(16)
	ST   -Y,R30
	LDI  R30,LOW(32)
	ST   -Y,R30
	JMP  _IICzapis

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x24:
	ST   -Y,R30
	CALL _IICzapis
	LDI  R30,LOW(20)
	LDI  R31,HIGH(20)
	ST   -Y,R31
	ST   -Y,R30
	JMP  _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x25:
	LDI  R30,LOW(20)
	LDI  R31,HIGH(20)
	ST   -Y,R31
	ST   -Y,R30
	JMP  _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x26:
	ST   -Y,R19
	LDD  R30,Y+13
	LDD  R31,Y+13+1
	ST   -Y,R31
	ST   -Y,R30
	JMP  __put_G2

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x27:
	LDD  R26,Y+14
	LDD  R27,Y+14+1
	SBIW R26,4
	STD  Y+14,R26
	STD  Y+14+1,R27
	ADIW R26,4
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x28:
	ST   -Y,R30
	LDD  R30,Y+13
	LDD  R31,Y+13+1
	ST   -Y,R31
	ST   -Y,R30
	JMP  __put_G2

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x29:
	CALL __GETW1P
	STD  Y+6,R30
	STD  Y+6+1,R31
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2A:
	LDD  R30,Y+13
	LDD  R31,Y+13+1
	ST   -Y,R31
	ST   -Y,R30
	JMP  __put_G2

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2B:
	ST   -Y,R30
	CALL __lcd_write_data
	JMP  __lcd_ready

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2C:
	CALL __long_delay_G4
	LDI  R30,LOW(48)
	ST   -Y,R30
	JMP  __lcd_init_write_G4

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2D:
	ST   -Y,R30
	CALL __lcd_write_data
	JMP  __long_delay_G4

	.equ __i2c_dir=__i2c_port-1
	.equ __i2c_pin=__i2c_port-2
_i2c_init:
	cbi  __i2c_port,__scl_bit
	cbi  __i2c_port,__sda_bit
	sbi  __i2c_dir,__scl_bit
	cbi  __i2c_dir,__sda_bit
	rjmp __i2c_delay2
_i2c_start:
	cbi  __i2c_dir,__sda_bit
	cbi  __i2c_dir,__scl_bit
	clr  r30
	nop
	sbis __i2c_pin,__sda_bit
	ret
	sbis __i2c_pin,__scl_bit
	ret
	rcall __i2c_delay1
	sbi  __i2c_dir,__sda_bit
	rcall __i2c_delay1
	sbi  __i2c_dir,__scl_bit
	ldi  r30,1
__i2c_delay1:
	ldi  r22,20
	rjmp __i2c_delay2l
_i2c_stop:
	sbi  __i2c_dir,__sda_bit
	sbi  __i2c_dir,__scl_bit
	rcall __i2c_delay2
	cbi  __i2c_dir,__scl_bit
	rcall __i2c_delay1
	cbi  __i2c_dir,__sda_bit
__i2c_delay2:
	ldi  r22,40
__i2c_delay2l:
	dec  r22
	brne __i2c_delay2l
	ret
_i2c_read:
	ldi  r23,8
__i2c_read0:
	cbi  __i2c_dir,__scl_bit
	rcall __i2c_delay2
	clc
	sbic __i2c_pin,__sda_bit
	sec
	sbi  __i2c_dir,__scl_bit
	rcall __i2c_delay2
	rol  r30
	dec  r23
	brne __i2c_read0
	ld   r23,y+
	tst  r23
	brne __i2c_read1
	cbi  __i2c_dir,__sda_bit
	rjmp __i2c_read2
__i2c_read1:
	sbi  __i2c_dir,__sda_bit
__i2c_read2:
	rcall __i2c_delay1
	cbi  __i2c_dir,__scl_bit
	rcall __i2c_delay2
	sbi  __i2c_dir,__scl_bit
	rcall __i2c_delay1
	cbi  __i2c_dir,__sda_bit
	rjmp __i2c_delay1

_i2c_write:
	ld   r30,y+
	ldi  r23,8
__i2c_write0:
	lsl  r30
	brcc __i2c_write1
	cbi  __i2c_dir,__sda_bit
	rjmp __i2c_write2
__i2c_write1:
	sbi  __i2c_dir,__sda_bit
__i2c_write2:
	rcall __i2c_delay2
	cbi  __i2c_dir,__scl_bit
	rcall __i2c_delay2
	sbi  __i2c_dir,__scl_bit
	dec  r23
	brne __i2c_write0
	cbi  __i2c_dir,__sda_bit
	rcall __i2c_delay1
	cbi  __i2c_dir,__scl_bit
	rcall __i2c_delay2
	ldi  r30,1
	sbic __i2c_pin,__sda_bit
	clr  r30
	sbi  __i2c_dir,__scl_bit
	ret

_strlen:
	ld   r26,y+
	ld   r27,y+
	clr  r30
	clr  r31
__strlen0:
	ld   r22,x+
	tst  r22
	breq __strlen1
	adiw r30,1
	rjmp __strlen0
__strlen1:
	ret

_strlenf:
	clr  r26
	clr  r27
	ld   r30,y+
	ld   r31,y+
__strlenf0:
	lpm  r0,z+
	tst  r0
	breq __strlenf1
	adiw r26,1
	rjmp __strlenf0
__strlenf1:
	movw r30,r26
	ret

_delay_ms:
	ld   r30,y+
	ld   r31,y+
	adiw r30,0
	breq __delay_ms1
__delay_ms0:
	__DELAY_USW 0xBB8
	wdr
	sbiw r30,1
	brne __delay_ms0
__delay_ms1:
	ret

__ftrunc:
	ldd  r23,y+3
	ldd  r22,y+2
	ldd  r31,y+1
	ld   r30,y
	bst  r23,7
	lsl  r23
	sbrc r22,7
	sbr  r23,1
	mov  r25,r23
	subi r25,0x7e
	breq __ftrunc0
	brcs __ftrunc0
	cpi  r25,24
	brsh __ftrunc1
	clr  r26
	clr  r27
	clr  r24
__ftrunc2:
	sec
	ror  r24
	ror  r27
	ror  r26
	dec  r25
	brne __ftrunc2
	and  r30,r26
	and  r31,r27
	and  r22,r24
	rjmp __ftrunc1
__ftrunc0:
	clt
	clr  r23
	clr  r30
	clr  r31
	clr  r22
__ftrunc1:
	cbr  r22,0x80
	lsr  r23
	brcc __ftrunc3
	sbr  r22,0x80
__ftrunc3:
	bld  r23,7
	ld   r26,y+
	ld   r27,y+
	ld   r24,y+
	ld   r25,y+
	cp   r30,r26
	cpc  r31,r27
	cpc  r22,r24
	cpc  r23,r25
	bst  r25,7
	ret

_ceil:
	rcall __ftrunc
	brne __ceil1
__ceil0:
	ret
__ceil1:
	brts __ceil0
	ldi  r25,0x3f

__addfc:
	clr  r26
	clr  r27
	ldi  r24,0x80
	rjmp __addf12

__ADDW2R15:
	CLR  R0
	ADD  R26,R15
	ADC  R27,R0
	RET

__ADDD12:
	ADD  R30,R26
	ADC  R31,R27
	ADC  R22,R24
	ADC  R23,R25
	RET

__ADDD21:
	ADD  R26,R30
	ADC  R27,R31
	ADC  R24,R22
	ADC  R25,R23
	RET

__SUBD12:
	SUB  R30,R26
	SBC  R31,R27
	SBC  R22,R24
	SBC  R23,R25
	RET

__ANEGW1:
	COM  R30
	COM  R31
	ADIW R30,1
	RET

__ANEGD1:
	COM  R30
	COM  R31
	COM  R22
	COM  R23
	SUBI R30,-1
	SBCI R31,-1
	SBCI R22,-1
	SBCI R23,-1
	RET

__LSLD12:
	TST  R30
	MOV  R0,R30
	MOVW R30,R26
	MOVW R22,R24
	BREQ __LSLD12R
__LSLD12L:
	LSL  R30
	ROL  R31
	ROL  R22
	ROL  R23
	DEC  R0
	BRNE __LSLD12L
__LSLD12R:
	RET

__CBD1:
	MOV  R31,R30
	ADD  R31,R31
	SBC  R31,R31
	MOV  R22,R31
	MOV  R23,R31
	RET

__MULW12U:
	MUL  R31,R26
	MOV  R31,R0
	MUL  R30,R27
	ADD  R31,R0
	MUL  R30,R26
	MOV  R30,R0
	ADD  R31,R1
	RET

__MULD12U:
	MUL  R23,R26
	MOV  R23,R0
	MUL  R22,R27
	ADD  R23,R0
	MUL  R31,R24
	ADD  R23,R0
	MUL  R30,R25
	ADD  R23,R0
	MUL  R22,R26
	MOV  R22,R0
	ADD  R23,R1
	MUL  R31,R27
	ADD  R22,R0
	ADC  R23,R1
	MUL  R30,R24
	ADD  R22,R0
	ADC  R23,R1
	CLR  R24
	MUL  R31,R26
	MOV  R31,R0
	ADD  R22,R1
	ADC  R23,R24
	MUL  R30,R27
	ADD  R31,R0
	ADC  R22,R1
	ADC  R23,R24
	MUL  R30,R26
	MOV  R30,R0
	ADD  R31,R1
	ADC  R22,R24
	ADC  R23,R24
	RET

__MULW12:
	RCALL __CHKSIGNW
	RCALL __MULW12U
	BRTC __MULW121
	RCALL __ANEGW1
__MULW121:
	RET

__MULD12:
	RCALL __CHKSIGND
	RCALL __MULD12U
	BRTC __MULD121
	RCALL __ANEGD1
__MULD121:
	RET

__DIVB21U:
	CLR  R0
	LDI  R25,8
__DIVB21U1:
	LSL  R26
	ROL  R0
	SUB  R0,R30
	BRCC __DIVB21U2
	ADD  R0,R30
	RJMP __DIVB21U3
__DIVB21U2:
	SBR  R26,1
__DIVB21U3:
	DEC  R25
	BRNE __DIVB21U1
	MOV  R30,R26
	MOV  R26,R0
	RET

__CHKSIGNW:
	CLT
	SBRS R31,7
	RJMP __CHKSW1
	RCALL __ANEGW1
	SET
__CHKSW1:
	SBRS R27,7
	RJMP __CHKSW2
	COM  R26
	COM  R27
	ADIW R26,1
	BLD  R0,0
	INC  R0
	BST  R0,0
__CHKSW2:
	RET

__CHKSIGND:
	CLT
	SBRS R23,7
	RJMP __CHKSD1
	RCALL __ANEGD1
	SET
__CHKSD1:
	SBRS R25,7
	RJMP __CHKSD2
	CLR  R0
	COM  R26
	COM  R27
	COM  R24
	COM  R25
	ADIW R26,1
	ADC  R24,R0
	ADC  R25,R0
	BLD  R0,0
	INC  R0
	BST  R0,0
__CHKSD2:
	RET

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

__GETW1PF:
	LPM  R0,Z+
	LPM  R31,Z
	MOV  R30,R0
	RET

__PUTPARD1:
	ST   -Y,R23
	ST   -Y,R22
	ST   -Y,R31
	ST   -Y,R30
	RET

__SWAPD12:
	MOV  R1,R24
	MOV  R24,R22
	MOV  R22,R1
	MOV  R1,R25
	MOV  R25,R23
	MOV  R23,R1

__SWAPW12:
	MOV  R1,R27
	MOV  R27,R31
	MOV  R31,R1

__SWAPB12:
	MOV  R1,R26
	MOV  R26,R30
	MOV  R30,R1
	RET

__REPACK:
	LDI  R21,0x80
	EOR  R21,R23
	BRNE __REPACK0
	PUSH R21
	RJMP __ZERORES
__REPACK0:
	CPI  R21,0xFF
	BREQ __REPACK1
	LSL  R22
	LSL  R0
	ROR  R21
	ROR  R22
	MOV  R23,R21
	RET
__REPACK1:
	PUSH R21
	TST  R0
	BRMI __REPACK2
	RJMP __MAXRES
__REPACK2:
	RJMP __MINRES

__UNPACK:
	LDI  R21,0x80
	MOV  R1,R25
	AND  R1,R21
	LSL  R24
	ROL  R25
	EOR  R25,R21
	LSL  R21
	ROR  R24

__UNPACK1:
	LDI  R21,0x80
	MOV  R0,R23
	AND  R0,R21
	LSL  R22
	ROL  R23
	EOR  R23,R21
	LSL  R21
	ROR  R22
	RET

__CFD1:
	PUSH R21
	RCALL __UNPACK1
	CPI  R23,0x80
	BRLO __CFD10
	CPI  R23,0xFF
	BRCC __CFD10
	RJMP __ZERORES
__CFD10:
	LDI  R21,22
	SUB  R21,R23
	BRPL __CFD11
	NEG  R21
	CPI  R21,8
	BRLO __CFD17
	SER  R30
	SER  R31
	SER  R22
	LDI  R23,0x7F
	RJMP __CFD15
__CFD17:
	CLR  R23
	TST  R21
	BREQ __CFD15
__CFD18:
	LSL  R30
	ROL  R31
	ROL  R22
	ROL  R23
	DEC  R21
	BRNE __CFD18
	RJMP __CFD15
__CFD11:
	CLR  R23
__CFD12:
	CPI  R21,8
	BRLO __CFD13
	MOV  R30,R31
	MOV  R31,R22
	MOV  R22,R23
	SUBI R21,8
	RJMP __CFD12
__CFD13:
	TST  R21
	BREQ __CFD15
__CFD14:
	LSR  R23
	ROR  R22
	ROR  R31
	ROR  R30
	DEC  R21
	BRNE __CFD14
__CFD15:
	TST  R0
	BRPL __CFD16
	RCALL __ANEGD1
__CFD16:
	POP  R21
	RET

__CDF1U:
	SET
	RJMP __CDF1U0
__CDF1:
	CLT
__CDF1U0:
	SBIW R30,0
	SBCI R22,0
	SBCI R23,0
	BREQ __CDF10
	CLR  R0
	BRTS __CDF11
	TST  R23
	BRPL __CDF11
	COM  R0
	RCALL __ANEGD1
__CDF11:
	MOV  R1,R23
	LDI  R23,30
	TST  R1
__CDF12:
	BRMI __CDF13
	DEC  R23
	LSL  R30
	ROL  R31
	ROL  R22
	ROL  R1
	RJMP __CDF12
__CDF13:
	MOV  R30,R31
	MOV  R31,R22
	MOV  R22,R1
	PUSH R21
	RCALL __REPACK
	POP  R21
__CDF10:
	RET

__SWAPACC:
	MOV  R21,R30
	MOV  R30,R26
	MOV  R26,R21
	MOV  R21,R31
	MOV  R31,R27
	MOV  R27,R21
	MOV  R21,R22
	MOV  R22,R24
	MOV  R24,R21
	MOV  R21,R23
	MOV  R23,R25
	MOV  R25,R21
	MOV  R21,R0
	MOV  R0,R1
	MOV  R1,R21
	RET

__UADD12:
	ADD  R30,R26
	ADC  R31,R27
	ADC  R22,R24
	RET

__NEGMAN1:
	COM  R30
	COM  R31
	COM  R22
	SUBI R30,-1
	SBCI R31,-1
	SBCI R22,-1
	RET

__ADDF12:
	PUSH R21
	RCALL __UNPACK
	CPI  R25,0x80
	BREQ __ADDF129

__ADDF120:
	CPI  R23,0x80
	BREQ __ADDF128
__ADDF121:
	MOV  R21,R23
	SUB  R21,R25
	BRVS __ADDF129
	BRPL __ADDF122
	RCALL __SWAPACC
	RJMP __ADDF121
__ADDF122:
	CPI  R21,24
	BRLO __ADDF123
	CLR  R26
	CLR  R27
	CLR  R24
__ADDF123:
	CPI  R21,8
	BRLO __ADDF124
	MOV  R26,R27
	MOV  R27,R24
	CLR  R24
	SUBI R21,8
	RJMP __ADDF123
__ADDF124:
	TST  R21
	BREQ __ADDF126
__ADDF125:
	LSR  R24
	ROR  R27
	ROR  R26
	DEC  R21
	BRNE __ADDF125
__ADDF126:
	MOV  R21,R0
	EOR  R21,R1
	BRMI __ADDF127
	RCALL __UADD12
	BRCC __ADDF129
	ROR  R22
	ROR  R31
	ROR  R30
	INC  R23
	BRVC __ADDF129
	RJMP __MAXRES
__ADDF128:
	RCALL __SWAPACC
__ADDF129:
	RCALL __REPACK
	POP  R21
	RET
__ADDF127:
	SUB  R30,R26
	SBC  R31,R27
	SBC  R22,R24
	BREQ __ZERORES
	BRCC __ADDF1210
	COM  R0
	RCALL __NEGMAN1
__ADDF1210:
	TST  R22
	BRMI __ADDF129
	LSL  R30
	ROL  R31
	ROL  R22
	DEC  R23
	BRVC __ADDF1210

__MINRES:
	SER  R30
	SER  R31
	LDI  R22,0x7F
	SER  R23
	POP  R21
	RET

__ZERORES:
	CLR  R30
	CLR  R31
	CLR  R22
	CLR  R23
	POP  R21
	RET

__MAXRES:
	SER  R30
	SER  R31
	LDI  R22,0x7F
	LDI  R23,0x7F
	POP  R21
	RET

__CPD21:
	CP   R26,R30
	CPC  R27,R31
	CPC  R24,R22
	CPC  R25,R23
	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:
