;CodeVisionAVR C Compiler V1.24.0 Standard
;(C) Copyright 1998-2003 HP InfoTech s.r.l.
;http://www.hpinfotech.ro
;e-mail:office@hpinfotech.ro

;Chip type           : AT90S8535
;Clock frequency     : 4,000000 MHz
;Memory model        : Small
;Optimize for        : Size
;(s)printf features  : int, width
;(s)scanf features   : long, width
;External SRAM size  : 0
;Data Stack size     : 125 byte(s)
;Heap size           : 0 byte(s)
;Promote char to int : No
;char is unsigned    : Yes
;8 bit enums         : Yes
;Automatic register allocation : On
;Use AVR Studio 3 Terminal I/O   : No

	.DEVICE AT90S8535
	.LISTMAC
	.EQU UDRE=0x5
	.EQU RXC=0x7
	.EQU USR=0xB
	.EQU UDR=0xC
	.EQU EERE=0x0
	.EQU EEWE=0x1
	.EQU EEMWE=0x2
	.EQU SPSR=0xE
	.EQU SPDR=0xF
	.EQU EECR=0x1C
	.EQU EEDR=0x1D
	.EQU EEARL=0x1E
	.EQU EEARH=0x1F
	.EQU WDTCR=0x21
	.EQU MCUCR=0x35
	.EQU RAMPZ=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=0x30
	.EQU __sm_powerdown=0x20

	.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
	CLR  R30
	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 __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@2,@0+@1
	.ENDM

	.MACRO __GETWRMN
	LDS  R@2,@0+@1
	LDS  R@3,@0+@1+1
	.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 __PUTBMRN
	STS  @0+@1,R@2
	.ENDM

	.MACRO __PUTWMRN
	STS  @0+@1,R@2
	STS  @0+@1+1,R@3
	.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 __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)
	RCALL __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
	RCALL __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)
	RCALL __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
	RCALL __PUTDP1
	.ENDM

	.MACRO __GETB1SX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R30,Z
	.ENDM

	.MACRO __GETW1SX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R0,Z+
	LD   R31,Z
	MOV  R30,R0
	.ENDM

	.MACRO __GETD1SX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R0,Z+
	LD   R1,Z+
	LD   R22,Z+
	LD   R23,Z
	MOV  R30,R0
	MOV  R31,R1
	.ENDM

	.MACRO __GETB2SX
	MOV  R26,R28
	MOV  R27,R29
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R26,X
	.ENDM

	.MACRO __GETW2SX
	MOV  R26,R28
	MOV  R27,R29
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R27,X
	MOV  R26,R0
	.ENDM

	.MACRO __GETD2SX
	MOV  R26,R28
	MOV  R27,R29
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	LD   R0,X+
	LD   R1,X+
	LD   R24,X+
	LD   R25,X
	MOV  R26,R0
	MOV  R27,R1
	.ENDM

	.MACRO __GETBRSX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@1)
	SBCI R31,HIGH(-@1)
	LD   R@0,Z
	.ENDM

	.MACRO __GETWRSX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@2)
	SBCI R31,HIGH(-@2)
	LD   R@0,Z+
	LD   R@1,Z
	.ENDM

	.MACRO __LSLW8SX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	LD   R31,Z
	CLR  R30
	.ENDM

	.MACRO __PUTB1SX
	MOV  R26,R28
	MOV  R27,R29
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X,R30
	.ENDM

	.MACRO __PUTW1SX
	MOV  R26,R28
	MOV  R27,R29
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X+,R30
	ST   X,R31
	.ENDM

	.MACRO __PUTD1SX
	MOV  R26,R28
	MOV  R27,R29
	SUBI R26,LOW(-@0)
	SBCI R27,HIGH(-@0)
	ST   X+,R30
	ST   X+,R31
	ST   X+,R22
	ST   X,R23
	.ENDM

	.MACRO __CLRW1SX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	CLR  R0
	ST   Z+,R0
	ST   Z,R0
	.ENDM

	.MACRO __CLRD1SX
	MOV  R30,R28
	MOV  R31,R29
	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
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z,R26
	.ENDM

	.MACRO __PUTW2SX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z+,R26
	ST   Z,R27
	.ENDM

	.MACRO __PUTBSRX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@0)
	SBCI R31,HIGH(-@0)
	ST   Z,R@1
	.ENDM

	.MACRO __PUTWSRX
	MOV  R30,R28
	MOV  R31,R29
	SUBI R30,LOW(-@2)
	SBCI R31,HIGH(-@2)
	ST   Z+,R@0
	ST   Z,R@1
	.ENDM

	.MACRO __PUTB1SNX
	MOV  R26,R28
	MOV  R27,R29
	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
	MOV  R26,R28
	MOV  R27,R29
	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
	MOV  R26,R28
	MOV  R27,R29
	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

	.CSEG
	.ORG 0

	.INCLUDE "solaire.vec"
	.INCLUDE "solaire.inc"

__RESET:
	CLI
	CLR  R30
	OUT  EECR,R30
	OUT  MCUCR,R30

;DISABLE WATCHDOG
	LDI  R31,0x18
	OUT  WDTCR,R31
	LDI  R31,0x10
	OUT  WDTCR,R31

;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(0x200)
	LDI  R25,HIGH(0x200)
	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
	ADIW R30,1
	MOV  R1,R0
	LPM
	ADIW R30,1
	MOV  R22,R30
	MOV  R23,R31
	MOV  R31,R0
	MOV  R30,R1
	SBIW R30,0
	BREQ __GLOBAL_INI_END
	LPM
	ADIW R30,1
	MOV  R26,R0
	LPM
	ADIW R30,1
	MOV  R27,R0
	LPM
	ADIW R30,1
	MOV  R24,R0
	LPM
	ADIW R30,1
	MOV  R25,R0
__GLOBAL_INI_LOOP:
	LPM
	ADIW R30,1
	ST   X+,R0
	SBIW R24,1
	BRNE __GLOBAL_INI_LOOP
	MOV  R30,R22
	MOV  R31,R23
	RJMP __GLOBAL_INI_NEXT
__GLOBAL_INI_END:

;STACK POINTER INITIALIZATION
	LDI  R30,LOW(0x25F)
	OUT  SPL,R30
	LDI  R30,HIGH(0x25F)
	OUT  SPH,R30

;DATA STACK POINTER INITIALIZATION
	LDI  R28,LOW(0xDD)
	LDI  R29,HIGH(0xDD)

	RJMP _main

	.ESEG
	.ORG 0

	.DSEG
	.ORG 0xDD
;       1 //TITRE : SOURCE_LUMINEUSE_AUTONOME
;       2 //NOM : TREMEAU_MURITH
;       3 //Date : 2004
;       4 
;       5 // Bibliothèques
;       6 #include <90s8535.h>
;       7 #include <ssi.h>
;       8 #include <delay.h>
;       9 #include <stdio.h> 
;      10 #include <stdlib.h>
;      11 
;      12 // Etats du graphe
;      13 #define Reglage_HTR	0
;      14 #define Jour     	1
;      15 #define Nuit     	2
;      16 
;      17 // Codes des touches de la carte AT90S8535 SSI
;      18 #define INC		0b00011111
;      19 #define DEC		0b00101111
;      20 #define OK		0b00110111
;      21 #define ECHAP		0b00111011
;      22 #define SET		0b00111101
;      23 #define ENTER		0b00111110
;      24 
;      25 // @I2C HTR
;      26 #define	add_HTR		0
;      27 
;      28 // Valeurs de Réglage
;      29 #define Seuil_batt1      400      // Valeurs à définir
;      30 #define Seuil_batt2      800
;      31 #define Seuil_lumiere1   400
;      32 #define Seuil_lumiere2   800
;      33 #define Heure_Jour	 5
;      34 #define Heure_Nuit       19
;      35 
;      36 //entrées
;      37 #define TENSION    6
;      38 #define LUMIERE    7
;      39 
;      40 //sortie
;      41 #define LAMPE PORTB.0
;      42 
;      43 // I2C Bus functions
;      44 #asm
;      45    .equ __i2c_port=0x12
   .equ __i2c_port=0x12
;      46    .equ __sda_bit=3
   .equ __sda_bit=3
;      47    .equ __scl_bit=7
   .equ __scl_bit=7
;      48 #endasm

;      49 #include <i2c.h>
;      50 
;      51 // PCF8583 Real Time Clock functions
;      52 #include <pcf8583.h>
;      53 
;      54 // Alphanumeric LCD Module functions
;      55 #asm
;      56    .equ __lcd_port=0x15
   .equ __lcd_port=0x15
;      57 #endasm

