+; main file of the monolyzer project
+;
+; author: hackbard@hackdaworld.org
+;
+
+; device specific definition file
+.include "../include/tn2313def.inc"
+
+; defines
+.def zero = r1
+.def one = r2
+.def tmp1 = r16
+.def tmp2 = r17
+.def uart_rxtx = r18
+.def count = r19
+
+;
+; interrupts
+;
+
+; RESET
+rjmp INIT
+
+; INT0
+reti
+
+; INT1
+reti
+
+; T1 CAPT1
+reti
+
+; T1 COMP A
+reti
+
+; T1 OVF1
+reti
+
+; T0 OVF0
+rjmp T0_OVF
+
+; UART RX
+rjmp UART_RECEIVE
+
+; UART UDRE
+reti
+
+; UART TX
+reti
+
+; ANA COMP
+reti
+
+; PCINT
+reti
+
+; T1 COMP B
+reti
+
+; T0 COMP A
+reti
+
+; T0 COMP B
+reti
+
+; USI START
+reti
+
+; USI OVF
+reti
+
+; EE READY
+reti
+
+; WDT OVF
+reti
+
+;
+; init and main code
+;
+
+RESET:
+INIT:
+
+ ; gio port init
+ rcall PORT_INIT
+
+ ; timer0 init
+ rcall TIMER0_INIT
+
+ ; timer0 interrupt enable
+ rcall TIMER0_INT_INIT
+
+ ; uart init
+ rcall UART_INIT
+
+ ; uart interrupt enable
+ rcall UART_INT_RX_INIT
+
+ ; zero and one initialization
+ ldi tmp1,0
+ mov zero,tmp1
+ ldi tmp1,1
+ mov one,tmp1
+
+ ; set stackpointer
+ ldi tmp1,low(RAMEND)
+ out SPL,tmp1
+
+ ; more init
+ ldi count,0x21
+
+ ; signal ready output
+ ldi uart_rxtx,0x68
+ rcall UART_TX
+
+ ; global interrupt enable
+ sei
+
+MAIN:
+
+WAIT_FOR_HIGH:
+ ; start as soon as we get a high signal
+
+ rjmp WAIT_FOR_HIGH
+
+
+; include subroutines
+.include "port.asm"
+.include "timer.asm"
+.include "uart.asm"
+
+
+;
+; interrupt routines
+;
+
+T0_OVF:
+
+ ; debug output
+ cbi PORTD,3
+
+ ; read port
+
+ ; store another byte into sram
+
+
+ ; debug output
+ sbi PORTD,3
+
+ reti
+
+UART_RECEIVE:
+ reti
+
+
+;
+; sram
+;
+
+.dseg
+
+DATA_STORAGE: .byte 8
+
+