;CodeVisionAVR C Compiler V1.23.8c 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
;External SRAM size  : 0
;Data Stack size     : 128
;Promote char to int : No
;char is unsigned    : Yes
;8 bit enums         : Yes
;Automatic register allocation : On
;Use AVR Studio 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 "ppe_acc_el.vec"
	.INCLUDE "ppe_acc_el.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(0xE0)
	LDI  R29,HIGH(0xE0)

	RJMP _main

	.ESEG
	.ORG 0
	.DB  0 ; FIRST EEPROM LOCATION NOT USED, SEE ATMEL ERRATA SHEETS

	.DSEG
	.ORG 0xE0
;       1 /*********************************************
;       2 This program was produced by the
;       3 CodeWizardAVR V1.0.2.2d Standard
;       4 Automatic Program Generator
;       5 © Copyright 1998-2002
;       6 Pavel Haiduc, HP InfoTech s.r.l.
;       7 http://www.hpinfotech.ro
;       8 e-mail:office@hpinfotech.ro , hpinfotech@xmail.ro
;       9 
;      10 Project : PPE ACCES DE PARKING
;      11 Version : 3
;      12 Date    : Mars 2003
;      13 Author  : Simonet Loudot Bupto               
;      14 Company : LYCEE Pierre Emile MARTIN       
;      15 Comments: Lecture d'un caractère sur une carte Philips D2000 et activation de PB0 si
;      16           la valeur lue est reconnue. La détection de la carte se fait sur PD6.
;      17 
;      18 Chip type           : AT90S8535
;      19 Clock frequency     : 4,000000 MHz
;      20 Memory model        : Small
;      21 Internal SRAM size  : 512
;      22 External SRAM size  : 0
;      23 Data Stack size     : 128
;      24 *********************************************/
;      25 
;      26 #include <90s8535.h>
;      27 
;      28 // Librairies non incluses par Wizard (à rajouter)      
;      29 #include <ssi.h>      // contient la fonction Lire_BP, Affiche_LCD etc
;      30 #include <delay.h>    // contient la fonction delay_ms
;      31 #include <stdio.h>    // contient la fonction sprintf
;      32 
;      33 // Etats du graphe "Contrôle d'acces"
;      34 #define Attente	 	0
;      35 #define Traitement 	1
;      36 #define Refus 		2
;      37 #define RetraitCarte	3
;      38 #define CdePortail	4
;      39 #define Reglage_HTR	5
;      40 
;      41 //Etats du graphe "Traitement"
;      42 #define Jour	0
;      43 #define Status  1
;      44 #define eleve1  2
;      45 #define eleve2  3
;      46 #define prof	4
;      47 
;      48 //Codes sur carte
;      49 #define Code_prof    2
;      50 #define Code_eleve1  8
;      51 #define Code_eleve2  4
;      52 
;      53 // Codes des BP de la carte DevATMEL ELEC
;      54 #define INC		0x1F
;      55 #define DEC		0x2F
;      56 #define OK		0x37
;      57 #define ECHAP		0x3B
;      58 #define SET		0x3D
;      59 #define ENTR		0x3E
;      60 
;      61 //booléens
;      62 #define autorise 	1
;      63 
;      64 // Adresse de l'Horloge Temps Réel
;      65 #define adresse_HTR 	1
;      66 
;      67 // Entrées / sorties du µC
;      68 #define Presence_carte	PIND.6   // Présence_carte = 0 si carte en place
;      69 #define Buzzer		PORTC.3
;      70 #define Portail		PORTB.0
;      71 
;      72 // I2C Bus functions
;      73 #asm
;      74    .equ __i2c_port=0x12
   .equ __i2c_port=0x12
;      75    .equ __sda_bit=3
   .equ __sda_bit=3
;      76    .equ __scl_bit=7
   .equ __scl_bit=7
;      77 #endasm

;      78 #include <i2c.h>
;      79 
;      80 // PCF8583 Real Time Clock functions
;      81 #include <pcf8583.h>
;      82 
;      83 // Alphanumeric LCD Module functions
;      84 #asm
;      85    .equ __lcd_port=0x15
   .equ __lcd_port=0x15
;      86 #endasm