;      58 #include <lcd.h>
;      59 
;      60 //Read the AD conversion result
;      61 unsigned int read_adc(unsigned char adc_input)
;      62 {

	.CSEG
_read_adc:
;      63 ADMUX=adc_input;
	LD   R30,Y
	OUT  0x7,R30
;      64 //Start the AD conversion
;      65 ADCSR|=0x40;
	SBI  0x6,6
;      66 //wait for the AD conversion to complete
;      67 while ((ADCSR & 0x10)==0);
_0x43:
	SBIS 0x6,4
	RJMP _0x43
;      68 ADCSR|=0x10;
	SBI  0x6,4
;      69 return ADCW;
	IN   R30,0x4
	IN   R31,0x4+1
	ADIW R28,1
	RET
;      70 }
;      71 
;      72 //VARIABLES GLOBALES
;      73 char display_buffer_ligne0[17]; // tampon ligne 0 de l'afficheur

	.DSEG
_display_buffer_ligne0:
	.BYTE 0x11
;      74 char display_buffer_ligne1[17]; // tampon ligne 1 de l'afficheur
_display_buffer_ligne1:
	.BYTE 0x11
;      75 
;      76 
;      77 void main(void)
;      78 {

	.CSEG
_main:
;      79 // Variables locales 
;      80 char *heures, *minutes, *secondes, *secondes_1, *dizieme; //stockage de l'heure
;      81 float Valeur_tension_reel;
;      82 char Valeur_tension_aff[4];
;      83 unsigned int Valeur_tension,Valeur_lumiere; 
;      84 unsigned char BP, etat=Reglage_HTR,etat_1 = Jour;  
;      85 unsigned char Heure_ou_Date;
;      86 unsigned char H_J, mn_mois;
;      87 int sec_annee;  
;      88 
;      89 //Port A
;      90 PORTA=0x3F;
	SBIW R28,24
	LDI  R24,1
	LDI  R26,LOW(5)
	LDI  R27,HIGH(5)
	LDI  R30,LOW(_0x47*2)
	LDI  R31,HIGH(_0x47*2)
	RCALL __INITLOCB
;	*heures -> Y+22
;	*minutes -> Y+20
;	*secondes -> Y+18
;	*secondes_1 -> Y+16
;	*dizieme -> Y+14
;	Valeur_tension_reel -> Y+10
;	Valeur_tension_aff -> Y+6
;	Valeur_tension -> R16,R17
;	Valeur_lumiere -> R18,R19
;	BP -> R20
;	etat -> R21
;	etat_1 -> Y+5
;	Heure_ou_Date -> Y+4
;	H_J -> Y+3
;	mn_mois -> Y+2
;	sec_annee -> Y+0
	LDI  R21,0
	LDI  R30,LOW(63)
	OUT  0x1B,R30
;      91 DDRA=0x00;
	CLR  R30
	OUT  0x1A,R30
;      92 
;      93 //Port B
;      94 PORTB = 0x00;
	OUT  0x18,R30
;      95 DDRB = 0x1F;  
	LDI  R30,LOW(31)
	OUT  0x17,R30
;      96 
;      97 //ADC Initialisation
;      98 ADCSR = 0x81;
	LDI  R30,LOW(129)
	OUT  0x6,R30
;      99 
;     100 //I2C BUS INITIALISATION
;     101 i2c_init();
	RCALL _i2c_init
;     102 
;     103 //PCF8583 Real Time Clock initialization
;     104 rtc_init(add_HTR,0);
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x0
	RCALL _rtc_init
;     105 
;     106 // LCD module initialization
;     107 lcd_init(16); 
	RCALL SUBOPT_0x1
	RCALL _lcd_init
;     108 
;     109 while (1)      
_0x48:
;     110  { 
;     111   BP = Lire_BP();
	RCALL _Lire_BP
	MOV  R20,R30
;     112   Valeur_lumiere=read_adc(LUMIERE);
	LDI  R30,LOW(7)
	RCALL SUBOPT_0x2
	__PUTW1R 18,19
;     113   Valeur_tension=read_adc(TENSION);
	LDI  R30,LOW(6)
	RCALL SUBOPT_0x2
	__PUTW1R 16,17
;     114   rtc_get_time(add_HTR,&heures,&minutes,&secondes,&dizieme);
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x3
	RCALL SUBOPT_0x3
	RCALL SUBOPT_0x3
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,21
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_get_time
;     115   Valeur_tension_reel = 5.0*((float)Valeur_tension/1023.0);
	__GETW1R 16,17
	CLR  R22
	CLR  R23
	RCALL __CDF1
	RCALL __MOVED12
	__GETD1N 0x447FC000
	RCALL __DIVF21
	__GETD2N 0x40A00000
	RCALL __MULF12
	__PUTD1S 10
;     116   ftoa(Valeur_tension_reel,2,Valeur_tension_aff);
	RCALL __PUTPARD1
	RCALL SUBOPT_0x4
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,11
	ST   -Y,R31
	ST   -Y,R30
	RCALL _ftoa
;     117   
;     118  
;     119   switch (etat)
	MOV  R30,R21
;     120    {
;     121     case Reglage_HTR :  Heure_ou_Date = 0;
	CPI  R30,0
	BRNE _0x4E
	CLR  R30
	STD  Y+4,R30
;     122     			H_J = 12;
	LDI  R30,LOW(12)
	STD  Y+3,R30
;     123        			mn_mois = 30;
	LDI  R30,LOW(30)
	STD  Y+2,R30
;     124         		sec_annee = 0;
	CLR  R30
	STD  Y+0,R30
	STD  Y+0+1,R30
;     125         		regle_HTR(add_HTR,Heure_ou_Date,H_J,mn_mois, sec_annee);
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x5
	RCALL SUBOPT_0x5
	RCALL SUBOPT_0x5
	RCALL SUBOPT_0x6
	RCALL _regle_HTR
;     126         		if (etat_1 == Nuit)etat = Nuit; 
	LDD  R26,Y+5
	CPI  R26,LOW(0x2)
	BRNE _0x4F
	LDI  R21,LOW(2)
;     127         	 		else etat = Jour;	 
	RJMP _0x50
_0x4F:
	LDI  R21,LOW(1)
_0x50:
;     128         	        etat_1 = Reglage_HTR;
	CLR  R30
	STD  Y+5,R30
;     129         
;     130         break;    
	RJMP _0x4D
;     131         
;     132         case Jour :     LAMPE=0;        	       
_0x4E:
	CPI  R30,LOW(0x1)
	BRNE _0x51
	CBI  0x18,0
;     133         		if ((etat_1 != etat) || (secondes_1 != secondes))
	RCALL SUBOPT_0x7
	BRNE _0x53
	RCALL SUBOPT_0x8
	BREQ _0x52
_0x53:
;     134         		{
;     135         		 
;     136         		 sprintf(display_buffer_ligne0,"Jour Ubatt=%sV",Valeur_tension_aff);
	RCALL SUBOPT_0x9
	__POINTW1FN _70,0
	RCALL SUBOPT_0xA
	LDI  R24,4
	RCALL SUBOPT_0xB
;     137         		 sprintf(display_buffer_ligne1,"%-uh / %-umn / %-us ",heures, minutes, secondes);
	__POINTW1FN _70,15
	RCALL SUBOPT_0xC
	LDI  R24,12
	RCALL SUBOPT_0xD
;     138         		 Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xE
;     139         	         secondes_1 = secondes;
;     140         	        }
;     141         	        
;     142         		if (BP==SET) etat = Reglage_HTR;
_0x52:
	CPI  R20,61
	BRNE _0x55
	LDI  R21,LOW(0)
;     143         			else if  ((Valeur_tension>=Seuil_batt2) && (Valeur_lumiere<=Seuil_lumiere1) && (heures>=Heure_Nuit)) etat = Nuit;
	RJMP _0x56
_0x55:
	__CPWRN 16,17,800
	BRLO _0x58
	LDI  R30,LOW(400)
	LDI  R31,HIGH(400)
	CP   R30,R18
	CPC  R31,R19
	BRLO _0x58
	RCALL SUBOPT_0xF
	BRSH _0x59
_0x58:
	RJMP _0x57
_0x59:
	LDI  R21,LOW(2)
;     144         				else etat = Jour;        		
	RJMP _0x5A
_0x57:
	LDI  R21,LOW(1)
_0x5A:
_0x56:
;     145         		etat_1 = Jour;
	LDI  R30,LOW(1)
	STD  Y+5,R30
;     146        
;     147        break;   
	RJMP _0x4D
;     148        
;     149         case Nuit : // Travail élève	 
_0x51:
	CPI  R30,LOW(0x2)
	BRNE _0x4D
;     150  			LAMPE=1; // Eclairer ampoule
	SBI  0x18,0
;     151  			if ((etat_1 != etat) || (secondes_1 != secondes))
	RCALL SUBOPT_0x7
	BRNE _0x5D
	RCALL SUBOPT_0x8
	BREQ _0x5C
_0x5D:
;     152         		  {    			  
;     153         		   sprintf(display_buffer_ligne0,"Nuit Ubatt=%sV",Valeur_tension_aff);
	RCALL SUBOPT_0x9
	__POINTW1FN _70,36
	RCALL SUBOPT_0xA
	LDI  R24,4
	RCALL SUBOPT_0xB
;     154         		   sprintf(display_buffer_ligne1,"%-uh / %-umn / %-us ",heures, minutes, secondes);
	__POINTW1FN _70,51
	RCALL SUBOPT_0xC
	LDI  R24,12
	RCALL SUBOPT_0xD
;     155         		   Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xE
;     156         	           secondes_1 = secondes;
;     157         	          }
;     158         	        if (BP==SET) etat = Reglage_HTR;				  
_0x5C:
	CPI  R20,61
	BRNE _0x5F
	LDI  R21,LOW(0)
;     159 					else if ((heures >=Heure_Jour && heures < Heure_Nuit && Valeur_lumiere>=Seuil_lumiere2)||(Valeur_tension<=Seuil_batt1)) etat = Jour; 
	RJMP _0x60
_0x5F:
	LDD  R26,Y+22
	LDD  R27,Y+22+1
	CPI  R26,LOW(0x5)
	LDI  R30,HIGH(0x5)
	CPC  R27,R30
	BRLO _0x62
	RCALL SUBOPT_0xF
	BRSH _0x62
	__CPWRN 18,19,800
	BRSH _0x64
_0x62:
	LDI  R30,LOW(400)
	LDI  R31,HIGH(400)
	CP   R30,R16
	CPC  R31,R17
	BRLO _0x61
_0x64:
	LDI  R21,LOW(1)
;     160 			  			else etat = Nuit;	
	RJMP _0x66
_0x61:
	LDI  R21,LOW(2)
_0x66:
_0x60:
;     161       			etat_1 = Nuit;
	LDI  R30,LOW(2)
	STD  Y+5,R30
;     162    	break;
;     163     }  
_0x4D:
;     164  }
	RJMP _0x48
;     165 }
	ADIW R28,24
