--- /dev/null
+;
+; control the light connected to the pwm output pins
+;
+; author: hackbard@hackdaworld.org
+;
+
+; specify device
+.include "../include/2313def.inc"
+
+; ------------------
+; interrupt vectors:
+; ------------------
+
+; reset
+rjmp RESET
+; int0
+reti
+; int1
+reti
+; timer 1 capture
+reti
+; timer 1 compare
+reti
+; timer 1 overflow
+reti
+; timer 0 overflow
+reti
+; usart rx complete
+rjmp UART_RX
+; usart data register empty
+reti
+; usart tx complete
+reti
+; analog comperator
+reti
+; pin change interrupt
+reti
+; timer/counter 1 compare match b
+reti
+; timer/counter 0 compare match a
+reti
+; timer/counter 0 compare match b
+reti
+; usi start condition
+reti
+; usi overflow
+reti
+; eeprom ready
+reti
+; watchdog timer overflow
+reti
+
+; -----
+; code:
+; -----
+
+RESET:
+ ; set stackpointer
+ ldi r16,low(RAMEND) ; write top of ramend (lowbyte)
+ out SPL,r16 ; to stackpointer
+
+ ; rs232 init
+ ldi r16,12 ; "38.4k bps @ 8 mhz" in r16
+ out UBRR,r16 ; write to uart baudrate register
+ ldi r16,(1<<RXEN)|(1<<TXEN)|(1<<RXCIE) ; enable rx/tx + rx interrupt
+ out UCSRB,r16 ; write to uart control register
+
+ ; pwm (OC0A=PB2 OC0B=PD5)
+ ; set as output
+ ldi r16,(1<<DDB2)
+ out DDRB,r16
+ ldi r16,(1<<DDD5)
+ out DDRD,r16
+ ; output 0
+ ldi r16,(1<<PINB2)
+ subi r16,0xff
+ out PORTB,r16
+ ldi r16,(1<<PIND5)|(1<<PIND6)
+ subi r16,0xff
+ out PORTD,r16
+ ; toggle OC0A/B on compare match / fast pwm
+ ldi r16,(1<<COM0A0)|(1<<COM0B0)|(1<<WGM00)|(1<<WGM01)
+ out TCCR0A,r16
+ ; top in OCR0A / no clock prescaling
+ ldi r16,(1<<WGM02)|(1<<CS00)
+ ; overflow interrupt enable
+
+ ; initial pwm value 0x7f
+ ldi r16,0x7f
+ out OCR0A,r16
+ out OCR0B,r16
+
+ ; global interrupt enable
+ sei
+
+MAIN:
+ rjmp MAIN
+
+UART_RX:
+ reti