;      87 #include <lcd.h>
;      88 
;      89 // Declare your global variables here
;      90 
;      91 //Prototype des fonctions
;      92 unsigned char Traiter_code(unsigned char code,unsigned char heures,unsigned char jour); // Détermine si l'acces est autorisé
;      93 
;      94 // Programme principal
;      95 //-------------------
;      96 void main(void)
;      97 {

	.CSEG
_main:
;      98 // Declare your local variables here
;      99 //----------------------------------
;     100 //type 		nom 					désignation
;     101 char display_buffer_ligne0[17];        		 // tampon ligne 0 de l'afficheur
;     102 char display_buffer_ligne1[17]; 		 // tampon ligne 1 de l'afficheur
;     103 unsigned char heures, minutes;    		 // stockage de l'heure
;     104 unsigned char secondes, secondes_1, dizieme;
;     105 unsigned char jour, mois; 			 // stockage de la date
;     106 int annee;
;     107 unsigned char etat=Attente, etat_1 = Traitement; // position dans le graphe "Contrôle d'acces"
;     108 unsigned char BP;				 // code de la touche actionnée
;     109 unsigned char Heure_ou_Date;			 // Heure_ou_Date = 0 réglage heure, Heure ou date = 1 régalge date
;     110 unsigned char Acces=0; 				 // Acces = 0 -> interdit Acces = 1 -> Autorisé
;     111 unsigned char H_J, mn_mois;			 // réglage de l'HTR
;     112 unsigned int sec_annee;
;     113 unsigned char code_carte;			 // Code contenu sur la carte Philips D2000
;     114 
;     115 // Input/Output Ports initialization
;     116 // Port A
;     117 PORTA=0x3F;
	SBIW R28,47
	LDI  R24,5
	LDI  R26,LOW(5)
	LDI  R27,HIGH(5)
	LDI  R30,LOW(_0x35*2)
	LDI  R31,HIGH(_0x35*2)
	RCALL __INITLOCB
;	display_buffer_ligne0 -> Y+30
;	display_buffer_ligne1 -> Y+13
;	heures -> R16
;	minutes -> R17
;	secondes -> R18
;	secondes_1 -> R19
;	dizieme -> R20
;	jour -> R21
;	mois -> Y+12
;	annee -> Y+10
;	etat -> Y+9
;	etat_1 -> Y+8
;	BP -> Y+7
;	Heure_ou_Date -> Y+6
;	Acces -> Y+5
;	H_J -> Y+4
;	mn_mois -> Y+3
;	sec_annee -> Y+1
;	code_carte -> Y+0
	LDI  R30,LOW(63)
	OUT  0x1B,R30
;     118 DDRA=0x00;
	CLR  R30
	OUT  0x1A,R30
;     119 
;     120 // Port B
;     121 PORTB=0x00;
	OUT  0x18,R30
;     122 DDRB=0x1F;
	LDI  R30,LOW(31)
	OUT  0x17,R30
;     123 
;     124 // Port C
;     125 PORTC=0x00;
	CLR  R30
	OUT  0x15,R30
;     126 DDRC=0x08;
	LDI  R30,LOW(8)
	OUT  0x14,R30
;     127 
;     128 // Port D
;     129 PORTD=0x20;
	LDI  R30,LOW(32)
	OUT  0x12,R30
;     130 DDRD=0x00;
	CLR  R30
	OUT  0x11,R30
;     131 
;     132 // I2C Bus initialization
;     133 i2c_init();
	RCALL _i2c_init
;     134 
;     135 // PCF8583 Real Time Clock initialization
;     136 rtc_init(adresse_HTR,0);
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x1
	RCALL _rtc_init
;     137 
;     138 // LCD module initialization
;     139 lcd_init(16);
	RCALL SUBOPT_0x2
	RCALL _lcd_init
;     140  
;     141 while (1) // boucle principale
_0x36:
;     142    {
;     143     BP = Lire_BP(); // lecture du clavier
	RCALL _Lire_BP
	STD  Y+7,R30
;     144       
;     145     switch (etat) // Début graphe "Contrôle d'acces"
	LDD  R30,Y+9
;     146      {
;     147        case Attente : rtc_get_time(adresse_HTR,&heures,&minutes,&secondes,&dizieme);
	CPI  R30,0
	BRNE _0x3C
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x3
;     148        		      if ((etat_1 != etat) || (secondes_1 != secondes))
	RCALL SUBOPT_0x4
	BRNE _0x3E
	CP   R18,R19
	BREQ _0x3D
_0x3E:
;     149                        { 
;     150                          sprintf(display_buffer_ligne0,"Placez la carte");
	RCALL SUBOPT_0x5
	__POINTW1FN _52,0
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x6
;     151                          sprintf(display_buffer_ligne1,"%-uh / %-umn / %-us",heures, minutes, secondes);
	__POINTW1FN _52,16
	ST   -Y,R31
	ST   -Y,R30
	RCALL SUBOPT_0x7
	MOV  R30,R17
	RCALL SUBOPT_0x8
	MOV  R30,R18
	RCALL SUBOPT_0x8
	LDI  R24,12
	RCALL SUBOPT_0x9
;     152                          Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0x5
	RCALL SUBOPT_0xA
;     153                          secondes_1 = secondes;
	MOV  R19,R18
;     154                        }
;     155                       if (!Presence_carte) etat = Traitement;
_0x3D:
	SBIC 0x10,6
	RJMP _0x40
	LDI  R30,LOW(1)
	STD  Y+9,R30
;     156                               else if (BP == SET) etat = Reglage_HTR;
	RJMP _0x41
_0x40:
	LDD  R26,Y+7
	CPI  R26,LOW(0x3D)
	BRNE _0x42
	LDI  R30,LOW(5)
	RJMP _0x1D0
;     157                               		else	  etat = Attente;
_0x42:
	CLR  R30
_0x1D0:
	STD  Y+9,R30
_0x41:
;     158                       etat_1 = Attente; 
	CLR  R30
	STD  Y+8,R30
;     159        break;
	RJMP _0x3B
;     160        		   
;     161        case Traitement : if (etat_1 != etat)
_0x3C:
	CPI  R30,LOW(0x1)
	BREQ PC+2
	RJMP _0x44
	RCALL SUBOPT_0x4
	BRNE PC+2
	RJMP _0x45
;     162                           {
;     163                            sprintf(display_buffer_ligne0,"Traitement      ");
	RCALL SUBOPT_0x5
	__POINTW1FN _52,36
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x6
;     164                            sprintf(display_buffer_ligne1,"       en cours ");
	__POINTW1FN _52,53
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0xB
;     165                            Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xA
;     166                            delay_ms(2000); 
	LDI  R30,LOW(2000)
	LDI  R31,HIGH(2000)
	RCALL SUBOPT_0xC
;     167                            code_carte=D2000_read(7); // lecture du code à l'adresse 8 dans la carte
	LDI  R30,LOW(7)
	ST   -Y,R30
	RCALL _D2000_read
	ST   Y,R30
;     168                            rtc_get_time(adresse_HTR,&heures,&minutes,&secondes,&dizieme); // lecture heure
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x3
;     169                            rtc_get_date(adresse_HTR,&jour,&mois,&annee);// lecture jour
	RCALL SUBOPT_0x0
	LDI  R30,LOW(21)
	LDI  R31,HIGH(21)
	RCALL SUBOPT_0xD
	RCALL SUBOPT_0xD
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_get_date
;     170                            sprintf(display_buffer_ligne0,"co=%-c h=%-u j=%-u",code_carte,heures,jour); // Affichage du code
	RCALL SUBOPT_0x5
	__POINTW1FN _52,70
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+4
	RCALL SUBOPT_0x8
	RCALL SUBOPT_0x7
	MOV  R30,R21
	RCALL SUBOPT_0x8
	LDI  R24,12
	RCALL SUBOPT_0x9
;     171                            sprintf(display_buffer_ligne1,"acces= %-u",Acces);				 // pour mise au point
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,13
	ST   -Y,R31
	ST   -Y,R30
	__POINTW1FN _52,89
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+9
	RCALL SUBOPT_0x8
	LDI  R24,4
	RCALL _sprintf
	ADIW R28,8
;     172                            Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0x5
	RCALL SUBOPT_0xA
;     173                            delay_ms(4000);
	LDI  R30,LOW(4000)
	LDI  R31,HIGH(4000)
	RCALL SUBOPT_0xC
;     174                            Acces=Traiter_code(code_carte,heures,jour);	// Appel SP Traitement
	RCALL SUBOPT_0xE
	ST   -Y,R16
	ST   -Y,R21
	RCALL _Traiter_code
	STD  Y+5,R30
;     175                          
;     176                            
;     177                             
;     178                           }
;     179                        
;     180                          if (Acces==autorise) etat = RetraitCarte;   
_0x45:
	LDD  R26,Y+5
	CPI  R26,LOW(0x1)
	BRNE _0x46
	LDI  R30,LOW(3)
	RJMP _0x1D1
;     181                       	     	        else  etat = Refus;	               
_0x46:
	LDI  R30,LOW(2)
_0x1D1:
	STD  Y+9,R30
;     182                          etat_1 = Traitement;
	LDI  R30,LOW(1)
	STD  Y+8,R30
;     183        break;
	RJMP _0x3B
;     184                       
;     185        case Refus :   if (etat_1 != etat)
_0x44:
	CPI  R30,LOW(0x2)
	BRNE _0x48
	RCALL SUBOPT_0x4
	BREQ _0x49
;     186                        {
;     187                          sprintf(display_buffer_ligne0,"Refus Reprenez");
	RCALL SUBOPT_0x5
	__POINTW1FN _52,100
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x6
;     188                          sprintf(display_buffer_ligne1,"    votre carte");
	__POINTW1FN _52,115
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0xB
;     189                          Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xA
;     190                          Buzzer = 1;
	SBI  0x15,3
;     191                          delay_ms(5000);  // 5 secondes pour retirer la carte
	RCALL SUBOPT_0xF
;     192                        }
;     193                       
;     194                       if (Presence_carte) {
_0x49:
	SBIS 0x10,6
	RJMP _0x4A
;     195                                            etat = Attente;
	RCALL SUBOPT_0x10
;     196                                            Buzzer = 0;
	CBI  0x15,3
;     197                                            delay_ms(500);
	LDI  R30,LOW(500)
	LDI  R31,HIGH(500)
	RCALL SUBOPT_0xC
;     198                                           }
;     199                                       else etat = Refus;
	RJMP _0x4B
_0x4A:
	LDI  R30,LOW(2)
	STD  Y+9,R30
_0x4B:
;     200                       etat_1 = Refus;
	LDI  R30,LOW(2)
	STD  Y+8,R30
;     201        break;
	RJMP _0x3B
;     202                       		             
;     203        case RetraitCarte :  if (etat_1 != etat)
_0x48:
	CPI  R30,LOW(0x3)
	BRNE _0x4C
	RCALL SUBOPT_0x4
	BREQ _0x4D
;     204                              {
;     205                               sprintf(display_buffer_ligne0,"Accepte Reprenez");
	RCALL SUBOPT_0x5
	__POINTW1FN _52,131
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x6
;     206                               sprintf(display_buffer_ligne1,"     votre carte");
	__POINTW1FN _52,148
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0xB
;     207                               Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xA
;     208                              }
;     209                              delay_ms(5000); // 5s pour retirer la carte
_0x4D:
	RCALL SUBOPT_0xF
;     210                              if (Presence_carte) etat = CdePortail;
	SBIS 0x10,6
	RJMP _0x4E
	LDI  R30,LOW(4)
	RJMP _0x1D2
;     211                                             else etat = Refus; 
_0x4E:
	LDI  R30,LOW(2)
_0x1D2:
	STD  Y+9,R30
;     212                              etat_1 = RetraitCarte;
	LDI  R30,LOW(3)
	STD  Y+8,R30
;     213        break;
	RJMP _0x3B
;     214                       
;     215        case CdePortail :     if (etat_1 != etat)
_0x4C:
	CPI  R30,LOW(0x4)
	BRNE _0x50
	RCALL SUBOPT_0x4
	BREQ _0x51
;     216        			      {    
;     217        		                sprintf(display_buffer_ligne0,"Ouverture       ");
	RCALL SUBOPT_0x5
	__POINTW1FN _52,165
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x6
;     218        				sprintf(display_buffer_ligne1,"      du portail");
	__POINTW1FN _52,182
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0xB
;     219            			Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xA
;     220           	   	       }
;     221              		     Portail = 1; //ouverture portail
_0x51:
	SBI  0x18,0
;     222                              delay_ms(1000);
	LDI  R30,LOW(1000)
	LDI  R31,HIGH(1000)
	RCALL SUBOPT_0xC
;     223                              Portail = 0;
	CBI  0x18,0
;     224                              delay_ms(10000); // attente fin de cycle ouverture / fermeture
	LDI  R30,LOW(10000)
	LDI  R31,HIGH(10000)
	RCALL SUBOPT_0xC
;     225                              etat = Attente; etat_1 = CdePortail;
	RCALL SUBOPT_0x10
	LDI  R30,LOW(4)
	STD  Y+8,R30
;     226        break;
	RJMP _0x3B
;     227        
;     228        case Reglage_HTR : if (etat_1 != etat)
_0x50:
	CPI  R30,LOW(0x5)
	BRNE _0x5A
	RCALL SUBOPT_0x4
	BREQ _0x53
;     229                            {
;     230         	            sprintf(display_buffer_ligne0,"Mode reglage    ");
	RCALL SUBOPT_0x5
	__POINTW1FN _52,199
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x6
;     231         	            sprintf(display_buffer_ligne1,"Ok->H Echp->Date");
	__POINTW1FN _52,216
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0xB
;     232         	            Affiche_LCD(display_buffer_ligne0,display_buffer_ligne1);
	RCALL SUBOPT_0xA
;     233         		   }               
;     234         	          switch(BP)
_0x53:
	LDD  R30,Y+7
;     235         		   {
;     236         		    case OK   : Heure_ou_Date = 0;
	CPI  R30,LOW(0x37)
	BRNE _0x57
	CLR  R30
	STD  Y+6,R30
;     237         		  	        H_J = 12;
	LDI  R30,LOW(12)
	STD  Y+4,R30
;     238         		  	        mn_mois = 30;
	LDI  R30,LOW(30)
	STD  Y+3,R30
;     239         		  	        sec_annee = 0;
	CLR  R30
	STD  Y+1,R30
	STD  Y+1+1,R30
;     240         		  	        regle_HTR(adresse_HTR,Heure_ou_Date, H_J, mn_mois, sec_annee);
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x11
;     241         		 	        etat = Attente;
	RJMP _0x1D3
;     242         		    break;
;     243         		 
;     244         		    case ECHAP : Heure_ou_Date = 1;
_0x57:
	CPI  R30,LOW(0x3B)
	BRNE _0x59
	LDI  R30,LOW(1)
	STD  Y+6,R30
;     245         		  	         H_J = 15;
	LDI  R30,LOW(15)
	STD  Y+4,R30
;     246         		  	         mn_mois = 6;
	LDI  R30,LOW(6)
	STD  Y+3,R30
;     247         		  	         sec_annee = 2002;
	LDI  R30,LOW(2002)
	LDI  R31,HIGH(2002)
	STD  Y+1,R30
	STD  Y+1+1,R31
;     248         		  	         regle_HTR(adresse_HTR,Heure_ou_Date, H_J, mn_mois, sec_annee);
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x11
;     249         		  	         etat = Attente;
	RJMP _0x1D3
;     250         		    break;
;     251         		 
;     252         		    default:     etat = Reglage_HTR;
_0x59:
	LDI  R30,LOW(5)
_0x1D3:
	STD  Y+9,R30
;     253         		   } 
;     254         		 
;     255         	          etat_1 = Reglage_HTR;
	LDI  R30,LOW(5)
	STD  Y+8,R30
;     256         break; 
	RJMP _0x3B
;     257         
;     258        default: etat = Attente;
_0x5A:
	RCALL SUBOPT_0x10
;     259        
;     260      };// fin graphe "Contrôle d'acces"
_0x3B:
;     261    };//fin boucle principale
	RJMP _0x36
;     262 } // fin prog princ 
	ADIW R28,47