_0x67:
	RJMP _0x67
_Lire_BP:

	.DSEG

	.CSEG
	RCALL __SAVELOCR2
	IN   R17,25
	ANDI R17,LOW(63)
	MOV  R30,R5
	CPI  R30,LOW(0x1)
	BRNE _0x6C
	CPI  R17,63
	BRNE _0x6D
	MOV  R16,R17
	RCALL SUBOPT_0x10
	IN   R17,25
	ANDI R17,LOW(63)
	CP   R17,R16
	BRNE _0x6E
	CLR  R5
	LDI  R30,LOW(255)
	RJMP _0x1B2
_0x6E:
	CLR  R30
	RJMP _0x1B2
	RJMP _0x70
_0x6D:
	CLR  R30
	RJMP _0x1B2
_0x70:
	RJMP _0x6B
_0x6C:
	CPI  R30,0
	BRNE _0x6B
	CPI  R17,63
	BREQ _0x72
	MOV  R16,R17
	RCALL SUBOPT_0x10
	IN   R17,25
	ANDI R17,LOW(63)
	CP   R17,R16
	BRNE _0x73
	LDI  R30,LOW(1)
	MOV  R5,R30
	MOV  R30,R17
	RJMP _0x1B2
_0x73:
	LDI  R30,LOW(255)
	RJMP _0x1B2
	RJMP _0x75
_0x72:
	LDI  R30,LOW(255)
_0x75:
_0x6B:
_0x1B2:
	RCALL __LOADLOCR2P
	RET
_Affiche_LCD:
	RCALL _lcd_clear
	RCALL SUBOPT_0x11
	RCALL _lcd_puts
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x12
	RCALL _lcd_gotoxy
	LD   R30,Y
	LDD  R31,Y+1
	ST   -Y,R31
	ST   -Y,R30
	RCALL _lcd_puts
	ADIW R28,4
	RET
_regle_HTR:
	SBIW R28,36
	RCALL __SAVELOCR5
	LDI  R17,LOW(0)
_0x78:
	RCALL _Lire_BP
	MOV  R16,R30
	MOV  R30,R17
	CPI  R30,LOW(0x3)
	BRNE _0x7E
	LDD  R26,Y+45
	CPI  R26,LOW(0x1)
	BRNE _0x7F
	RCALL SUBOPT_0x13
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_set_date
	RJMP _0x80
_0x7F:
	RCALL SUBOPT_0x13
	RCALL SUBOPT_0x14
	RCALL _rtc_set_time
_0x80:
	CLR  R30
	CLR  R31
	RJMP _0x1B1
_0x7E:
	CPI  R30,0
	BREQ PC+2
	RJMP _0x81
	RCALL SUBOPT_0x15
	BRNE _0x82
	LDD  R26,Y+44
	CPI  R26,LOW(0x18)
	BRNE _0x83
	RCALL SUBOPT_0x16
_0x83:
	LDD  R26,Y+44
	CPI  R26,LOW(0xFF)
	BRNE _0x84
	LDI  R30,LOW(23)
	STD  Y+44,R30
_0x84:
	RCALL SUBOPT_0x17
	BRNE _0x86
	CP   R17,R18
	BREQ _0x85
_0x86:
	RCALL SUBOPT_0x18
	__POINTW1FN _119,0
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x19
	__POINTW1FN _119,17
	RCALL SUBOPT_0x1A
	LDI  R24,12
	RCALL SUBOPT_0x1B
	RCALL SUBOPT_0x1C
	LDD  R19,Y+44
_0x85:
	RJMP _0x88
_0x82:
	LDD  R26,Y+44
	CPI  R26,LOW(0x20)
	BRNE _0x89
	RCALL SUBOPT_0x16
_0x89:
	LDD  R30,Y+44
	CPI  R30,0
	BRNE _0x8A
	LDI  R30,LOW(31)
	STD  Y+44,R30
_0x8A:
	RCALL SUBOPT_0x17
	BRNE _0x8C
	CP   R17,R18
	BREQ _0x8B
_0x8C:
	RCALL SUBOPT_0x18
	__POINTW1FN _119,38
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x19
	__POINTW1FN _119,55
	RCALL SUBOPT_0x1A
	LDI  R24,12
	RCALL SUBOPT_0x1B
	RCALL SUBOPT_0x1C
	LDD  R19,Y+44
_0x8B:
_0x88:
	RCALL SUBOPT_0x1D
	BRNE _0x91
	LDD  R30,Y+44
	SUBI R30,-LOW(1)
	STD  Y+44,R30
	RJMP _0x90
_0x91:
	CPI  R30,LOW(0x2F)
	BRNE _0x92
	LDD  R30,Y+44
	SUBI R30,LOW(1)
	STD  Y+44,R30
	RJMP _0x90
_0x92:
	CPI  R30,LOW(0x37)
	BRNE _0x93
	LDI  R17,LOW(1)
	RJMP _0x90
_0x93:
	CPI  R30,LOW(0x3B)
	BRNE _0x95
	LDI  R17,LOW(3)
	RJMP _0x90
_0x95:
	LDI  R17,LOW(0)
_0x90:
	LDI  R18,LOW(0)
	RJMP _0x7D
_0x81:
	CPI  R30,LOW(0x1)
	BREQ PC+2
	RJMP _0x96
	RCALL SUBOPT_0x15
	BRNE _0x97
	LDD  R26,Y+43
	CPI  R26,LOW(0x3C)
	BRNE _0x98
	CLR  R30
	STD  Y+43,R30
_0x98:
	LDD  R26,Y+43
	CPI  R26,LOW(0xFF)
	BRNE _0x99
	LDI  R30,LOW(59)
	STD  Y+43,R30
_0x99:
	RCALL SUBOPT_0x1E
	BRNE _0x9B
	CP   R17,R18
	BREQ _0x9A
_0x9B:
	RCALL SUBOPT_0x18
	__POINTW1FN _119,72
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x19
	__POINTW1FN _119,89
	RCALL SUBOPT_0x1A
	LDI  R24,12
	RCALL SUBOPT_0x1B
	RCALL SUBOPT_0x1C
	LDD  R20,Y+43
_0x9A:
	RJMP _0x9D
_0x97:
	LDD  R26,Y+43
	CPI  R26,LOW(0xD)
	BRNE _0x9E
	LDI  R30,LOW(1)
	STD  Y+43,R30
_0x9E:
	LDD  R30,Y+43
	CPI  R30,0
	BRNE _0x9F
	LDI  R30,LOW(12)
	STD  Y+43,R30
