;CodeVisionAVR C Compiler V1.0.2.2d Standard
;(C) Copyright 1998-2002 Pavel Haiduc, HP InfoTech s.r.l.
;http://www.hpinfotech.ro
;e-mail:office@hpinfotech.ro , hpinfotech@xmail.ro

;Chip type           : AT90S8535
;Clock frequency     : 4,000000 MHz
;Memory model        : Small
;Optimize for        : Size
;Internal SRAM size  : 512
;External SRAM size  : 0
;Data Stack size     : 128
;Promote char to int : No
;char is unsigned    : 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 __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 0x11

	.INCLUDE "morse1.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-R15
	LDI  R24,14
	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(0xDF)
	LDI  R29,HIGH(0xDF)

	RJMP _main

	.ESEG
	.ORG 1

	.DSEG
	.ORG 0xE0
;       1 /*********************************************
;       2 This program was produced by the
;       3 CodeWizardAVR V1.23.7a Light
;       4 Automatic Program Generator
;       5 © Copyright 1998-2002 HP InfoTech s.r.l.
;       6 http://www.hpinfotech.ro
;       7 e-mail:office@hpinfotech.ro
;       8 
;       9 Project : PPE COMMUNICATION EN MORSE
;      10 Version : 1
;      11 Date    : 24/02/2003
;      12 Author  : Philippe MARIANO
;      13 Company : Lycee Pierre Emile MARTIN, Bourges
;      14 Comments: Acquisition d'une touche sur un clavier de PC et 
;      15           affichage du caractère correspondant sur un afficheur LCD
;      16           Configuration de la carte SSI : cavalier PA0 en1-2
;      17           				  cavalier HTR/INT sur INT
;      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 // CodeVisionAVR C Compiler
;      28 // (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.
;      29 
;      30 // I/O registers definitions for the AT90S8535
;      31 
;      32 #ifndef _90S8535_INCLUDED_
;      33 #define _90S8535_INCLUDED_
;      34 
;      35 #pragma used+
;      36 sfrb ADCL=4;
;      37 sfrb ADCH=5;
;      38 sfrw ADCW=4;      // 16 bit access
;      39 sfrb ADCSR=6;
;      40 sfrb ADMUX=7;
;      41 sfrb ACSR=8;
;      42 sfrb UBRR=9;
;      43 sfrb UCR=0xa;
;      44 sfrb USR=0xb;
;      45 sfrb UDR=0xc;
;      46 sfrb SPCR=0xd;
;      47 sfrb SPSR=0xe;
;      48 sfrb SPDR=0xf;
;      49 sfrb PIND=0x10;
;      50 sfrb DDRD=0x11;
;      51 sfrb PORTD=0x12;
;      52 sfrb PINC=0x13;
;      53 sfrb DDRC=0x14;
;      54 sfrb PORTC=0x15;
;      55 sfrb PINB=0x16;
;      56 sfrb DDRB=0x17;
;      57 sfrb PORTB=0x18;
;      58 sfrb PINA=0x19;
;      59 sfrb DDRA=0x1a;
;      60 sfrb PORTA=0x1b;
;      61 sfrb EECR=0x1c;
;      62 sfrb EEDR=0x1d;
;      63 sfrb EEARL=0x1e;
;      64 sfrb EEARH=0x1f;
;      65 sfrw EEAR=0x1e;   // 16 bit access
;      66 sfrb WDTCR=0x21;
;      67 sfrb ASSR=0x22;
;      68 sfrb OCR2=0x23;
;      69 sfrb TCNT2=0x24;
;      70 sfrb TCCR2=0x25;
;      71 sfrb ICR1L=0x26;
;      72 sfrb ICR1H=0x27;
;      73 sfrw ICR1=0x26;   // 16 bit access
;      74 sfrb OCR1BL=0x28;
;      75 sfrb OCR1BH=0x29;
;      76 sfrw OCR1B=0x28;  // 16 bit access
;      77 sfrb OCR1AL=0x2a;
;      78 sfrb OCR1AH=0x2b;
;      79 sfrw OCR1A=0x2a;  // 16 bit access
;      80 sfrb TCNT1L=0x2c;
;      81 sfrb TCNT1H=0x2d;
;      82 sfrw TCNT1=0x2c;  // 16 bit access
;      83 sfrb TCCR1B=0x2e;
;      84 sfrb TCCR1A=0x2f;
;      85 sfrb TCNT0=0x32;
;      86 sfrb TCCR0=0x33;
;      87 sfrb MCUSR=0x34;
;      88 sfrb MCUCR=0x35;
;      89 sfrb TIFR=0x38;
;      90 sfrb TIMSK=0x39;
;      91 sfrb GIFR=0x3a;
;      92 sfrb GIMSK=0x3b;
;      93 sfrb SPL=0x3d;
;      94 sfrb SPH=0x3e;
;      95 sfrb SREG=0x3f;
;      96 #pragma used-
;      97 
;      98 // Interrupt vectors definitions
;      99 
;     100 #define EXT_INT0 2
;     101 #define EXT_INT1 3
;     102 #define TIM2_COMP 4
;     103 #define TIM2_OVF 5
;     104 #define TIM1_CAPT 6
;     105 #define TIM1_COMPA 7
;     106 #define TIM1_COMPB 8
;     107 #define TIM1_OVF 9
;     108 #define TIM0_OVF 10
;     109 #define SPI_STC 11
;     110 #define UART_RXC 12
;     111 #define UART_DRE 13
;     112 #define UART_TXC 14
;     113 #define ADC_INT 15
;     114 #define EE_RDY 16
;     115 #define ANA_COMP 17
;     116 
;     117 #endif
;     118 
;     119 #include <Scancode2.h>
;     120 // Unshifted characters
;     121 
;     122 flash unsigned char unshifted[68][2]={

	.CSEG
;     123 0x0d,9,
;     124 0x0e,'|',
;     125 0x15,'a',
;     126 0x16,'&',
;     127 0x1a,'w',
;     128 0x1b,'s',
;     129 0x1c,'q',
;     130 0x1d,'z',
;     131 0x1e,'',
;     132 0x21,'c',
;     133 0x22,'x',
;     134 0x23,'d',
;     135 0x24,'e',
;     136 0x25,0x27,
;     137 0x26,'"',
;     138 0x29,' ',
;     139 0x2a,'v',
;     140 0x2b,'f',
;     141 0x2c,'t',
;     142 0x2d,'r',
;     143 0x2e,'(',
;     144 0x31,'n',
;     145 0x32,'b',
;     146 0x33,'h',
;     147 0x34,'g',
;     148 0x35,'y',
;     149 0x36,'-',
;     150 0x39,',',
;     151 0x3a,',',
;     152 0x3b,'j',
;     153 0x3c,'u',
;     154 0x3d,'',
;     155 0x3e,'_',
;     156 0x41,';',
;     157 0x42,'k',
;     158 0x43,'i',
;     159 0x44,')',
;     160 0x45,'0',
;     161 0x46,'^',
;     162 0x49,':',
;     163 0x4a,'-',
;     164 0x4b,'l',
;     165 0x4c,'',
;     166 0x4d,'p',
;     167 0x4e,')',
;     168 0x52,'',
;     169 0x54,'',
;     170 0x55,'',
;     171 0x5a,'',
;     172 0x5b,'"',
;     173 0x5d,'',
;     174 0x61,'<',
;     175 0x66,'',
;     176 0x69,'1',
;     177 0x6b,'4',
;     178 0x6c,'7',
;     179 0x70,'0',
;     180 0x71,',',
;     181 0x72,'2',
;     182 0x73,'5',
;     183 0x74,'6',
;     184 0x75,'8',
;     185 0x79,'+',
;     186 0x7a,'3',
;     187 0x7b,'!',
;     188 0x7c,'*',
;     189 0x7d,'9',
;     190 0,0
;     191 };
;     192 
;     193 flash unsigned char shifted[68][2]={
;     194 0x0d,'',
;     195 0x0e,'',
;     196 0x15,'A',
;     197 0x16,'1',
;     198 0x1a,'W',
;     199 0x1b,'S',
;     200 0x1c,'Q',
;     201 0x1d,'Z',
;     202 0x1e,'2',
;     203 0x21,'C',
;     204 0x22,'X',
;     205 0x23,'D',
;     206 0x24,'E',
;     207 0x25,'4',
;     208 0x26,'3',
;     209 0x29,' ',
;     210 0x2a,'V',
;     211 0x2b,'F',
;     212 0x2c,'T',
;     213 0x2d,'R',
;     214 0x2e,'5',
;     215 0x31,'N',
;     216 0x32,'B',
;     217 0x33,'H',
;     218 0x34,'G',
;     219 0x35,'Y',
;     220 0x36,'6',
;     221 0x39,'L',
;     222 0x3a,'?',
;     223 0x3b,'J',
;     224 0x3c,'U',
;     225 0x3d,'7',
;     226 0x3e,'8',
;     227 0x41,'.',
;     228 0x42,'K',
;     229 0x43,'I',
;     230 0x44,'O',
;     231 0x45,'0',
;     232 0x46,'9',
;     233 0x49,'/',
;     234 0x4a,'',
;     235 0x4b,'L',
;     236 0x4c,'',
;     237 0x4d,'P',
;     238 0x4e,'°',
;     239 0x52,'',
;     240 0x54,'',
;     241 0x55,'+',
;     242 0x5a,'',
;     243 0x5b,'^',
;     244 0x5d,'*',
;     245 0x61,'>',
;     246 0x66,'',
;     247 0x69,'1',
;     248 0x6b,'4',
;     249 0x6c,'7',
;     250 0x70,'0',
;     251 0x71,',',
;     252 0x72,'2',
;     253 0x73,'5',
;     254 0x74,'6',
;     255 0x75,'8',
;     256 0x79,'+',
;     257 0x7a,'3',
;     258 0x7b,'§',
;     259 0x7c,'*',
;     260 0x7d,'9',
;     261 0,0
;     262 };
;     263 #include <lcd.h>
;     264 /* LCD driver routines
;     265 
;     266   CodeVisionAVR C Compiler
;     267   (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.
;     268 
;     269   BEFORE #include -ING THIS FILE YOU
;     270   MUST DECLARE THE I/O ADDRESS OF THE
;     271   DATA REGISTER OF THE PORT AT WHICH
;     272   THE LCD IS CONNECTED!
;     273 
;     274   EXAMPLE FOR PORTB:
;     275 
;     276     #asm
;     277         .equ __lcd_port=0x18
;     278     #endasm
;     279     #include <lcd.h>
;     280 
;     281 */
;     282 
;     283 #ifndef _LCD_INCLUDED_
;     284 #define _LCD_INCLUDED_
;     285 
;     286 #pragma used+
;     287 
;     288 void _lcd_ready(void);
;     289 void _lcd_write_data(unsigned char data);
;     290 // write a byte to the LCD character generator or display RAM
;     291 void lcd_write_byte(unsigned char addr, unsigned char data);
;     292 // read a byte from the LCD character generator or display RAM
;     293 unsigned char lcd_read_byte(unsigned char addr);
;     294 // set the LCD display position  x=0..39 y=0..3
;     295 void lcd_gotoxy(unsigned char x, unsigned char y);
;     296 // clear the LCD
;     297 void lcd_clear(void);
;     298 void lcd_putchar(char c);
;     299 // write the string str located in SRAM to the LCD
;     300 void lcd_puts(char *str);
;     301 // write the string str located in FLASH to the LCD
;     302 void lcd_putsf(char flash *str);
;     303 // initialize the LCD controller
;     304 void lcd_init(unsigned char lcd_columns);
;     305 
;     306 #pragma used-
;     307 #pragma library lcd.lib
;     308 
;     309 #endif
;     310 
;     311 
;     312 // Alphanumeric LCD Module functions
;     313 #asm
   .equ __lcd_port=0x15