_0x5B:
	RJMP _0x5B
;     263 
;     264 
;     265 
;     266 // Sous programme de traitement
;     267 // à compléter
;     268 unsigned char Traiter_code(unsigned char code,unsigned char Heure,unsigned char Jour_Sem) // à remplacer par votre solution
;     269 {
_Traiter_code:
;     270 
;     271 unsigned char etat;
;     272 etat=Jour;
	ST   -Y,R16
;	code -> Y+3
;	Heure -> Y+2
;	Jour_Sem -> Y+1
;	etat -> R16
	LDI  R16,LOW(0)
;     273       	
;     274 while(1)
_0x5D:
;     275 {
;     276 switch (etat)
	RCALL SUBOPT_0x12
;     277     {
;     278     case Jour : if ((Jour_Sem == 1) || (Jour_Sem == 2) || (Jour_Sem == 3) || (Jour_Sem == 4) || (Jour_Sem == 5)) etat = Status;
	BRNE _0x63
	RCALL SUBOPT_0x13
	BREQ _0x65
	RCALL SUBOPT_0x14
	BREQ _0x65
	RCALL SUBOPT_0x15
	BREQ _0x65
	RCALL SUBOPT_0x16
	BREQ _0x65
	RCALL SUBOPT_0x17
	BRNE _0x64
_0x65:
	LDI  R16,LOW(1)
;     279                 else return 0;
	RJMP _0x67
_0x64:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
_0x67:
;     280     break;
	RJMP _0x62
;     281     
;     282 
;     283     case Status : if (code == 2)  etat=prof;
_0x63:
	CPI  R30,LOW(0x1)
	BRNE _0x68
	LDD  R26,Y+3
	CPI  R26,LOW(0x2)
	BRNE _0x69
	LDI  R16,LOW(4)
;     284                  	else if (code == 8) etat = eleve1;
	RJMP _0x6A
_0x69:
	LDD  R26,Y+3
	CPI  R26,LOW(0x8)
	BRNE _0x6B
	LDI  R16,LOW(2)
;     285                       		else if (code == 4)  etat = eleve2;
	RJMP _0x6C
_0x6B:
	LDD  R26,Y+3
	CPI  R26,LOW(0x4)
	BRNE _0x6D
	LDI  R16,LOW(3)
;     286                            		else return 0;
	RJMP _0x6E
_0x6D:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
_0x6E:
_0x6C:
_0x6A:
;     287     break;
	RJMP _0x62
;     288 
;     289     case prof : return 1;
_0x68:
	CPI  R30,LOW(0x4)
	BRNE _0x6F
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     290     
;     291 
;     292     case eleve1 : if ((20 < Heure) && (Heure <7)) return 0;
_0x6F:
	CPI  R30,LOW(0x2)
	BREQ PC+2
	RJMP _0x70
	LDD  R30,Y+2
	LDI  R26,LOW(20)
	CP   R26,R30
	BRSH _0x72
	RCALL SUBOPT_0x18
	BRLO _0x73
_0x72:
	RJMP _0x71
_0x73:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     293                   else { if (((Jour_Sem  == 1) && (Jour_Sem  == 2)) && ((Heure > 8) && (Heure < 18))) return 0;
_0x71:
	RCALL SUBOPT_0x13
	BRNE _0x76
	RCALL SUBOPT_0x14
	BREQ _0x77
_0x76:
	RJMP _0x78
_0x77:
	RCALL SUBOPT_0x19
	BRSH _0x79
	RCALL SUBOPT_0x1A
	BRLO _0x7A
_0x79:
	RJMP _0x78
_0x7A:
	RJMP _0x7B
_0x78:
	RJMP _0x75
_0x7B:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     294                          else return 1;
_0x75:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     295 
;     296                          if ((Jour_Sem  == 3) && ((Heure > 10) && (Heure < 12))) return 0;
	RCALL SUBOPT_0x15
	BRNE _0x7E
	RCALL SUBOPT_0x1B
	BRSH _0x7F
	RCALL SUBOPT_0x1C
	BRLO _0x80
_0x7F:
	RJMP _0x7E
_0x80:
	RJMP _0x81
_0x7E:
	RJMP _0x7D
_0x81:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     297                          else return 1;
_0x7D:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     298 
;     299                          if ((Jour_Sem  == 4) && (((Heure > 8) && (Heure < 12)) || ((Heure > 15) && (Heure < 18)))) return 0;
	RCALL SUBOPT_0x16
	BRNE _0x84
	RCALL SUBOPT_0x19
	BRSH _0x85
	RCALL SUBOPT_0x1C
	BRLO _0x87
_0x85:
	RCALL SUBOPT_0x1D
	BRSH _0x88
	RCALL SUBOPT_0x1A
	BRLO _0x87
_0x88:
	RJMP _0x84
_0x87:
	RJMP _0x8B
_0x84:
	RJMP _0x83
_0x8B:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     300                          else return 1;
_0x83:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     301 
;     302                          if ((Jour_Sem  == 5) && ((Heure > 8) && (Heure > 16))) return 0;
	RCALL SUBOPT_0x17
	BRNE _0x8E
	RCALL SUBOPT_0x19
	BRSH _0x8F
	LDD  R26,Y+2
	LDI  R30,LOW(16)
	CP   R30,R26
	BRLO _0x90
_0x8F:
	RJMP _0x8E
_0x90:
	RJMP _0x91
_0x8E:
	RJMP _0x8D
_0x91:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     303                          else return 1;
_0x8D:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     304                         }
;     305      
;     306 
;     307     case eleve2 : if ((Heure >20) && (Heure < 7)) return 0;
	RJMP _0x93
_0x70:
	CPI  R30,LOW(0x3)
	BREQ PC+2
	RJMP _0x62
_0x93:
	LDD  R26,Y+2
	LDI  R30,LOW(20)
	CP   R30,R26
	BRSH _0x96
	RCALL SUBOPT_0x18
	BRLO _0x97
_0x96:
	RJMP _0x95
_0x97:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     308                   else { if ((Jour_Sem  == 1) && ((Heure > 10) && (Heure < 16))) return 0;
_0x95:
	RCALL SUBOPT_0x13
	BRNE _0x9A
	RCALL SUBOPT_0x1B
	BRSH _0x9B
	LDD  R26,Y+2
	CPI  R26,LOW(0x10)
	BRLO _0x9C
_0x9B:
	RJMP _0x9A
_0x9C:
	RJMP _0x9D
_0x9A:
	RJMP _0x99
_0x9D:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     309                          else return 1;
_0x99:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     310 
;     311                          if ((Jour_Sem  == 2) && ((Heure > 8) && (Heure < 17))) return 0;
	RCALL SUBOPT_0x14
	BRNE _0xA0
	RCALL SUBOPT_0x19
	BRSH _0xA1
	RCALL SUBOPT_0x1E
	BRLO _0xA2
_0xA1:
	RJMP _0xA0
_0xA2:
	RJMP _0xA3
_0xA0:
	RJMP _0x9F
_0xA3:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     312                          else return 1;
_0x9F:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     313 
;     314                          if ((Jour_Sem  == 3) && ((Heure > 8) && (Heure < 17))) return 0;
	RCALL SUBOPT_0x15
	BRNE _0xA6
	RCALL SUBOPT_0x19
	BRSH _0xA7
	RCALL SUBOPT_0x1E
	BRLO _0xA8
_0xA7:
	RJMP _0xA6
_0xA8:
	RJMP _0xA9
_0xA6:
	RJMP _0xA5
_0xA9:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     315                          else return 1;
_0xA5:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     316 
;     317                          if ((Jour_Sem  == 4) && ((Heure> 9) && (Heure < 15))) return 0;
	RCALL SUBOPT_0x16
	BRNE _0xAC
	LDD  R26,Y+2
	LDI  R30,LOW(9)
	CP   R30,R26
	BRSH _0xAD
	CPI  R26,LOW(0xF)
	BRLO _0xAE
_0xAD:
	RJMP _0xAC
_0xAE:
	RJMP _0xAF
_0xAC:
	RJMP _0xAB
_0xAF:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     318                          else return 1;
_0xAB:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     319 
;     320                          if ((Jour_Sem  == 5) && (((Heure> 8) && (Heure < 12)) || ((Heure > 15) && (Heure < 18)))) return 0;
	RCALL SUBOPT_0x17
	BRNE _0xB2
	RCALL SUBOPT_0x19
	BRSH _0xB3
	RCALL SUBOPT_0x1C
	BRLO _0xB5
_0xB3:
	RCALL SUBOPT_0x1D
	BRSH _0xB6
	RCALL SUBOPT_0x1A
	BRLO _0xB5
_0xB6:
	RJMP _0xB2
_0xB5:
	RJMP _0xB9
_0xB2:
	RJMP _0xB1
_0xB9:
	CLR  R30
	LDD  R16,Y+0
	RJMP _0x1CE
;     321                          else return 1;
_0xB1:
	LDI  R30,LOW(1)
	LDD  R16,Y+0
	RJMP _0x1CE
;     322                        }
;     323      }
_0x62:
;     324    }
	RJMP _0x5D
;     325 }
	LDD  R16,Y+0
	RJMP _0x1CE
