;Wait for the character '?' from the UART then returns the value of PORTB
;to the serial line.

.include	"8535def.inc"
.include	"map.asm"
.cseg
.org	0
reset:
	rjmp	init
.org	9
	rjmp	isr_t0_ov

init:
.include	"init.asm"
	sei
	ldi	tmp1,time_s_timer0
	sts	s_timer0,tmp1	
	ldi	tmp1,time_s_timer1
	sts	s_timer1,tmp1
main_loop:
	rcall	get_uart
	brcc	main0
	cpi	tmp1,'?'
	brne	main0
	in	tmp1,pinb
	rcall	send
main0:
	lds	tmp1,s_timer0
	tst	tmp1
	brne 	main1
	ldi	tmp1,time_s_timer0
	sts	s_timer0,tmp1
	rcall	toggle1
main1:
	lds	tmp1,s_timer1
	tst	tmp1
	brne	main_loop
	ldi	tmp1,time_s_timer1
	sts	s_timer1,tmp1
	rcall	toggle2
	rjmp	main_loop
.include	"timer.asm"
.include	"io.asm"
.include	"uart.asm"
.include	"lib.asm"