;     315 #endasm
;     316 
;     317 // Declare your global variables here
;     318 
;     319 
;     320 // Prototype des fonctions
;     321 //------------------------
;     322 void decode (unsigned char sc);
;     323 
;     324 
;     325 // Sous-programme de capture du caractère envoyé par le clavier
;     326 //-------------------------------------------------------------
;     327 // External Interrupt 0 service routine
;     328 interrupt [EXT_INT0] void ext_int0_isr(void)
;     329 {
_ext_int0_isr:
	RCALL __SAVEISR
;     330 static unsigned char data; // contient le code de la touche reçue

	.DSEG

	.CSEG
;     331 static unsigned char edge = 0; // 0 = front descendant 1 = front montant

	.DSEG

	.CSEG
;     332 static unsigned char bitcount = 11;

	.DSEG

	.CSEG
;     333 
;     334 if (!edge)
	TST  R5
	BRNE _0xD
;     335  {
;     336    if (bitcount < 11 && bitcount > 2)
	LDI  R30,LOW(11)
	CP   R6,R30
	BRSH _0xF
	LDI  R30,LOW(2)
	CP   R30,R6
	BRLO _0x10
_0xF:
	RJMP _0xE
_0x10:
;     337     {
;     338       data = (data >> 1);
	LSR  R4
;     339       if (PINA.0)
	SBIS 0x19,0
	RJMP _0x11
;     340         data = data | 0x80;
	MOV  R30,R4
	ORI  R30,0x80
	MOV  R4,R30
;     341     }                      
_0x11:
;     342     MCUCR = 3; // INT0 actif sur le prochain front descendant
_0xE:
	LDI  R30,LOW(3)
	OUT  0x35,R30
;     343     edge = 1;
	LDI  R30,LOW(1)
	MOV  R5,R30
;     344  }
;     345  else
	RJMP _0x12
_0xD:
;     346   {
;     347     MCUCR = 2; // INT0 actif sur le prochain front montant
	RCALL SUBOPT_0x0
;     348     edge = 0;
	CLR  R5
;     349     if (--bitcount ==0)
	DEC  R6
	BRNE _0x13
;     350      {
;     351        decode(data);
	ST   -Y,R4
	RCALL _decode
;     352        bitcount = 11;
	LDI  R30,LOW(11)
	MOV  R6,R30
;     353      }
;     354   }
_0x13:
_0x12:
;     355 }
	RCALL __LOADISR
	RETI