_Lire_BP:

	.DSEG

	.CSEG
	RCALL __SAVELOCR2
	IN   R17,25
	ANDI R17,LOW(63)
	MOV  R30,R5
	CPI  R30,LOW(0x1)
	BRNE _0xBF
	CPI  R17,63
	BRNE _0xC0
	MOV  R16,R17
	RCALL SUBOPT_0x1F
	IN   R17,25
	ANDI R17,LOW(63)
	CP   R17,R16
	BRNE _0xC1
	CLR  R5
	LDI  R30,LOW(255)
	RJMP _0x1CF
_0xC1:
	CLR  R30
	RJMP _0x1CF
	RJMP _0xC3
_0xC0:
	CLR  R30
	RJMP _0x1CF
_0xC3:
	RJMP _0xBE
_0xBF:
	CPI  R30,0
	BRNE _0xBE
	CPI  R17,63
	BREQ _0xC5
	MOV  R16,R17
	RCALL SUBOPT_0x1F
	IN   R17,25
	ANDI R17,LOW(63)
	CP   R17,R16
	BRNE _0xC6
	LDI  R30,LOW(1)
	MOV  R5,R30
	MOV  R30,R17
	RJMP _0x1CF
_0xC6:
	LDI  R30,LOW(255)
	RJMP _0x1CF
	RJMP _0xC8
_0xC5:
	LDI  R30,LOW(255)
_0xC8:
_0xBE:
_0x1CF:
	RCALL __LOADLOCR2P
	RET
_Affiche_LCD:
	RCALL _lcd_clear
	RCALL SUBOPT_0x20
	RCALL _lcd_puts
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x0
	RCALL _lcd_gotoxy
	LD   R30,Y
	LDD  R31,Y+1
	ST   -Y,R31
	ST   -Y,R30
	RCALL _lcd_puts
_0x1CE:
	ADIW R28,4
	RET
_regle_HTR:
	SBIW R28,36
	RCALL __SAVELOCR5
	LDI  R17,LOW(0)
_0xCB:
	RCALL _Lire_BP
	MOV  R16,R30
	MOV  R30,R17
	CPI  R30,LOW(0x3)
	BRNE _0xD1
	LDD  R26,Y+45
	CPI  R26,LOW(0x1)
	BRNE _0xD2
	RCALL SUBOPT_0x21
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_set_date
	RJMP _0xD3
_0xD2:
	RCALL SUBOPT_0x21
	RCALL SUBOPT_0x22
	RCALL _rtc_set_time
_0xD3:
	CLR  R30
	CLR  R31
	RJMP _0x1CD
_0xD1:
	CPI  R30,0
	BREQ PC+2
	RJMP _0xD4
	RCALL SUBOPT_0x23
	BRNE _0xD5
	LDD  R26,Y+44
	CPI  R26,LOW(0x18)
	BRNE _0xD6
	RCALL SUBOPT_0x24
_0xD6:
	LDD  R26,Y+44
	CPI  R26,LOW(0xFF)
	BRNE _0xD7
	LDI  R30,LOW(23)
	STD  Y+44,R30
_0xD7:
	RCALL SUBOPT_0x25
	BRNE _0xD9
	CP   R17,R18
	BREQ _0xD8
_0xD9:
	RCALL SUBOPT_0x26
	__POINTW1FN _202,0
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x27
	__POINTW1FN _202,17
	RCALL SUBOPT_0x28
	RCALL SUBOPT_0x29
	RCALL SUBOPT_0x2A
	LDI  R24,12
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x2B
	LDD  R19,Y+44
_0xD8:
	RJMP _0xDB
_0xD5:
	LDD  R26,Y+44
	CPI  R26,LOW(0x20)
	BRNE _0xDC
	RCALL SUBOPT_0x24
_0xDC:
	LDD  R30,Y+44
	CPI  R30,0
	BRNE _0xDD
	LDI  R30,LOW(31)
	STD  Y+44,R30