_0x9F:
	RCALL SUBOPT_0x1E
	BRNE _0xA1
	CP   R17,R18
	BREQ _0xA0
_0xA1:
	RCALL SUBOPT_0x18
	__POINTW1FN _119,110
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x19
	__POINTW1FN _119,127
	RCALL SUBOPT_0x1A
	LDI  R24,12
	RCALL SUBOPT_0x1B
	RCALL SUBOPT_0x1C
	LDD  R20,Y+43
_0xA0:
_0x9D:
	RCALL SUBOPT_0x1D
	BRNE _0xA6
	LDD  R30,Y+43
	SUBI R30,-LOW(1)
	STD  Y+43,R30
	RJMP _0xA5
_0xA6:
	CPI  R30,LOW(0x2F)
	BRNE _0xA7
	LDD  R30,Y+43
	SUBI R30,LOW(1)
	STD  Y+43,R30
	RJMP _0xA5
_0xA7:
	CPI  R30,LOW(0x37)
	BRNE _0xA8
	LDI  R17,LOW(2)
	RJMP _0xA5
_0xA8:
	CPI  R30,LOW(0x3B)
	BRNE _0xAA
	LDI  R17,LOW(3)
	RJMP _0xA5
_0xAA:
	LDI  R17,LOW(1)
_0xA5:
	LDI  R18,LOW(1)
	RJMP _0x7D
_0x96:
	CPI  R30,LOW(0x2)
	BREQ PC+2
	RJMP _0x7D
	RCALL SUBOPT_0x15
	BRNE _0xAC
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0x3C)
	LDI  R30,HIGH(0x3C)
	CPC  R27,R30
	BRNE _0xAD
	CLR  R30
	STD  Y+41,R30
	STD  Y+41+1,R30
_0xAD:
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0xFFFF)
	LDI  R30,HIGH(0xFFFF)
	CPC  R27,R30
	BRNE _0xAE
	LDI  R30,LOW(59)
	LDI  R31,HIGH(59)
	STD  Y+41,R30
	STD  Y+41+1,R31
_0xAE:
	RCALL SUBOPT_0x1F
	BRNE _0xB0
	CP   R17,R18
	BREQ _0xAF
_0xB0:
	RCALL SUBOPT_0x18
	__POINTW1FN _119,144
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x19
	__POINTW1FN _119,161
	RCALL SUBOPT_0x1A
	LDI  R24,12
	RCALL SUBOPT_0x1B
	RCALL SUBOPT_0x1C
	RCALL SUBOPT_0x20
_0xAF:
	RJMP _0xB2
_0xAC:
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0x834)
	LDI  R30,HIGH(0x834)
	CPC  R27,R30
	BRNE _0xB3
	RCALL SUBOPT_0x21
_0xB3:
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0x7CF)
	LDI  R30,HIGH(0x7CF)
	CPC  R27,R30
	BRNE _0xB4
	RCALL SUBOPT_0x21
_0xB4:
	RCALL SUBOPT_0x1F
	BRNE _0xB6
	CP   R17,R18
	BREQ _0xB5
_0xB6:
	RCALL SUBOPT_0x18
	__POINTW1FN _119,182
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x19
	__POINTW1FN _119,199
	RCALL SUBOPT_0x1A
	LDI  R24,12
	RCALL SUBOPT_0x1B
	RCALL SUBOPT_0x1C
	RCALL SUBOPT_0x20
_0xB5:
_0xB2:
	RCALL SUBOPT_0x1D
	BRNE _0xBB
	RCALL SUBOPT_0x22
	RJMP _0xBA
_0xBB:
	CPI  R30,LOW(0x2F)
	BRNE _0xBC
	RCALL SUBOPT_0x22
	RJMP _0xBA
_0xBC:
	CPI  R30,LOW(0x37)
	BRNE _0xBD
	LDI  R17,LOW(0)
	RJMP _0xBA
_0xBD:
	CPI  R30,LOW(0x3B)
	BRNE _0xBF
	LDI  R17,LOW(3)
	RJMP _0xBA
_0xBF:
	LDI  R17,LOW(2)
_0xBA:
	LDI  R18,LOW(2)
_0x7D:
	RJMP _0x78
_0x1B1:
	RCALL __LOADLOCR5
	ADIW R28,47
	RET
_getchar:
     sbis usr,rxc
     rjmp _getchar
     in   r30,udr
	RET
_putchar:
     sbis usr,udre
     rjmp _putchar
     ld   r30,y
     out  udr,r30
	ADIW R28,1
	RET
__put_G3:
	put:
	RCALL SUBOPT_0x23
	SBIW R30,0
	BREQ _0xF6
	RCALL SUBOPT_0x23
	ADIW R30,1
	RCALL __PUTWP1
	SBIW R30,1
	MOV  R26,R30
	MOV  R27,R31
	LDD  R30,Y+2
	ST   X,R30
	RJMP _0xF7
_0xF6:
	RCALL SUBOPT_0x24
	RCALL _putchar
_0xF7:
	ADIW R28,3
	RET
__print_G3:
	SBIW R28,6
	RCALL __SAVELOCR6
	LDI  R16,0
_0xF9:
	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
	MOV  R30,R0
	MOV  R19,R30
	CPI  R30,0
	BRNE PC+2
	RJMP _0xFB
	MOV  R30,R16
	CPI  R30,0
	BRNE _0xFF
	CPI  R19,37
	BRNE _0x100
	LDI  R16,LOW(1)
	RJMP _0x101
_0x100:
	RCALL SUBOPT_0x25
_0x101:
	RJMP _0xFE
_0xFF:
	CPI  R30,LOW(0x1)
	BRNE _0x102
	CPI  R19,37
	BRNE _0x103
	RCALL SUBOPT_0x25
	LDI  R16,LOW(0)
	RJMP _0xFE
_0x103:
	LDI  R16,LOW(2)
	LDI  R21,LOW(0)
	LDI  R17,LOW(0)
	CPI  R19,45
	BRNE _0x104
	LDI  R17,LOW(1)
	RJMP _0xFE
_0x104:
	CPI  R19,43
	BRNE _0x105
	LDI  R21,LOW(43)
	RJMP _0xFE
_0x105:
	CPI  R19,32
	BRNE _0x106
	LDI  R21,LOW(32)
	RJMP _0xFE
_0x106:
	RJMP _0x107
_0x102:
	CPI  R30,LOW(0x2)
	BRNE _0x108
_0x107:
	LDI  R20,LOW(0)
	LDI  R16,LOW(3)
	CPI  R19,48
	BRNE _0x109
	ORI  R17,LOW(128)
	RJMP _0xFE
_0x109:
	RJMP _0x10A
_0x108:
	CPI  R30,LOW(0x3)
	BREQ PC+2
	RJMP _0xFE
_0x10A:
	CPI  R19,48
	BRLO _0x10D
	CPI  R19,58
	BRLO _0x10E
_0x10D:
	RJMP _0x10C
_0x10E:
	MOV  R18,R20
	LSL  R20
	LSL  R20
	ADD  R20,R18
	LSL  R20
	MOV  R30,R19
	SUBI R30,LOW(48)
	ADD  R20,R30
	RJMP _0xFE
_0x10C:
	MOV  R30,R19
	CPI  R30,LOW(0x63)
	BRNE _0x112
	RCALL SUBOPT_0x26
	LD   R30,X
	RCALL SUBOPT_0x27
	RJMP _0x113
_0x112:
	CPI  R30,LOW(0x73)
	BRNE _0x115
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x28
	RCALL _strlen
	MOV  R16,R30
	RJMP _0x116
_0x115:
	CPI  R30,LOW(0x70)
	BRNE _0x118
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x28
	RCALL _strlenf
	MOV  R16,R30
	ORI  R17,LOW(8)
_0x116:
	ORI  R17,LOW(2)
	ANDI R17,LOW(127)
	LDI  R18,LOW(0)
	RJMP _0x119
_0x118:
	CPI  R30,LOW(0x64)
	BREQ _0x11C
	CPI  R30,LOW(0x69)
	BRNE _0x11D
_0x11C:
	ORI  R17,LOW(4)
	RJMP _0x11E
_0x11D:
	CPI  R30,LOW(0x75)
	BRNE _0x11F
_0x11E:
	LDI  R30,LOW(_tbl10_G3*2)
	LDI  R31,HIGH(_tbl10_G3*2)
	STD  Y+6,R30
	STD  Y+6+1,R31
	LDI  R16,LOW(5)
	RJMP _0x120
_0x11F:
	CPI  R30,LOW(0x58)
	BRNE _0x122
	ORI  R17,LOW(8)
	RJMP _0x123
_0x122:
	CPI  R30,LOW(0x78)
	BREQ PC+2
	RJMP _0x151