;     356 
;     357 
;     358 // Programme principal
;     359 //--------------------
;     360 void main(void)
;     361 {
_main:
;     362 // External Interrupt(s) initialization
;     363 // INT0: On
;     364 // INT0 Mode: Falling Edge
;     365 // INT1: Off
;     366 GIMSK=0x40;
	LDI  R30,LOW(64)
	OUT  0x3B,R30
;     367 MCUCR=0x02;
	RCALL SUBOPT_0x0
;     368 GIFR=0x40;
	LDI  R30,LOW(64)
	OUT  0x3A,R30
;     369 
;     370 // LCD module initialization
;     371 lcd_init(16);
	LDI  R30,LOW(16)
	ST   -Y,R30
	RCALL _lcd_init
;     372 
;     373 // Global enable interrupts
;     374 #asm("sei")
	sei
;     375 
;     376 while (1)
_0x15:
;     377       {
;     378       	// Place your code here
;     379       };
	RJMP _0x15
;     380 }
_0x18:
	RJMP _0x18
;     381 
;     382 
;     383 
;     384 // Sous programme de décodage et d'affichage de la touche
;     385 //------------------------------------------------------- 
;     386 void decode (unsigned char sc)
;     387 {
_decode:
;     388  static unsigned char is_up=0, shift = 0;

	.DSEG

	.CSEG
;     389  unsigned char i;
;     390  
;     391  if (!is_up) // dernier caractère reçu = touche relâchée
	ST   -Y,R16
;	sc -> Y+1
;	i -> R16
	TST  R7
	BRNE _0x1A
;     392   {
;     393     switch (sc)
	LDD  R30,Y+1
;     394      {
;     395        case 0xf0 ://touche relâchée
	CPI  R30,LOW(0xF0)
	BRNE _0x1E
;     396         is_up = 1;
	LDI  R30,LOW(1)
	MOV  R7,R30
;     397        break;
	RJMP _0x1D
;     398        
;     399        case 0x12 : // détection shift gauche
_0x1E:
	CPI  R30,LOW(0x12)
	BRNE _0x1F
;     400         shift = 1;
	RCALL SUBOPT_0x1
;     401        break;
	RJMP _0x1D
;     402        
;     403        case 0x59 : // détection shift droite
_0x1F:
	CPI  R30,LOW(0x59)
	BRNE _0x21
;     404         shift = 1;
	RCALL SUBOPT_0x1
;     405        break;
	RJMP _0x1D
;     406  
;     407        default:
_0x21:
;     408           if (!shift) // shift non appuyé
	TST  R8
	BRNE _0x22
;     409            {
;     410             for (i = 0; unshifted[i][0] != sc && unshifted[i][0]; i++);
	LDI  R16,LOW(0)
_0x24:
	RCALL SUBOPT_0x2
	RCALL SUBOPT_0x3
	BREQ _0x26
	RCALL SUBOPT_0x2
	CPI  R30,0
	BRNE _0x27
_0x26:
	RJMP _0x25
_0x27:
	SUBI R16,-1
	RJMP _0x24
_0x25:
;     411               if (unshifted[i][0] == sc) 
	RCALL SUBOPT_0x2
	RCALL SUBOPT_0x3
	BRNE _0x28
;     412                {
;     413                 lcd_putchar(unshifted[i][1]);
	LDI  R26,LOW(_unshifted*2)
	LDI  R27,HIGH(_unshifted*2)
	RCALL SUBOPT_0x4
	ADIW R30,1
	LPM
	MOV  R30,R0
	RCALL SUBOPT_0x5
;     414                 // à compléter
;     415                }
;     416            }
_0x28:
;     417           else // si shift appuyé
	RJMP _0x29
_0x22:
;     418            {
;     419             for (i = 0; shifted[i][0] != sc && shifted[i][0]; i++);
	LDI  R16,LOW(0)
_0x2B:
	RCALL SUBOPT_0x6
	RCALL SUBOPT_0x7
	BREQ _0x2D
	RCALL SUBOPT_0x6
	LPM
	MOV  R30,R0
	CPI  R30,0
	BRNE _0x2E
_0x2D:
	RJMP _0x2C
_0x2E:
	SUBI R16,-1
	RJMP _0x2B
_0x2C:
;     420               if (shifted[i][0] == sc) 
	RCALL SUBOPT_0x6
	RCALL SUBOPT_0x7
	BRNE _0x2F
;     421                {
;     422                 lcd_putchar(shifted[i][1]);
	RCALL SUBOPT_0x6
	ADIW R30,1
	LPM
	MOV  R30,R0
	RCALL SUBOPT_0x5
;     423                 // à compléter
;     424                } 
;     425            }  
_0x2F:
_0x29:
;     426        break;  
;     427      }
_0x1D:
;     428   }  
;     429           
;     430  else
	RJMP _0x30
_0x1A:
;     431   {
;     432     is_up = 0;
	CLR  R7
;     433     switch (sc)
	LDD  R30,Y+1
;     434      {
;     435        case 0x12 : // détection shift gauche
	CPI  R30,LOW(0x12)
	BRNE _0x34
;     436         shift = 0;
	CLR  R8
;     437        break;
	RJMP _0x33
;     438        
;     439        case 0x59 : // détection shift droite
_0x34:
	CPI  R30,LOW(0x59)
	BRNE _0x33
;     440         shift = 0;
	CLR  R8
;     441        break;         
;     442      } 
_0x33:
;     443   }
_0x30:
;     444   
;     445 }
	LDD  R16,Y+0
	ADIW R28,2
	RET

	.DSEG