_0xDD:
	RCALL SUBOPT_0x25
	BRNE _0xDF
	CP   R17,R18
	BREQ _0xDE
_0xDF:
	RCALL SUBOPT_0x26
	__POINTW1FN _202,38
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x27
	__POINTW1FN _202,55
	RCALL SUBOPT_0x28
	RCALL SUBOPT_0x29
	RCALL SUBOPT_0x2A
	LDI  R24,12
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x2B
	LDD  R19,Y+44
_0xDE:
_0xDB:
	RCALL SUBOPT_0x2C
	BRNE _0xE4
	LDD  R30,Y+44
	SUBI R30,-LOW(1)
	STD  Y+44,R30
	RJMP _0xE3
_0xE4:
	CPI  R30,LOW(0x2F)
	BRNE _0xE5
	LDD  R30,Y+44
	SUBI R30,LOW(1)
	STD  Y+44,R30
	RJMP _0xE3
_0xE5:
	CPI  R30,LOW(0x37)
	BRNE _0xE6
	LDI  R17,LOW(1)
	RJMP _0xE3
_0xE6:
	CPI  R30,LOW(0x3B)
	BRNE _0xE8
	LDI  R17,LOW(3)
	RJMP _0xE3
_0xE8:
	LDI  R17,LOW(0)
_0xE3:
	LDI  R18,LOW(0)
	RJMP _0xD0
_0xD4:
	CPI  R30,LOW(0x1)
	BREQ PC+2
	RJMP _0xE9
	RCALL SUBOPT_0x23
	BRNE _0xEA
	LDD  R26,Y+43
	CPI  R26,LOW(0x3C)
	BRNE _0xEB
	CLR  R30
	STD  Y+43,R30
_0xEB:
	LDD  R26,Y+43
	CPI  R26,LOW(0xFF)
	BRNE _0xEC
	LDI  R30,LOW(59)
	STD  Y+43,R30
_0xEC:
	RCALL SUBOPT_0x2D
	BRNE _0xEE
	CP   R17,R18
	BREQ _0xED
_0xEE:
	RCALL SUBOPT_0x26
	__POINTW1FN _202,72
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x27
	__POINTW1FN _202,89
	RCALL SUBOPT_0x28
	RCALL SUBOPT_0x29
	RCALL SUBOPT_0x2A
	LDI  R24,12
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x2B
	LDD  R20,Y+43
_0xED:
	RJMP _0xF0
_0xEA:
	LDD  R26,Y+43
	CPI  R26,LOW(0xD)
	BRNE _0xF1
	LDI  R30,LOW(1)
	STD  Y+43,R30
_0xF1:
	LDD  R30,Y+43
	CPI  R30,0
	BRNE _0xF2
	LDI  R30,LOW(12)
	STD  Y+43,R30
_0xF2:
	RCALL SUBOPT_0x2D
	BRNE _0xF4
	CP   R17,R18
	BREQ _0xF3
_0xF4:
	RCALL SUBOPT_0x26
	__POINTW1FN _202,110
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x27
	__POINTW1FN _202,127
	RCALL SUBOPT_0x28
	RCALL SUBOPT_0x29
	RCALL SUBOPT_0x2A
	LDI  R24,12
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x2B
	LDD  R20,Y+43
_0xF3:
_0xF0:
	RCALL SUBOPT_0x2C
	BRNE _0xF9
	LDD  R30,Y+43
	SUBI R30,-LOW(1)
	STD  Y+43,R30
	RJMP _0xF8
_0xF9:
	CPI  R30,LOW(0x2F)
	BRNE _0xFA
	LDD  R30,Y+43
	SUBI R30,LOW(1)
	STD  Y+43,R30
	RJMP _0xF8
_0xFA:
	CPI  R30,LOW(0x37)
	BRNE _0xFB
	LDI  R17,LOW(2)
	RJMP _0xF8
_0xFB:
	CPI  R30,LOW(0x3B)
	BRNE _0xFD
	LDI  R17,LOW(3)
	RJMP _0xF8
_0xFD:
	LDI  R17,LOW(1)
_0xF8:
	LDI  R18,LOW(1)
	RJMP _0xD0
_0xE9:
	CPI  R30,LOW(0x2)
	BREQ PC+2
	RJMP _0xD0
	RCALL SUBOPT_0x23
	BRNE _0xFF
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0x3C)
	LDI  R30,HIGH(0x3C)
	CPC  R27,R30
	BRNE _0x100
	CLR  R30
	STD  Y+41,R30
	STD  Y+41+1,R30
_0x100:
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0xFFFF)
	LDI  R30,HIGH(0xFFFF)
	CPC  R27,R30
	BRNE _0x101
	LDI  R30,LOW(59)
	LDI  R31,HIGH(59)
	STD  Y+41,R30
	STD  Y+41+1,R31
_0x101:
	RCALL SUBOPT_0x2E
	BRNE _0x103
	CP   R17,R18
	BREQ _0x102
_0x103:
	RCALL SUBOPT_0x26
	__POINTW1FN _202,144
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x27
	__POINTW1FN _202,161
	RCALL SUBOPT_0x28
	RCALL SUBOPT_0x29
	RCALL SUBOPT_0x2A
	LDI  R24,12
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x2B
	RCALL SUBOPT_0x2F
_0x102:
	RJMP _0x105
_0xFF:
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0x834)
	LDI  R30,HIGH(0x834)
	CPC  R27,R30
	BRNE _0x106
	RCALL SUBOPT_0x30
_0x106:
	LDD  R26,Y+41
	LDD  R27,Y+41+1
	CPI  R26,LOW(0x7CF)
	LDI  R30,HIGH(0x7CF)
	CPC  R27,R30
	BRNE _0x107
	RCALL SUBOPT_0x30
_0x107:
	RCALL SUBOPT_0x2E
	BRNE _0x109
	CP   R17,R18
	BREQ _0x108
_0x109:
	RCALL SUBOPT_0x26
	__POINTW1FN _202,182
	ST   -Y,R31
	ST   -Y,R30
	LDI  R24,0
	RCALL SUBOPT_0x27
	__POINTW1FN _202,199
	RCALL SUBOPT_0x28
	RCALL SUBOPT_0x29
	RCALL SUBOPT_0x2A
	LDI  R24,12
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x26
	RCALL SUBOPT_0x2B
	RCALL SUBOPT_0x2F
_0x108:
_0x105:
	RCALL SUBOPT_0x2C
	BRNE _0x10E
	RCALL SUBOPT_0x31
	RJMP _0x10D
_0x10E:
	CPI  R30,LOW(0x2F)
	BRNE _0x10F
	RCALL SUBOPT_0x31
	RJMP _0x10D
_0x10F:
	CPI  R30,LOW(0x37)
	BRNE _0x110
	LDI  R17,LOW(0)
	RJMP _0x10D
_0x110:
	CPI  R30,LOW(0x3B)
	BRNE _0x112
	LDI  R17,LOW(3)
	RJMP _0x10D
_0x112:
	LDI  R17,LOW(2)
_0x10D:
	LDI  R18,LOW(2)
_0xD0:
	RJMP _0xCB
_0x1CD:
	RCALL __LOADLOCR5
	ADIW R28,47
	RET
_D2000_read:
	ST   -Y,R16
	RCALL _i2c_start
	LDI  R30,LOW(160)
	RCALL SUBOPT_0x32
	RCALL SUBOPT_0x33
	RCALL _i2c_start
	LDI  R30,LOW(161)
	RCALL SUBOPT_0x32
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x34
	LDD  R16,Y+0
	ADIW R28,2
	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_0x35
	SBIW R30,0
	BREQ _0x14A
	RCALL SUBOPT_0x35
	ADIW R30,1
	RCALL __PUTWP1
	SBIW R30,1
	MOV  R26,R30
	MOV  R27,R31
	LDD  R30,Y+2
	ST   X,R30
	RJMP _0x14B
_0x14A:
	RCALL SUBOPT_0x36
	RCALL _putchar
_0x14B:
	ADIW R28,3
	RET
__print_G3:
	SBIW R28,6
	RCALL __SAVELOCR6
	LDI  R16,0
_0x14D:
	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 _0x14F
	RCALL SUBOPT_0x12
	BRNE _0x153
	CPI  R19,37
	BRNE _0x154
	LDI  R16,LOW(1)
	RJMP _0x155
_0x154:
	RCALL SUBOPT_0x37
_0x155:
	RJMP _0x152