_0x123:
	LDI  R30,LOW(_tbl16_G3*2)
	LDI  R31,HIGH(_tbl16_G3*2)
	STD  Y+6,R30
	STD  Y+6+1,R31
	LDI  R16,LOW(4)
_0x120:
	SBRS R17,2
	RJMP _0x125
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x29
	LDD  R26,Y+10
	LDD  R27,Y+10+1
	SBIW R26,0
	BRGE _0x126
	LDD  R30,Y+10
	LDD  R31,Y+10+1
	RCALL __ANEGW1
	STD  Y+10,R30
	STD  Y+10+1,R31
	LDI  R21,LOW(45)
_0x126:
	CPI  R21,0
	BREQ _0x127
	SUBI R16,-LOW(1)
	RJMP _0x128
_0x127:
	ANDI R17,LOW(251)
_0x128:
	RJMP _0x129
_0x125:
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x29
_0x129:
_0x119:
	SBRC R17,0
	RJMP _0x12A
_0x12B:
	CP   R16,R20
	BRSH _0x12D
	SBRS R17,7
	RJMP _0x12E
	SBRS R17,2
	RJMP _0x12F
	ANDI R17,LOW(251)
	MOV  R19,R21
	SUBI R16,LOW(1)
	RJMP _0x130
_0x12F:
	LDI  R19,LOW(48)
_0x130:
	RJMP _0x131
_0x12E:
	LDI  R19,LOW(32)
_0x131:
	RCALL SUBOPT_0x25
	SUBI R20,LOW(1)
	RJMP _0x12B
_0x12D:
_0x12A:
	MOV  R18,R16
	SBRS R17,1
	RJMP _0x132
_0x133:
	CPI  R18,0
	BREQ _0x135
	SBRS R17,3
	RJMP _0x136
	RCALL SUBOPT_0x2A
	LPM
	MOV  R30,R0
	RJMP _0x1B3
_0x136:
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	LD   R30,X+
	STD  Y+6,R26
	STD  Y+6+1,R27
_0x1B3:
	ST   -Y,R30
	RCALL SUBOPT_0x2B
	CPI  R20,0
	BREQ _0x138
	SUBI R20,LOW(1)
_0x138:
	SUBI R18,LOW(1)
	RJMP _0x133
_0x135:
	RJMP _0x139
_0x132:
_0x13B:
	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
	RCALL __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 _0x13D
	SBRS R17,3
	RJMP _0x13E
	SUBI R19,-LOW(7)
	RJMP _0x13F
_0x13E:
	SUBI R19,-LOW(39)
_0x13F:
_0x13D:
	SBRC R17,4
	RJMP _0x141
	LDI  R30,LOW(48)
	CP   R30,R19
	BRLO _0x143
	LDD  R26,Y+8
	LDD  R27,Y+8+1
	CPI  R26,LOW(0x1)
	LDI  R30,HIGH(0x1)
	CPC  R27,R30
	BRNE _0x142
_0x143:
	ORI  R17,LOW(16)
	RJMP _0x145
_0x142:
	CP   R20,R18
	BRLO _0x147
	SBRS R17,0
	RJMP _0x148
_0x147:
	RJMP _0x146
_0x148:
	LDI  R19,LOW(32)
	SBRS R17,7
	RJMP _0x149
	LDI  R19,LOW(48)
	ORI  R17,LOW(16)
_0x145:
	SBRS R17,2
	RJMP _0x14A
	ANDI R17,LOW(251)
	ST   -Y,R21
	RCALL SUBOPT_0x2B
	CPI  R20,0
	BREQ _0x14B
	SUBI R20,LOW(1)
_0x14B:
_0x14A:
_0x149:
_0x141:
	RCALL SUBOPT_0x25
	CPI  R20,0
	BREQ _0x14C
	SUBI R20,LOW(1)
_0x14C:
_0x146:
	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 _0x13C
	RJMP _0x13B
_0x13C:
_0x139:
	SBRS R17,0
	RJMP _0x14D
_0x14E:
	CPI  R20,0
	BREQ _0x150
	SUBI R20,LOW(1)
	LDI  R30,LOW(32)
	RCALL SUBOPT_0x27
	RJMP _0x14E
_0x150:
_0x14D:
_0x151:
_0x113:
	LDI  R16,LOW(0)
_0xFE:
	RJMP _0xF9
_0xFB:
	RCALL __LOADLOCR6
	ADIW R28,18
	RET
_sprintf:
	MOV  R15,R24
	SBIW R28,4
	MOV  R26,R28
	MOV  R27,R29
	RCALL __ADDW2R15
	STD  Y+2,R26
	STD  Y+2+1,R27
	MOV  R26,R28
	MOV  R27,R29
	ADIW R26,6
	RCALL SUBOPT_0x2C
	ST   Y,R30
	STD  Y+1,R31
	MOV  R26,R28
	MOV  R27,R29
	ADIW R26,4
	RCALL SUBOPT_0x2C
	ST   -Y,R31
	ST   -Y,R30
	RCALL SUBOPT_0x6
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,4
	ST   -Y,R31
	ST   -Y,R30
	RCALL __print_G3
	LD   R26,Y
	LDD  R27,Y+1
	RCALL SUBOPT_0x2D
	RJMP _0x1AD
_ftoa:
	SBIW R28,6
	__GETD2S 9
	RCALL __CPD20
	BRGE _0x17B
	__GETD1S 9
	RCALL __ANEGF1
	__PUTD1S 9
	RCALL SUBOPT_0x2E
	LDI  R30,LOW(45)
	ST   X,R30
_0x17B:
	RCALL SUBOPT_0x2F
	RCALL SUBOPT_0x30
	RCALL _cmin
	STD  Y+8,R30
	LDI  R26,LOW(__fround_G4*2)
	LDI  R27,HIGH(__fround_G4*2)
	CLR  R31
	LSL  R30
	ROL  R31
	LSL  R30
	ROL  R31
	ADD  R30,R26
	ADC  R31,R27
	RCALL __GETD1PF
	__GETD2S 9
	RCALL __ADDF12
	__PUTD1S 9
	CLR  R30
	STD  Y+1,R30
	__GETD1N 0x3F800000
	__PUTD1S 2
_0x17C:
	RCALL SUBOPT_0x31
	RCALL __CMPF12
	BRLO _0x17E
	RCALL SUBOPT_0x32
	RCALL __MULF12
	__PUTD1S 2
	LDD  R30,Y+1
	SUBI R30,-LOW(1)
	STD  Y+1,R30
	RJMP _0x17C
_0x17E:
	RCALL SUBOPT_0x33
	BRNE _0x17F
	RCALL SUBOPT_0x2E
	LDI  R30,LOW(48)
	ST   X,R30
	RJMP _0x180
_0x17F:
_0x181:
	LDD  R30,Y+1
	SUBI R30,LOW(1)
	STD  Y+1,R30
	SUBI R30,-LOW(1)
	BREQ _0x183
	RCALL SUBOPT_0x32
	RCALL __DIVF21
	__GETD2N 0x3F000000
	RCALL __ADDF12
	RCALL __PUTPARD1
	RCALL _floor
	__PUTD1S 2
	RCALL SUBOPT_0x31
	RCALL __DIVF21
	RCALL SUBOPT_0x34
	PUSH R31
	PUSH R30
	RCALL SUBOPT_0x35
	POP  R26
	POP  R27
	RCALL SUBOPT_0x36
	__GETD2S 2
	CLR  R31
	CLR  R22
	CLR  R23
	RCALL __CDF1
	RCALL __MULF12
	__GETD2S 9
	RCALL SUBOPT_0x37
	RJMP _0x181
_0x183:
_0x180:
	LDD  R30,Y+8
	CPI  R30,0
	BRNE _0x184
	RCALL SUBOPT_0x38
	RJMP _0x1B0
_0x184:
	RCALL SUBOPT_0x2E
	LDI  R30,LOW(46)
	ST   X,R30
_0x185:
	LDD  R30,Y+8
	SUBI R30,LOW(1)
	STD  Y+8,R30
	SUBI R30,-LOW(1)
	BREQ _0x187
	__GETD2S 9
	__GETD1N 0x41200000
	RCALL __MULF12
	__PUTD1S 9
	RCALL SUBOPT_0x34
	PUSH R31
	PUSH R30
	RCALL SUBOPT_0x35
	POP  R26
	POP  R27
	RCALL SUBOPT_0x36
	__GETD2S 9
	CLR  R31
	CLR  R22
	CLR  R23
	RCALL __CDF1
	RCALL SUBOPT_0x37
	RJMP _0x185
_0x187:
	RCALL SUBOPT_0x38
_0x1B0:
	ADIW R28,13
	RET