__base_y:
	.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:
    nop
    nop
    nop
    nop
    nop
    nop
    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)
	SBCI R31,HIGH(-__base_y)
	LD   R30,Z
	LDD  R26,Y+1
	ADD  R30,R26
	RCALL SUBOPT_0x8
	LDD  R9,Y+1
	LDD  R10,Y+0
	ADIW R28,2
	RET
_lcd_clear:
	RCALL __lcd_ready
	LDI  R30,LOW(12)
	RCALL SUBOPT_0x8
	RCALL __lcd_ready
	LDI  R30,LOW(1)
	RCALL SUBOPT_0x8
	CLR  R30
	MOV  R10,R30
	MOV  R9,R30
	RET
_lcd_putchar:
    push r30
    push r31
    ld   r26,y
    set
    cpi  r26,10
    breq __lcd_putchar1
    clt
	INC  R9
	CP   R11,R9
	BRSH _0x3B
	__lcd_putchar1:
	INC  R10
	CLR  R30
	ST   -Y,R30
	ST   -Y,R10
	RCALL _lcd_gotoxy
	brts __lcd_putchar0
_0x3B:
    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
__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  R11,Y+0
	LD   R30,Y
	SUBI R30,-LOW(128)
	__PUTB1MN __base_y,2
	LD   R30,Y
	SUBI R30,-LOW(192)
	__PUTB1MN __base_y,3
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x9
	RCALL SUBOPT_0x9
	RCALL __long_delay
	LDI  R30,LOW(32)
	RCALL SUBOPT_0x8
	RCALL __lcd_ready
	LDI  R30,LOW(40)
	RCALL SUBOPT_0x8
	RCALL __lcd_ready
	LDI  R30,LOW(6)
	RCALL SUBOPT_0x8
	RCALL _lcd_clear
	ADIW R28,1
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x0:
	LDI  R30,LOW(2)
	OUT  0x35,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x1:
	LDI  R30,LOW(1)
	MOV  R8,R30
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x2:
	LDI  R26,LOW(_unshifted*2)
	LDI  R27,HIGH(_unshifted*2)
	MOV  R30,R16
	CLR  R31
	LSL  R30
	ROL  R31
	ADD  R30,R26
	ADC  R31,R27
	LPM
	MOV  R30,R0
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x3:
	MOV  R26,R30
	LDD  R30,Y+1
	CP   R30,R26
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES
SUBOPT_0x4:
	MOV  R30,R16
	CLR  R31
	LSL  R30
	ROL  R31
	ADD  R30,R26
	ADC  R31,R27
	RET

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x5:
	ST   -Y,R30
	RJMP _lcd_putchar

