	processor	6502
	
	org	$fe00
init	cli
	lda	#$00
	sta	$06
	lda	#$4
	sta	$07
loop	jsr	getin
	cmp	#$00
	beq	loop
	jsr	chrout
	jmp	loop

irqhandler	jsr	scnkey
	jsr	udtim
	rti

scnkey	lda	$dc01
	bne	next
	rts
next	ldx	$c6
	cpx	#$0a
	beq	quit2
	sta	$0277,x
	inc	$c6
quit2	rts


chrout	ldy	#$00
	sta	($06),y
	inc	$06
	bne	quit1
	inc	$07
	lda	$07
	cmp	#$08
	bne	quit1
	lda	#$04
	sta	$07
quit1	rts
	
getin	ldx	$c6
	beq	nochar
	dex
	stx	$c6
	lda	$0277,x
	rts
nochar	lda	#$00
	rts

udtim	inc	$a2
	bne	quit3
	inc	$a1
	bne	quit3
	inc	$a0
quit3	rts


	org	$ff9f
	jmp	scnkey
	org	$ffd2
	jmp	chrout
	org	$ffe4
	jmp	getin
	org	$ffea
	jmp	udtim
	
	org	$fffc
	dc.w	init
	dc.w	irqhandler