_rtc_read:
	ST   -Y,R16
	RCALL SUBOPT_0x39
	MOV  R16,R30
	RCALL _i2c_start
	ST   -Y,R16
	RCALL SUBOPT_0x3A
	RCALL _i2c_start
	MOV  R30,R16
	ORI  R30,1
	RCALL SUBOPT_0x3B
	RCALL SUBOPT_0x0
	RCALL _i2c_read
	MOV  R16,R30
	RCALL _i2c_stop
	MOV  R30,R16
	LDD  R16,Y+0
	RJMP _0x1AE
_rtc_write:
	RCALL _i2c_start
	RCALL SUBOPT_0x39
	ST   -Y,R30
	RCALL SUBOPT_0x3A
	LD   R30,Y
	RCALL SUBOPT_0x3B
	RCALL _i2c_stop
	RJMP _0x1AE
_rtc_get_status:
	RCALL SUBOPT_0x3C
	RCALL _rtc_read
	MOV  R4,R30
	BST  R4,1
	BLD  R2,0
	MOV  R30,R4
	RJMP _0x1AF
_rtc_init:
	ST   -Y,R16
	LDI  R16,LOW(144)
	RCALL SUBOPT_0x33
	BREQ _0x193
	LDI  R16,LOW(176)
_0x193:
	CLR  R4
	CLT
	BLD  R2,0
	LDD  R30,Y+2
	RCALL SUBOPT_0x14
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x3D
	RCALL SUBOPT_0x3E
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x3E
	RCALL _rtc_read
	ANDI R30,LOW(0x3F)
	ST   -Y,R30
	RCALL SUBOPT_0x3D
	LDI  R30,LOW(8)
	ST   -Y,R30
	ST   -Y,R16
	RCALL _rtc_write
	LDD  R16,Y+0
	RJMP _0x1AE
_rtc_stop:
	RCALL SUBOPT_0x40
	ORI  R30,0x80
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x42
	RJMP _0x1AF
_rtc_start:
	RCALL SUBOPT_0x40
	ANDI R30,0x7F
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x42
	RJMP _0x1AF
_rtc_hold_off:
	RCALL SUBOPT_0x40
	ANDI R30,0xBF
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x42
	RJMP _0x1AF
_rtc_hold_on:
	RCALL SUBOPT_0x40
	ORI  R30,0x40
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x42
_0x1AF:
	ADIW R28,1
	RET
_rtc_read_bcd:
	RCALL SUBOPT_0x43
	RCALL SUBOPT_0x43
	RCALL _rtc_read
	ST   -Y,R30
	RCALL _bcd2bin
	ADIW R28,2
	RET
_rtc_write_bcd:
	RCALL SUBOPT_0x24
	RCALL SUBOPT_0x24
	RCALL SUBOPT_0x24
	RCALL _bin2bcd
	RCALL SUBOPT_0x44
_0x1AE:
	ADIW R28,3
	RET
_rtc_write_word:
	RCALL SUBOPT_0x45
	RCALL SUBOPT_0x45
	RCALL SUBOPT_0x24
	RCALL _rtc_write
	RCALL SUBOPT_0x45
	LDD  R30,Y+3
	SUBI R30,-LOW(1)
	STD  Y+3,R30
	ST   -Y,R30
	LDD  R30,Y+3
	ANDI R31,HIGH(0x0)
	RCALL SUBOPT_0x44
_0x1AD:
	ADIW R28,4
	RET
_rtc_write_date:
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x3F
	RCALL _bin2bcd
	PUSH R30
	LDD  R30,Y+2
	ANDI R30,LOW(0x3)
	SWAP R30
	ANDI R30,0xF0
	LSL  R30
	LSL  R30
	POP  R26
	OR   R30,R26
	RCALL SUBOPT_0x44
	RJMP _0x1AC
_rtc_get_time:
	RCALL SUBOPT_0x2F
	RCALL _rtc_hold_on
	RCALL SUBOPT_0x2F
	RCALL SUBOPT_0x12
	RCALL _rtc_read_bcd
	LD   R26,Y
	LDD  R27,Y+1
	RCALL SUBOPT_0x46
	RCALL SUBOPT_0x4
	RCALL _rtc_read_bcd
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	RCALL SUBOPT_0x46
	RCALL SUBOPT_0x47
	RCALL _rtc_read_bcd
	LDD  R26,Y+4
	LDD  R27,Y+4+1
	RCALL SUBOPT_0x46
	RCALL SUBOPT_0x3E
	RCALL _rtc_read_bcd
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	RCALL SUBOPT_0x46
	RCALL _rtc_hold_off
	ADIW R28,9
	RET
_rtc_set_time:
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x48
	RCALL SUBOPT_0x12
	RCALL SUBOPT_0x24
	RCALL SUBOPT_0x49
	RCALL SUBOPT_0x4
	RCALL SUBOPT_0x45
	RCALL SUBOPT_0x49
	RCALL SUBOPT_0x47
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x49
	RCALL SUBOPT_0x3E
	RCALL SUBOPT_0x5
	RCALL SUBOPT_0x49
	RCALL _rtc_start
	RJMP _0x1AC
_rtc_set_date:
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x11
	RCALL _rtc_write_word
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x48
	RCALL SUBOPT_0x30
	RCALL SUBOPT_0x5
	LDD  R30,Y+3
	LDD  R31,Y+3+1
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_write_date
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x4A
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x49
	RCALL _rtc_start
_0x1AC:
	ADIW R28,5
	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_G6:
	.BYTE 0x4

	.CSEG
__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:
    rcall __lcd_delay
    sbi   __lcd_port,__lcd_enable ;EN=1
    rcall __lcd_delay
    in    r26,__lcd_pin
    cbi   __lcd_port,__lcd_enable ;EN=0
    rcall __lcd_delay
    sbi   __lcd_port,__lcd_enable ;EN=1
    rcall __lcd_delay
    cbi   __lcd_port,__lcd_enable ;EN=0
    sbrc  r26,__lcd_busy_flag
    rjmp  __lcd_busy
	RET
__lcd_write_nibble:
    andi  r26,0xf0
    or    r26,r27
    out   __lcd_port,r26          ;write
    sbi   __lcd_port,__lcd_enable ;EN=1
    rcall __lcd_delay
    cbi   __lcd_port,__lcd_enable ;EN=0
__lcd_delay:
    ldi   r31,15
__lcd_delay0:
    dec   r31
    brne  __lcd_delay0
    ret
__lcd_write_data:
    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
    rcall __lcd_write_nibble      ;RD=0, write MSN
    ld    r26,y
    swap  r26
    rcall __lcd_write_nibble      ;write LSN
    sbi   __lcd_port,__lcd_rd     ;RD=1
	ADIW R28,1
	RET
__lcd_read_nibble:
    sbi   __lcd_port,__lcd_enable ;EN=1
    rcall __lcd_delay
    in    r30,__lcd_pin           ;read
    cbi   __lcd_port,__lcd_enable ;EN=0
    rcall __lcd_delay
    andi  r30,0xf0
    ret
_lcd_read_byte0_G6:
    rcall __lcd_delay
    rcall __lcd_read_nibble       ;read MSN
    mov   r26,r30
    rcall __lcd_read_nibble       ;read LSN
    cbi   __lcd_port,__lcd_rd     ;RD=0
    swap  r30
    or    r30,r26
	RET
_lcd_gotoxy:
	RCALL __lcd_ready
	LD   R30,Y
	CLR  R31
	SUBI R30,LOW(-__base_y_G6)
	SBCI R31,HIGH(-__base_y_G6)
	LD   R30,Z
	LDD  R26,Y+1
	ADD  R30,R26
	RCALL SUBOPT_0x4B
	LDD  R6,Y+1
	LDD  R7,Y+0
	ADIW R28,2
	RET
_lcd_clear:
	RCALL __lcd_ready
	RCALL SUBOPT_0x4
	RCALL __lcd_write_data
	RCALL __lcd_ready
	LDI  R30,LOW(12)
	RCALL SUBOPT_0x4B
	RCALL __lcd_ready
	RCALL SUBOPT_0x12
	RCALL __lcd_write_data
	CLR  R30
	MOV  R7,R30
	MOV  R6,R30
	RET
_lcd_putchar:
    push r30
    push r31
    ld   r26,y
    set
    cpi  r26,10
    breq __lcd_putchar1
    clt
	INC  R6
	CP   R8,R6
	BRSH _0x1A5
	__lcd_putchar1:
	INC  R7
	RCALL SUBOPT_0x0
	ST   -Y,R7
	RCALL _lcd_gotoxy
	brts __lcd_putchar0
_0x1A5:
    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_puts:
    ldd  r31,y+1
    ld   r30,y