_0x153:
	CPI  R30,LOW(0x1)
	BRNE _0x156
	CPI  R19,37
	BRNE _0x157
	RCALL SUBOPT_0x37
	LDI  R16,LOW(0)
	RJMP _0x152
_0x157:
	LDI  R16,LOW(2)
	LDI  R21,LOW(0)
	LDI  R17,LOW(0)
	CPI  R19,45
	BRNE _0x158
	LDI  R17,LOW(1)
	RJMP _0x152
_0x158:
	CPI  R19,43
	BRNE _0x159
	LDI  R21,LOW(43)
	RJMP _0x152
_0x159:
	CPI  R19,32
	BRNE _0x15A
	LDI  R21,LOW(32)
	RJMP _0x152
_0x15A:
	RJMP _0x15B
_0x156:
	CPI  R30,LOW(0x2)
	BRNE _0x15C
_0x15B:
	LDI  R20,LOW(0)
	LDI  R16,LOW(3)
	CPI  R19,48
	BRNE _0x15D
	ORI  R17,LOW(128)
	RJMP _0x152
_0x15D:
	RJMP _0x15E
_0x15C:
	CPI  R30,LOW(0x3)
	BREQ PC+2
	RJMP _0x152
_0x15E:
	CPI  R19,48
	BRLO _0x161
	CPI  R19,58
	BRLO _0x162
_0x161:
	RJMP _0x160
_0x162:
	MOV  R18,R20
	LSL  R20
	LSL  R20
	ADD  R20,R18
	LSL  R20
	MOV  R30,R19
	SUBI R30,LOW(48)
	ADD  R20,R30
	RJMP _0x152
_0x160:
	MOV  R30,R19
	CPI  R30,LOW(0x63)
	BRNE _0x166
	RCALL SUBOPT_0x38
	LD   R30,X
	RCALL SUBOPT_0x39
	RJMP _0x167
_0x166:
	CPI  R30,LOW(0x73)
	BRNE _0x169
	RCALL SUBOPT_0x38
	RCALL SUBOPT_0x3A
	RCALL _strlen
	MOV  R16,R30
	RJMP _0x16A
_0x169:
	CPI  R30,LOW(0x70)
	BRNE _0x16C
	RCALL SUBOPT_0x38
	RCALL SUBOPT_0x3A
	RCALL _strlenf
	MOV  R16,R30
	ORI  R17,LOW(8)
_0x16A:
	ORI  R17,LOW(2)
	ANDI R17,LOW(127)
	LDI  R18,LOW(0)
	RJMP _0x16D
_0x16C:
	CPI  R30,LOW(0x64)
	BREQ _0x170
	CPI  R30,LOW(0x69)
	BRNE _0x171
_0x170:
	ORI  R17,LOW(4)
	RJMP _0x172
_0x171:
	CPI  R30,LOW(0x75)
	BRNE _0x173
_0x172:
	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 _0x174
_0x173:
	CPI  R30,LOW(0x58)
	BRNE _0x176
	ORI  R17,LOW(8)
	RJMP _0x177
_0x176:
	CPI  R30,LOW(0x78)
	BREQ PC+2
	RJMP _0x1A5
_0x177:
	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)
_0x174:
	SBRS R17,2
	RJMP _0x179
	RCALL SUBOPT_0x38
	RCALL SUBOPT_0x3B
	LDD  R26,Y+10
	LDD  R27,Y+10+1
	SBIW R26,0
	BRGE _0x17A
	LDD  R30,Y+10
	LDD  R31,Y+10+1
	RCALL __ANEGW1
	STD  Y+10,R30
	STD  Y+10+1,R31
	LDI  R21,LOW(45)
_0x17A:
	CPI  R21,0
	BREQ _0x17B
	SUBI R16,-LOW(1)
	RJMP _0x17C
_0x17B:
	ANDI R17,LOW(251)
_0x17C:
	RJMP _0x17D
_0x179:
	RCALL SUBOPT_0x38
	RCALL SUBOPT_0x3B
_0x17D:
_0x16D:
	SBRC R17,0
	RJMP _0x17E
_0x17F:
	CP   R16,R20
	BRSH _0x181
	SBRS R17,7
	RJMP _0x182
	SBRS R17,2
	RJMP _0x183
	ANDI R17,LOW(251)
	MOV  R19,R21
	SUBI R16,LOW(1)
	RJMP _0x184
_0x183:
	LDI  R19,LOW(48)
_0x184:
	RJMP _0x185
_0x182:
	LDI  R19,LOW(32)
_0x185:
	RCALL SUBOPT_0x37
	SUBI R20,LOW(1)
	RJMP _0x17F
_0x181:
_0x17E:
	MOV  R18,R16
	SBRS R17,1
	RJMP _0x186
_0x187:
	CPI  R18,0
	BREQ _0x189
	SBRS R17,3
	RJMP _0x18A
	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
	MOV  R30,R0
	RJMP _0x1D4
_0x18A:
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	LD   R30,X+
	STD  Y+6,R26
	STD  Y+6+1,R27
_0x1D4:
	ST   -Y,R30
	RCALL SUBOPT_0x3C
	CPI  R20,0
	BREQ _0x18C
	SUBI R20,LOW(1)
_0x18C:
	SUBI R18,LOW(1)
	RJMP _0x187
_0x189:
	RJMP _0x18D
_0x186:
_0x18F:
	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 _0x191
	SBRS R17,3
	RJMP _0x192
	SUBI R19,-LOW(7)
	RJMP _0x193
_0x192:
	SUBI R19,-LOW(39)
_0x193:
_0x191:
	SBRC R17,4
	RJMP _0x195
	LDI  R30,LOW(48)
	CP   R30,R19
	BRLO _0x197
	LDD  R26,Y+8
	LDD  R27,Y+8+1
	CPI  R26,LOW(0x1)
	LDI  R30,HIGH(0x1)
	CPC  R27,R30
	BRNE _0x196
_0x197:
	ORI  R17,LOW(16)
	RJMP _0x199
_0x196:
	CP   R20,R18
	BRLO _0x19B
	SBRS R17,0
	RJMP _0x19C
_0x19B:
	RJMP _0x19A
_0x19C:
	LDI  R19,LOW(32)
	SBRS R17,7
	RJMP _0x19D
	LDI  R19,LOW(48)
	ORI  R17,LOW(16)
_0x199:
	SBRS R17,2
	RJMP _0x19E
	ANDI R17,LOW(251)
	ST   -Y,R21
	RCALL SUBOPT_0x3C
	CPI  R20,0
	BREQ _0x19F
	SUBI R20,LOW(1)
_0x19F:
_0x19E:
_0x19D:
_0x195:
	RCALL SUBOPT_0x37
	CPI  R20,0
	BREQ _0x1A0
	SUBI R20,LOW(1)
_0x1A0:
_0x19A:
	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 _0x190
	RJMP _0x18F
_0x190:
_0x18D:
	SBRS R17,0
	RJMP _0x1A1
_0x1A2:
	CPI  R20,0
	BREQ _0x1A4
	SUBI R20,LOW(1)
	LDI  R30,LOW(32)
	RCALL SUBOPT_0x39
	RJMP _0x1A2
_0x1A4:
_0x1A1:
_0x1A5:
_0x167:
	LDI  R16,LOW(0)
_0x152:
	RJMP _0x14D
_0x14F:
	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_0x3D
	ST   Y,R30
	STD  Y+1,R31
	MOV  R26,R28
	MOV  R27,R29
	ADIW R26,4
	RCALL SUBOPT_0x3D
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+4
	LDD  R31,Y+4+1
	ST   -Y,R31
	ST   -Y,R30
	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
	CLR  R30
	ST   X,R30
	RJMP _0x1CA
_rtc_read:
	ST   -Y,R16
	RCALL SUBOPT_0x3E
	MOV  R16,R30
	RCALL _i2c_start
	ST   -Y,R16
	RCALL _i2c_write
	RCALL SUBOPT_0x33
	RCALL _i2c_start
	MOV  R30,R16
	ORI  R30,1
	RCALL SUBOPT_0x32
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x34
	LDD  R16,Y+0
	RJMP _0x1CB
_rtc_write:
	RCALL _i2c_start
	RCALL SUBOPT_0x3E
	RCALL SUBOPT_0x32
	RCALL SUBOPT_0x33
	RCALL SUBOPT_0xE
	RCALL _i2c_write
	RCALL _i2c_stop
	RJMP _0x1CB