;OPTIMIZER ADDED SUBROUTINE, CALLED 4 TIMES
SUBOPT_0x6:
	LDI  R26,LOW(_shifted*2)
	LDI  R27,HIGH(_shifted*2)
	RJMP SUBOPT_0x4

;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES
SUBOPT_0x7:
	LPM
	MOV  R30,R0
	RJMP SUBOPT_0x3

;OPTIMIZER ADDED SUBROUTINE, CALLED 9 TIMES
SUBOPT_0x8:
	ST   -Y,R30
	RJMP __lcd_write_data

;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES
SUBOPT_0x9:
	RCALL __long_delay
	LDI  R30,LOW(48)
	RJMP SUBOPT_0x8

__SAVEISR:
	ST   -Y,R0
	ST   -Y,R1
	ST   -Y,R22
	ST   -Y,R23
	ST   -Y,R24
	ST   -Y,R25
	ST   -Y,R26
	ST   -Y,R27
	ST   -Y,R30
	ST   -Y,R31
	IN   R0,SREG
	ST   -Y,R0
	RET

__LOADISR:
	LD   R0,Y+
	OUT  SREG,R0
	LD   R31,Y+
	LD   R30,Y+
	LD   R27,Y+
	LD   R26,Y+
	LD   R25,Y+
	LD   R24,Y+
	LD   R23,Y+
	LD   R22,Y+
	LD   R1,Y+
	LD   R0,Y+
	RET

	.ORG 0x00

;INTERRUPT VECTORS
	RJMP __RESET
	RJMP _ext_int0_isr
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
	RJMP 0