__lcd_puts0:
    ld   r26,z+
    tst  r26
    breq __lcd_puts1
    st   -y,r26    
    rcall _lcd_putchar
    rjmp __lcd_puts0
__lcd_puts1:
	ADIW R28,2
	RET
__long_delay_G6:
    clr   r26
    clr   r27
__long_delay0:
    sbiw  r26,1         ;2 cycles
    brne  __long_delay0 ;2 cycles
	RET
__lcd_init_write_G6:
    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
    rcall __lcd_write_nibble      ;RD=0, write MSN
    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
	LDD  R8,Y+0
	LD   R30,Y
	SUBI R30,-LOW(128)
	__PUTB1MN __base_y_G6,2
	LD   R30,Y
	SUBI R30,-LOW(192)
	__PUTB1MN __base_y_G6,3
	RCALL SUBOPT_0x4C
	RCALL SUBOPT_0x4C
	RCALL SUBOPT_0x4C
	RCALL __long_delay_G6
	LDI  R30,LOW(32)
	ST   -Y,R30
	RCALL __lcd_init_write_G6
	RCALL __long_delay_G6
	LDI  R30,LOW(40)
	RCALL SUBOPT_0x4B
	RCALL __long_delay_G6
	RCALL SUBOPT_0x3E
	RCALL __lcd_write_data
	RCALL __long_delay_G6
	LDI  R30,LOW(133)
	RCALL SUBOPT_0x4B
	RCALL __long_delay_G6
    in    r26,__lcd_direction
    andi  r26,0xf                 ;set as input
    out   __lcd_direction,r26
    sbi   __lcd_port,__lcd_rd     ;RD=1
	RCALL _lcd_read_byte0_G6
	CPI  R30,LOW(0x5)
	BREQ _0x1AA
	CLR  R30
	RJMP _0x1AB
_0x1AA:
	RCALL __lcd_ready
	RCALL SUBOPT_0x4A
	RCALL __lcd_write_data
	RCALL _lcd_clear
	LDI  R30,LOW(1)
_0x1AB:
	ADIW R28,1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 15 TIMES
SUBOPT_0x0:
	CLR  R30
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1:
	LDI  R30,LOW(16)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2:
	ST   -Y,R30
	RJMP _read_adc

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x3:
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,23
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x4:
	LDI  R30,LOW(2)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x5:
	LDD  R30,Y+5
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x6:
	LDD  R30,Y+4
	LDD  R31,Y+4+1
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x7:
	LDD  R26,Y+5
	CP   R21,R26
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x8:
	LDD  R30,Y+18
	LDD  R31,Y+18+1
	LDD  R26,Y+16
	LDD  R27,Y+16+1
	CP   R30,R26
	CPC  R31,R27
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x9:
	LDI  R30,LOW(_display_buffer_ligne0)
	LDI  R31,HIGH(_display_buffer_ligne0)
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xA:
	ST   -Y,R31
	ST   -Y,R30
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,10
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xB:
	RCALL _sprintf
	ADIW R28,8
	LDI  R30,LOW(_display_buffer_ligne1)
	LDI  R31,HIGH(_display_buffer_ligne1)
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xC:
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+26
	LDD  R31,Y+26+1
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	LDD  R30,Y+28
	LDD  R31,Y+28+1
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	LDD  R30,Y+30
	LDD  R31,Y+30+1
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xD:
	RCALL _sprintf
	ADIW R28,16
	RJMP SUBOPT_0x9

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xE:
	LDI  R30,LOW(_display_buffer_ligne1)
	LDI  R31,HIGH(_display_buffer_ligne1)
	ST   -Y,R31
	ST   -Y,R30
	RCALL _Affiche_LCD
	LDD  R30,Y+18
	LDD  R31,Y+18+1
	STD  Y+16,R30
	STD  Y+16+1,R31
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xF:
	LDD  R26,Y+22
	LDD  R27,Y+22+1
	CPI  R26,LOW(0x13)
	LDI  R30,HIGH(0x13)
	CPC  R27,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x10:
	LDI  R30,LOW(20)
	LDI  R31,HIGH(20)
	ST   -Y,R31
	ST   -Y,R30
	RJMP _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x11:
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x12:
	LDI  R30,LOW(1)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x13:
	LDD  R30,Y+46
	ST   -Y,R30
	LDD  R30,Y+45
	ST   -Y,R30
	LDD  R30,Y+45
	ST   -Y,R30
	LDD  R30,Y+44
	LDD  R31,Y+44+1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 7 TIMES
SUBOPT_0x14:
	ST   -Y,R30
	RJMP SUBOPT_0x0

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x15:
	LDD  R30,Y+45
	CPI  R30,0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x16:
	CLR  R30
	STD  Y+44,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x17:
	LDD  R30,Y+44
	CP   R30,R19
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 12 TIMES
SUBOPT_0x18:
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,22
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x19:
	RCALL _sprintf
	ADIW R28,4
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,5
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x1A:
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+48
	CLR  R31
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	LDD  R30,Y+51
	CLR  R31
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	LDD  R30,Y+53
	LDD  R31,Y+53+1
	RCALL __CWD1
	RCALL __PUTPARD1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x1B:
	RCALL _sprintf
	ADIW R28,16
	RJMP SUBOPT_0x18

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x1C:
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,7
	ST   -Y,R31
	ST   -Y,R30
	RJMP _Affiche_LCD

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x1D:
	MOV  R30,R16
	CPI  R30,LOW(0x1F)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1E:
	LDD  R30,Y+43
	CP   R30,R20
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1F:
	LDD  R30,Y+41
	LDD  R31,Y+41+1
	LDD  R26,Y+39
	LDD  R27,Y+39+1
	CP   R30,R26
	CPC  R31,R27
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x20:
	LDD  R30,Y+41
	LDD  R31,Y+41+1
	STD  Y+39,R30
	STD  Y+39+1,R31
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x21:
	MOV  R26,R28
	MOV  R27,R29
	ADIW R26,43
	LDI  R30,LOW(2000)
	LDI  R31,HIGH(2000)
	ST   X,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x22:
	LDD  R30,Y+41
	LDD  R31,Y+41+1
	ADIW R30,1
	STD  Y+41,R30
	STD  Y+41+1,R31
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x23:
	LD   R26,Y
	LDD  R27,Y+1
	RCALL __GETW1P
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 8 TIMES
SUBOPT_0x24:
	LDD  R30,Y+2
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x25:
	ST   -Y,R19
	LDD  R30,Y+13
	LDD  R31,Y+13+1
	ST   -Y,R31
	ST   -Y,R30
	RJMP __put_G3

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x26:
	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_0x27:
	ST   -Y,R30
	LDD  R30,Y+13
	LDD  R31,Y+13+1
	ST   -Y,R31
	ST   -Y,R30
	RJMP __put_G3

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x28:
	RCALL __GETD1P
	STD  Y+6,R30
	STD  Y+6+1,R31
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x29:
	RCALL __GETW1P
	STD  Y+10,R30
	STD  Y+10+1,R31
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2A:
	LDD  R30,Y+6
	LDD  R31,Y+6+1
	ADIW R30,1
	STD  Y+6,R30
	STD  Y+6+1,R31
	SBIW R30,1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2B:
	LDD  R30,Y+13
	LDD  R31,Y+13+1
	ST   -Y,R31
	ST   -Y,R30
	RJMP __put_G3

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2C:
	RCALL __ADDW2R15
	RCALL __GETW1P
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2D:
	CLR  R30
	ST   X,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2E:
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	ADIW R26,1
	STD  Y+6,R26
	STD  Y+6+1,R27
	SBIW R26,1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 7 TIMES
SUBOPT_0x2F:
	LDD  R30,Y+8
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x30:
	LDI  R30,LOW(5)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x31:
	__GETD1S 2
	__GETD2S 9
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x32:
	__GETD2S 2
	__GETD1N 0x41200000
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x33:
	LDD  R30,Y+1
	CPI  R30,0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x34:
	RCALL __CFD1
	ST   Y,R30
	RJMP SUBOPT_0x2A

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x35:
	LD   R30,Y
	SUBI R30,-LOW(48)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x36:
	ST   X,R30
	LD   R30,Y
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x37:
	RCALL __SWAPD12
	RCALL __SUBF12
	__PUTD1S 9
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x38:
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	RJMP SUBOPT_0x2D

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x39:
	LDD  R30,Y+2
	LSL  R30
	ORI  R30,LOW(0xA0)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3A:
	RCALL _i2c_write
	LDD  R30,Y+1
	ST   -Y,R30
	RJMP _i2c_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3B:
	ST   -Y,R30
	RJMP _i2c_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x3C:
	LD   R30,Y
	RJMP SUBOPT_0x14

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3D:
	RCALL _rtc_write
	RJMP SUBOPT_0x24

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x3E:
	LDI  R30,LOW(4)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 17 TIMES