_rtc_get_status:
	RCALL SUBOPT_0xE
	RCALL SUBOPT_0x1
	RCALL _rtc_read
	MOV  R4,R30
	BST  R4,1
	BLD  R2,0
	MOV  R30,R4
	RJMP _0x1CC
_rtc_init:
	ST   -Y,R16
	LDI  R16,LOW(144)
	LDD  R30,Y+1
	CPI  R30,0
	BREQ _0x1B2
	LDI  R16,LOW(176)
_0x1B2:
	CLR  R4
	CLT
	BLD  R2,0
	LDD  R30,Y+2
	RCALL SUBOPT_0x22
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x3F
	RCALL SUBOPT_0x40
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x40
	RCALL _rtc_read
	RCALL SUBOPT_0x42
	RCALL SUBOPT_0x3F
	LDI  R30,LOW(8)
	ST   -Y,R30
	ST   -Y,R16
	RCALL _rtc_write
	LDD  R16,Y+0
	RJMP _0x1CB
_rtc_stop:
	RCALL SUBOPT_0xE
	RCALL SUBOPT_0x43
	ORI  R30,0x80
	RCALL SUBOPT_0x44
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x45
	RJMP _0x1CC
_rtc_start:
	RCALL SUBOPT_0xE
	RCALL SUBOPT_0x43
	ANDI R30,0x7F
	RCALL SUBOPT_0x44
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x45
	RJMP _0x1CC
_rtc_hold_off:
	RCALL SUBOPT_0xE
	RCALL SUBOPT_0x43
	ANDI R30,0xBF
	RCALL SUBOPT_0x44
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x45
	RJMP _0x1CC
_rtc_hold_on:
	RCALL SUBOPT_0xE
	RCALL SUBOPT_0x43
	ORI  R30,0x40
	RCALL SUBOPT_0x44
	RCALL SUBOPT_0x1
	RCALL SUBOPT_0x45
_0x1CC:
	ADIW R28,1
	RET
_rtc_read_bcd:
	RCALL SUBOPT_0x46
	RCALL SUBOPT_0x46
	RCALL _rtc_read
	RCALL SUBOPT_0x47
	ADIW R28,2
	RET
_rtc_write_bcd:
	RCALL SUBOPT_0x36
	RCALL SUBOPT_0x36
	RCALL SUBOPT_0x36
	RCALL _bin2bcd
	RCALL SUBOPT_0x48
_0x1CB:
	ADIW R28,3
	RET
_rtc_write_word:
	RCALL SUBOPT_0x49
	RCALL SUBOPT_0x49
	RCALL SUBOPT_0x36
	RCALL _rtc_write
	RCALL SUBOPT_0x49
	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_0x48
_0x1CA:
	ADIW R28,4
	RET
_rtc_write_date:
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x41
	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_0x48
	RJMP _0x1C9
_rtc_get_time:
	RCALL SUBOPT_0x4A
	RCALL _rtc_hold_on
	RCALL SUBOPT_0x4A
	RCALL SUBOPT_0x0
	RCALL _rtc_read_bcd
	LD   R26,Y
	LDD  R27,Y+1
	RCALL SUBOPT_0x4B
	RCALL SUBOPT_0x4C
	RCALL _rtc_read_bcd
	LDD  R26,Y+2
	LDD  R27,Y+2+1
	RCALL SUBOPT_0x4B
	RCALL SUBOPT_0x4D
	RCALL _rtc_read_bcd
	LDD  R26,Y+4
	LDD  R27,Y+4+1
	RCALL SUBOPT_0x4B
	RCALL SUBOPT_0x40
	RCALL _rtc_read_bcd
	LDD  R26,Y+6
	LDD  R27,Y+6+1
	RCALL SUBOPT_0x4B
	RCALL _rtc_hold_off
	ADIW R28,9
	RET
_rtc_set_time:
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x4E
	RCALL SUBOPT_0x0
	RCALL SUBOPT_0x36
	RCALL SUBOPT_0x4F
	RCALL SUBOPT_0x4C
	RCALL SUBOPT_0x49
	RCALL SUBOPT_0x4F
	RCALL SUBOPT_0x4D
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x4F
	RCALL SUBOPT_0x40
	RCALL SUBOPT_0x50
	RCALL SUBOPT_0x4F
	RCALL _rtc_start
	RJMP _0x1C9
_rtc_get_date:
	SBIW R28,3
	RCALL SUBOPT_0x51
	RCALL _rtc_hold_on
	RCALL SUBOPT_0x51
	RCALL SUBOPT_0x52
	RCALL _rtc_read
	RCALL SUBOPT_0x53
	RCALL SUBOPT_0x54
	RCALL _rtc_read
	ANDI R30,LOW(0x1F)
	RCALL SUBOPT_0x47
	LDD  R26,Y+5
	LDD  R27,Y+5+1
	ST   X,R30
	RCALL SUBOPT_0x51
	RCALL _rtc_hold_off
	LDD  R30,Y+2
	RCALL SUBOPT_0x42
	RCALL _bcd2bin
	LDD  R26,Y+7
	LDD  R27,Y+7+1
	ST   X,R30
	LDD  R30,Y+2
	SWAP R30
	ANDI R30,0xF
	LSR  R30
	LSR  R30
	RCALL SUBOPT_0x53
	RCALL SUBOPT_0x2
	RCALL _rtc_read
	PUSH R30
	RCALL SUBOPT_0x51
	LDI  R30,LOW(17)
	ST   -Y,R30
	RCALL _rtc_read
	MOV  R31,R30
	CLR  R30
	POP  R26
	CLR  R27
	OR   R30,R26
	OR   R31,R27
	ST   Y,R30
	STD  Y+1,R31
	LD   R30,Y
	ANDI R30,LOW(0x3)
	MOV  R26,R30
	LDD  R30,Y+2
	CP   R30,R26
	BREQ _0x1BE
	RCALL SUBOPT_0x51
	RCALL SUBOPT_0x2
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	ADIW R30,1
	STD  Y+2,R30
	STD  Y+2+1,R31
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_write_word
_0x1BE:
	LD   R30,Y
	LDD  R31,Y+1
	LDD  R26,Y+3
	LDD  R27,Y+3+1
	RCALL __PUTWP1
	ADIW R28,10
	RET
_rtc_set_date:
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x2
	RCALL SUBOPT_0x20
	RCALL _rtc_write_word
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x4E
	RCALL SUBOPT_0x52
	RCALL SUBOPT_0x50
	LDD  R30,Y+3
	LDD  R31,Y+3+1
	ST   -Y,R31
	ST   -Y,R30
	RCALL _rtc_write_date
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x54
	RCALL SUBOPT_0x41
	RCALL SUBOPT_0x4F
	RCALL _rtc_start
_0x1C9:
	ADIW R28,5
	RET

	.DSEG
__base_y_G5:
	.BYTE 0x4
    .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

	.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
    sbic  __lcd_pin,__lcd_busy_flag
    rjmp  __lcd_busy
    cbi   __lcd_port,__lcd_enable ;EN=0
	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_gotoxy:
	RCALL __lcd_ready
	LD   R30,Y
	CLR  R31
	SUBI R30,LOW(-__base_y_G5)
	SBCI R31,HIGH(-__base_y_G5)
	LD   R30,Z
	LDD  R26,Y+1
	ADD  R30,R26
	RCALL SUBOPT_0x55
	LDD  R6,Y+1
	LDD  R7,Y+0
	ADIW R28,2
	RET
_lcd_clear:
	RCALL __lcd_ready
	LDI  R30,LOW(12)
	RCALL SUBOPT_0x55
	RCALL __lcd_ready
	RCALL SUBOPT_0x0
	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 _0x1C5
	__lcd_putchar1:
	INC  R7
	RCALL SUBOPT_0x1
	ST   -Y,R7
	RCALL _lcd_gotoxy
	brts __lcd_putchar0
_0x1C5:
    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:
    clr   r26
    clr   r27
__long_delay0:
    sbiw  r26,1         ;2 cycles
    brne  __long_delay0 ;2 cycles
	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_G5,2
	LD   R30,Y
	SUBI R30,-LOW(192)
	__PUTB1MN __base_y_G5,3
	RCALL SUBOPT_0x56
	RCALL SUBOPT_0x56
	RCALL SUBOPT_0x56
	RCALL __long_delay
	LDI  R30,LOW(32)
	RCALL SUBOPT_0x55
	RCALL __lcd_ready
	LDI  R30,LOW(40)
	RCALL SUBOPT_0x55
	RCALL __lcd_ready
	RCALL SUBOPT_0x54
	RCALL __lcd_write_data
	RCALL _lcd_clear
	ADIW R28,1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 10 TIMES
