;***************************************************************************
;* File Name		:key0.asm
;* Title		:Query a Key
;* Date	 		:28/03/97
;* Version 		:1.0
;* Target MCU		:AT90S1200
;* 
;* DESCRIPTION
;* Query of keys in a loop
;***************************************************************************

;***** Directives

.device at90s1200		; Device is AT90S1200
.nolist
.include "1200def.inc"
.list

.def	temp 	= r16
.def	dly	= r17
.def	delcnt	= r18		; Loop Counter

;***** Interrupt vector table

	rjmp	RESET		; Reset handle
	reti			; External Interrupt0 handle
	reti			; Overflow0 Interrupt handle
	reti			; Analog Comparator Interrupt handle

;***** Subroutines

DELAY:	clr	delcnt		; Init Loop Counter
loop1:	dec	delcnt
	nop
	brne	loop1
	dec	dly
	brne	loop
	ret
	
;***** Main

RESET:	ser	temp
	out	DDRB,temp	; PORTB = all outputs
	out	PORTB, temp	; Set all outputs Hi
	ldi	dly, $80	; Initialize delay

loop:	in 	temp, PIND
	out	PORTB, temp
	rcall	DELAY		; Number of cycles = 1026 * del + 4
	nop
	rjmp 	loop		; Repeat forever
	




