;***************************************************************************
;* File Name		:key1.asm
;* Title		:Query a Key
;* Date	 		:28/03/97
;* Version 		:1.0
;* Target MCU		:AT90S1200
;* 
;* DESCRIPTION
;* Interrupt controlled query of keys
;***************************************************************************

;***** Directives

.device at90s1200		; Device is AT90S1200
.nolist
.include "1200def.inc"
.list
.listmac

.def	temp 	= r16
.def	byte 	= r17


;***** Macros

.MACRO	SBIs_HR			; Set Bits in I/O Register 32 up
	in 	temp,@0
	ori 	temp, @1
	out 	@0, temp
.ENDMACRO

;***** Interrupt vector table

	rjmp	RESET		; Reset handle
	rjmp	EX_INT0		; External Interrupt0 handle
	reti			; Overflow0 Interrupt handle
	reti			; Analog Comparator Interrupt handle

;***** Interrupt handlers

EX_INT0:in	temp, PIND	; Read Pins of PortD
	out	PORTB, temp	; Write Pattern to PortB
	reti

;***** Main

RESET:	ser	temp
	out	DDRB,temp	; PORTB = all outputs
	out	PORTB, temp	; Set all outputs Hi

	SBIs_HR	MCUCR,0b00000010; Interrupt on falling edge of INT0 

	SBIs_HR	GIMSK,0b01000000; External Interrupt0 Enable

	sei			; Global Interrupt Enable
	
loop:	
	rjmp 	loop		; Repeat forever
	