SUBOPT_0x0:
	LDI  R30,LOW(1)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 13 TIMES
SUBOPT_0x1:
	CLR  R30
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x2:
	LDI  R30,LOW(16)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3:
	LDI  R30,LOW(16)
	LDI  R31,HIGH(16)
	ST   -Y,R31
	ST   -Y,R30
	LDI  R30,LOW(17)
	LDI  R31,HIGH(17)
	ST   -Y,R31
	ST   -Y,R30
	LDI  R30,LOW(18)
	LDI  R31,HIGH(18)
	ST   -Y,R31
	ST   -Y,R30
	LDI  R30,LOW(20)
	LDI  R31,HIGH(20)
	ST   -Y,R31
	ST   -Y,R30
	RJMP _rtc_get_time

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x4:
	LDD  R30,Y+9
	LDD  R26,Y+8
	CP   R30,R26
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 14 TIMES
SUBOPT_0x5:
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,30
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x6:
	RCALL _sprintf
	ADIW R28,4
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,13
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x7:
	MOV  R30,R16
	CLR  R31
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 17 TIMES
SUBOPT_0x8:
	CLR  R31
	CLR  R22
	CLR  R23
	RCALL __PUTPARD1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 8 TIMES
SUBOPT_0x9:
	RCALL _sprintf
	ADIW R28,16
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 7 TIMES
SUBOPT_0xA:
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,15
	ST   -Y,R31
	ST   -Y,R30
	RJMP _Affiche_LCD

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0xB:
	RCALL _sprintf
	ADIW R28,4
	RJMP SUBOPT_0x5

;OPTIMIZER ADDED SUBROUTINE, CALLED 9 TIMES
SUBOPT_0xC:
	ST   -Y,R31
	ST   -Y,R30
	RJMP _delay_ms

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xD:
	ST   -Y,R31
	ST   -Y,R30
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,15
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 11 TIMES
SUBOPT_0xE:
	LD   R30,Y
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0xF:
	LDI  R30,LOW(5000)
	LDI  R31,HIGH(5000)
	RJMP SUBOPT_0xC

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x10:
	CLR  R30
	STD  Y+9,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x11:
	LDD  R30,Y+7
	ST   -Y,R30
	LDD  R30,Y+6
	ST   -Y,R30
	LDD  R30,Y+6
	ST   -Y,R30
	LDD  R30,Y+5
	LDD  R31,Y+5+1
	ST   -Y,R31
	ST   -Y,R30
	RCALL _regle_HTR
	CLR  R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x12:
	MOV  R30,R16
	CPI  R30,0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x13:
	LDD  R26,Y+1
	CPI  R26,LOW(0x1)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x14:
	LDD  R26,Y+1
	CPI  R26,LOW(0x2)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x15:
	LDD  R26,Y+1
	CPI  R26,LOW(0x3)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x16:
	LDD  R26,Y+1
	CPI  R26,LOW(0x4)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x17:
	LDD  R26,Y+1
	CPI  R26,LOW(0x5)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x18:
	LDD  R26,Y+2
	CPI  R26,LOW(0x7)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x19:
	LDD  R26,Y+2
	LDI  R30,LOW(8)
	CP   R30,R26
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x1A:
	LDD  R26,Y+2
	CPI  R26,LOW(0x12)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1B:
	LDD  R26,Y+2
	LDI  R30,LOW(10)
	CP   R30,R26
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x1C:
	LDD  R26,Y+2
	CPI  R26,LOW(0xC)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1D:
	LDD  R26,Y+2
	LDI  R30,LOW(15)
	CP   R30,R26
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1E:
	LDD  R26,Y+2
	CPI  R26,LOW(0x11)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1F:
	LDI  R30,LOW(20)
	LDI  R31,HIGH(20)
	RJMP SUBOPT_0xC

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x20:
	LDD  R30,Y+2
	LDD  R31,Y+2+1
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x21:
	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 2 TIMES
SUBOPT_0x22:
	ST   -Y,R30
	RJMP SUBOPT_0x1

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x23:
	LDD  R30,Y+45
	CPI  R30,0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x24:
	CLR  R30
	STD  Y+44,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x25:
	LDD  R30,Y+44
	CP   R30,R19
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 12 TIMES
SUBOPT_0x26:
	MOV  R30,R28
	MOV  R31,R29
	ADIW R30,22
	ST   -Y,R31
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x27:
	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_0x28:
	ST   -Y,R31
	ST   -Y,R30
	LDD  R30,Y+48
	RJMP SUBOPT_0x8

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x29:
	LDD  R30,Y+51
	RJMP SUBOPT_0x8

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x2A:
	LDD  R30,Y+53
	LDD  R31,Y+53+1
	RCALL __CWD1
	RCALL __PUTPARD1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x2B:
	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_0x2C:
	MOV  R30,R16
	CPI  R30,LOW(0x1F)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2D:
	LDD  R30,Y+43
	CP   R30,R20
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x2E:
	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_0x2F:
	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_0x30:
	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_0x31:
	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 7 TIMES
SUBOPT_0x32:
	ST   -Y,R30
	RJMP _i2c_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x33:
	LDD  R30,Y+1
	RJMP SUBOPT_0x32

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x34:
	RCALL _i2c_read
	MOV  R16,R30
	RCALL _i2c_stop
	MOV  R30,R16
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x35:
	LD   R26,Y
	LDD  R27,Y+1
	RCALL __GETW1P
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 8 TIMES
SUBOPT_0x36:
	LDD  R30,Y+2
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x37:
	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_0x38:
	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_0x39:
	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_0x3A:
	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_0x3B:
	RCALL __GETW1P
	STD  Y+10,R30
	STD  Y+10+1,R31
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3C:
	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_0x3D:
	RCALL __ADDW2R15
	RCALL __GETW1P
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3E:
	LDD  R30,Y+2
	LSL  R30
	ORI  R30,LOW(0xA0)
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x3F:
	RCALL _rtc_write
	RJMP SUBOPT_0x36

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x40:
	LDI  R30,LOW(4)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 17 TIMES
SUBOPT_0x41:
	LDD  R30,Y+4
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x42:
	ANDI R30,LOW(0x3F)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x43:
	RCALL _rtc_get_status
	MOV  R30,R4
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x44:
	MOV  R4,R30
	RJMP SUBOPT_0xE

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x45:
	ST   -Y,R4
	RJMP _rtc_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x46:
	LDD  R30,Y+1
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x47:
	ST   -Y,R30
	RJMP _bcd2bin

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x48:
	ST   -Y,R30
	RJMP _rtc_write

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x49:
	LDD  R30,Y+3
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 6 TIMES
SUBOPT_0x4A:
	LDD  R30,Y+8
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x4B:
	ST   X,R30
	RJMP SUBOPT_0x4A

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x4C:
	LDI  R30,LOW(2)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x4D:
	LDI  R30,LOW(3)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x4E:
	RCALL _rtc_stop
	RJMP SUBOPT_0x41

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x4F:
	RCALL _rtc_write_bcd
	RJMP SUBOPT_0x41

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x50:
	LDD  R30,Y+5
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 7 TIMES
SUBOPT_0x51:
	LDD  R30,Y+9
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x52:
	LDI  R30,LOW(5)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x53:
	STD  Y+2,R30
	RJMP SUBOPT_0x51

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x54:
	LDI  R30,LOW(6)
	ST   -Y,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 7 TIMES
SUBOPT_0x55:
	ST   -Y,R30
	RJMP __lcd_write_data

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x56:
	RCALL __long_delay
	LDI  R30,LOW(48)
	RJMP SUBOPT_0x55

	.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

__ADDW2R15:
	CLR  R0
	ADD  R26,R15
	ADC  R27,R0
	RET

__ANEGW1:
	COM  R30
	COM  R31
	ADIW R30,1
	RET

__CWD1:
	CLR  R22
	CLR  R23
	SBRS R31,7
	RET
	SER  R22
	SER  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

__PUTPARD1:
	ST   -Y,R23
	ST   -Y,R22
	ST   -Y,R31
	ST   -Y,R30
	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