SUBOPT_0x3F:
	LDD  R30,Y+4
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x40:
	LD   R30,Y
	ST   -Y,R30
	RCALL _rtc_get_status
	MOV  R30,R4
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x41:
	MOV  R4,R30
	RJMP SUBOPT_0x3C

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x42:
	ST   -Y,R4
	RJMP _rtc_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x43:
	LDD  R30,Y+1
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x44:
	ST   -Y,R30
	RJMP _rtc_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x45:
	LDD  R30,Y+3
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x46:
	ST   X,R30
	RJMP SUBOPT_0x2F

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x47:
	LDI  R30,LOW(3)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x48:
	RCALL _rtc_stop
	RJMP SUBOPT_0x3F

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x49:
	RCALL _rtc_write_bcd
	RJMP SUBOPT_0x3F

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x4A:
	LDI  R30,LOW(6)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x4B:
	ST   -Y,R30
	RJMP __lcd_write_data

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x4C:
	RCALL __long_delay_G6
	LDI  R30,LOW(48)
	ST   -Y,R30
	RJMP __lcd_init_write_G6

_cmin:
	ld   r26,y+
	ld   r30,y+
	cp   r30,r26
	brlt __cmin0
	mov  r30,r26
__cmin0:
	ret

	.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,7
	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,13
__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 
	tst  r0
	breq __strlenf1
	adiw r26,1
	adiw r30,1
	rjmp __strlenf0
__strlenf1:
	mov  r30,r26
	mov  r31,r27
	ret

_delay_ms:
	ld   r30,y+
	ld   r31,y+
	adiw r30,0
	breq __delay_ms1
__delay_ms0:
	__DELAY_USW 0x3E8
	wdr
	sbiw r30,1
	brne __delay_ms0
__delay_ms1:
	ret

_bcd2bin:
	ld   r30,y
	swap r30
	andi r30,0xf
	mov  r26,r30
	lsl  r26
	lsl  r26
	add  r30,r26
	lsl  r30
	ld   r26,y+
	andi r26,0xf
	add  r30,r26
	ret

_bin2bcd:
	ld   r26,y+
	clr  r30
__bin2bcd0:
	subi r26,10
	brmi __bin2bcd1
	subi r30,-16
	rjmp __bin2bcd0
__bin2bcd1:
	subi r26,-10
	add  r30,r26
	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

_floor:
	rcall __ftrunc
	brne __floor1
__floor0:
	ret
__floor1:
	brtc __floor0
	ldi  r25,0xbf

__addfc:
	clr  r26
	clr  r27
	ldi  r24,0x80
	rjmp __addf12

__ADDW2R15:
	CLR  R0
	ADD  R26,R15
	ADC  R27,R0
	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

__CBD1:
	CLR  R31
	CLR  R22
	CLR  R23
	SBRS R30,7
	RET
	SER  R31
	SER  R22
	SER  R23
	RET

__CWD1:
	CLR  R22
	CLR  R23
	SBRS R31,7
	RET
	SER  R22
	SER  R23
	RET

__MOVED12:
	MOV  R26,R30
	MOV  R27,R31
	MOV  R24,R22
	MOV  R25,R23
	RET

__GETW1P:
	LD   R30,X+
	LD   R31,X
	SBIW R26,1
	RET

__GETD1P:
	LD   R30,X+
	LD   R31,X+
	LD   R22,X+
	LD   R23,X
	SBIW R26,3
	RET

__PUTWP1:
	ST   X+,R30
	ST   X,R31
	RET

__GETW1PF:
	LPM
	ADIW R30,1
	MOV  R1,R0
	LPM 
	MOV  R31,R0
	MOV  R30,R1
	RET

__GETD1PF:
	LPM 
	PUSH R0
	ADIW R30,1
	LPM 
	MOV  R1,R0
	ADIW R30,1
	LPM 
	MOV  R22,R0
	ADIW R30,1
	LPM 
	MOV  R23,R0
	MOV  R31,R1
	POP  R30
	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

__ANEGF1:
	SBIW R30,0
	SBCI R22,0
	SBCI R23,0
	BREQ __ANEGF10
	SUBI R23,0x80
__ANEGF10:
	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

__SUBF12:
	PUSH R21
	RCALL __UNPACK
	CPI  R25,0x80
	BREQ __ADDF129
	LDI  R21,0x80
	EOR  R1,R21

	RJMP __ADDF120

__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

__MULF12:
	PUSH R21
	RCALL __UNPACK
	CPI  R23,0x80
	BREQ __ZERORES
	CPI  R25,0x80
	BREQ __ZERORES
	EOR  R0,R1
	SEC
	ADC  R23,R25
	BRVC __MULF124
	BRLT __ZERORES
__MULF125:
	TST  R0
	BRMI __MINRES
	RJMP __MAXRES
__MULF124:
	PUSH R19
	PUSH R20
	CLR  R1
	CLR  R19
	CLR  R20
	CLR  R21
	LDI  R25,24
__MULF120:
	LSL  R19
	ROL  R20
	ROL  R21
	ROL  R30
	ROL  R31
	ROL  R22
	BRCC __MULF121
	ADD  R19,R26
	ADC  R20,R27
	ADC  R21,R24
	ADC  R30,R1
	ADC  R31,R1
	ADC  R22,R1
__MULF121:
	DEC  R25
	BRNE __MULF120
	POP  R20
	POP  R19
	TST  R22
	BRMI __MULF122
	LSL  R21
	ROL  R30
	ROL  R31
	ROL  R22
	RJMP __MULF123
__MULF122:
	INC  R23
	BRVS __MULF125
__MULF123:
	RCALL __REPACK
	POP  R21
	RET

__DIVF21:
	PUSH R21
	RCALL __UNPACK
	CPI  R23,0x80
	BRNE __DIVF210
	TST  R1
__DIVF211:
	BRPL __MAXRES
	RJMP __MINRES
__DIVF210:
	CPI  R25,0x80
	BRNE __DIVF218
__DIVF217:
	RJMP __ZERORES
__DIVF218:
	EOR  R0,R1
	SEC
	SBC  R25,R23
	BRVC __DIVF216
	BRLT __DIVF217
	TST  R0
	RJMP __DIVF211
__DIVF216:
	MOV  R23,R25
	LSR  R22
	ROR  R31
	ROR  R30
	LSR  R24
	ROR  R27
	ROR  R26
	PUSH R20
	CLR  R1
	CLR  R20
	CLR  R21
	LDI  R25,24
__DIVF212:
	CP   R26,R30
	CPC  R27,R31
	CPC  R24,R22
	BRLO __DIVF213
	SUB  R26,R30
	SBC  R27,R31
	SBC  R24,R22
	SEC
	RJMP __DIVF214
__DIVF213:
	CLC
__DIVF214:
	ROL  R1
	ROL  R20
	ROL  R21
	ROL  R26
	ROL  R27
	ROL  R24
	DEC  R25
	BRNE __DIVF212
	MOV  R30,R1
	MOV  R31,R20
	MOV  R22,R21
	LSR  R26
	ADC  R30,R25
	ADC  R31,R25
	ADC  R22,R25
	POP  R20
	TST  R22
	BRMI __DIVF215
	LSL  R30
	ROL  R31
	ROL  R22
	DEC  R23
	BRVS __DIVF217
__DIVF215:
	RCALL __REPACK
	POP  R21
	RET

__CMPF12:
	TST  R25
	BRMI __CMPF120
	TST  R23
	BRMI __CMPF121
	CP   R25,R23
	BRLO __CMPF122
	BRNE __CMPF121
	CP   R26,R30
	CPC  R27,R31
	CPC  R24,R22
	BRLO __CMPF122
	BREQ __CMPF123
__CMPF121:
	CLZ
	CLC
	RET
__CMPF122:
	CLZ
	SEC
	RET
__CMPF123:
	SEZ
	CLC
	RET
__CMPF120:
	TST  R23
	BRPL __CMPF122
	CP   R25,R23
	BRLO __CMPF121
	BRNE __CMPF122
	CP   R30,R26
	CPC  R31,R27
	CPC  R22,R24
	BRLO __CMPF122
	BREQ __CMPF123
	RJMP __CMPF121

__CPD20:
	SBIW R26,0
	SBCI R24,0
	SBCI R25,0
	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

__LOADLOCR2P:
	LD   R16,Y+
	LD   R17,Y+
	RET

__INITLOCB:
__INITLOCW:
	ADD R26,R28
	ADC R27,R29
__INITLOC0:
	LPM
	ADIW R30,1
	ST   X+,R0
	DEC  R24
	BRNE __INITLOC0
	RET

