;----------------------------------------------------------------------
;
; Note for Embedded Pascal users:
;
; The following file is an original copy of the include file found
; with Atmels AVR assembler.
; Embedded Pascal contains extentions to enable this file to be
; used as definition file for both Embedded Pascal assembler and
; compiler.
;
; The file is nearly unchanged but contains extentions to allow
; the Pascal compiler to qualify the purpose of every defined item.
;
; Should you want to use Embedded Pascal to develop code for a
; processor not defined in the available include files shipping
; with Embedded Pascal, you may have to define your own or modify
; the include file you may have obtained from Atmel.
;
; The required changes are very minor and are as follows:
;
; a) Before the section containing IO register definitions place
;    the item .IODEF on a single line starting on the leftmost column
;    Embedded Pascal will interpret these definitions as starting
;    at address $20 to $5F. These will be defined as absolute byte
;    variables.
;    The embedded Pascal assembler will use the addresses as presented
;    starting at $0 to $3F for use with IO instructions.
;
; b) Before the section containing Bit definitions place the item
;    .BITDEF on a single line starting on the leftmost column.
;    Embedded Pascal will interpret these definitions as pointers
;    to bit masks for use with standard Pascal OR, XOR and AND operators.
;    For example if a Bit definition is used as:
;    .EQU TheBit =4, Embedded Pascal will define TWO !! contants
;    "_TheBit" as constant with the value 4 and "__TheBit"
;    with the value $10. (i.e. the fourth bit is set).
;    The Embedded Pascal assembler will use the definition as presented.
;
; c) Before the section containing the interrupt vectors place the
;    item .VECTORS on a single line starting on the leftmost column.
;    Embedded Pascal will not currently use these definitions.
;    You can use these definitions with the Embedded Pascal assembler
;    but ensure that you are going to refer to these items by
;    multiplying the values by 2 as the Embedded Pascal assembler
;    is byte orientated.
;
; d) Before the section containing the item RAMEND place the item
;    .CPUDEF.
;    Embedded Pascal does not use items placed in this section.
;    You can use these items from the Embedded Pascal assembler.
; 
;----------------------------------------------------------------------

;***************************************************************************
;* A P P L I C A T I O N   N O T E   F O R   T H E   A V R   F A M I L Y
;* 
;* Number		:AVR000
;* File Name		:"Tny15def.inc"
;* Title		:Register/Bit Definitions for the Tiny15
;* Date	 		:99.10.30
;* Version		:1.20
;* Support telephone	:+47 72 88 87 20 (ATMEL Norway)
;* Support fax		:+47 72 88 87 18 (ATMEL Norway)
;* Support E-Mail	:avr@atmel.com
;* Target MCU		:Tiny22
;* Modified		: A.J. Vogelaar for PasAvr and T22 on 17-12-01
;*
;* DESCRIPTION
;* When including this file in the assembly program file, all I/O register
;* names and I/O register bit names appearing in the data book can be used.
;* 
;* The Register names are represented by their hexadecimal addresses.
;* 
;* The Register Bit names are represented by their bit number (0-7).
;* 
;* Please observe the difference in using the bit names with instructions
;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc" 
;* (skip if bit in register set/cleared). The following example illustrates
;* this:
;* 
;* in	r16,PORTB		;read PORTB latch
;* sbr	r16,(1<<PB6)+(1<<PB5)	;set PB6 and PB5 (use masks, not bit#)
;* out  PORTB,r16		;output to PORTB
;*
;* in	r16,TIFR		;read the Timer Interrupt Flag Register
;* sbrc	r16,TOV0		;test the overflow flag (use bit#)
;* rjmp	TOV0_is_set		;jump if set
;* ...				;otherwise do something else
;***************************************************************************

;***** Specify Device
.device Tiny22

.IODEF ;Embedded Pascal specific extention

;***** I/O Register Definitions
.equ	SREG	=$3f
.equ	SPL	=$3d
.equ	GIMSK	=$3b
.equ    GIFR    =$3a
.equ	TIMSK	=$39
.equ	TIFR	=$38
.equ	MCUCR	=$35
.equ    MCUSR   =$34
.equ	TCCR0	=$33
.equ	TCNT0	=$32
.equ	OSCCAL	=$31
.equ	WDTCR	=$21
.equ	EEAR	=$1E
.equ	EEDR	=$1D
.equ	EECR	=$1C
.equ	PORTB	=$18
.equ	DDRB	=$17
.equ	PINB	=$16


.BITDEF ;Embedded Pascal specific extention

;***** Bit Definitions

; bits in GIMSK
.equ	INT0	=6

; bits in GIFR
.equ	INTF0	=6

; bits in TIMSK
.equ	TOIE0	=1

; bits in TIFR
.equ	TOV0	=1

; bits in MCUCR
.equ	ISC00	=0
.equ	ISC01	=1
.equ	SM	=4
.equ	SE	=5

; bits in MCUSR
.equ	PORF	=0
.equ	EXTRF	=1

; bits in TCCR0
.equ	CS00	=0
.equ	CS01	=1
.equ	CS02	=2

; bits in WDTCR
.equ	WDP0	=0
.equ	WDP1	=1
.equ	WDP2	=2
.equ	WDE	=3
.equ	WDTOE	=4

; bits in EECR
.equ	EERE	=0
.equ	EEWE	=1
.equ	EEMW	=2

; bits in PORTB
.equ	PB0	=0
.equ	PB1	=1
.equ	PB2	=2
.equ	PB3	=3
.equ	PB4	=4

; bits in DDRB
.equ	DDB0	=0
.equ	DDB1	=1
.equ	DDB2	=2
.equ	DDB3	=3
.equ	DDB4	=4

; bits in PINB
.equ	PINB0	=0
.equ	PINB1	=1
.equ	PINB2	=2
.equ	PINB3	=3
.equ	PINB4	=4


.VECTORS ;Embedded Pascal specific extention - Interrupt vector addresses

.equ	INT0addr  =$001	; External Interrupt0
.equ	OVF0addr  =$002	; Overflow 0 Interrupt
.equ	ConstSectionaddr = $3 ;Start of typed constant section unless overridden by "PlaceConst" 

.def	ZL	=r30
