--- /dev/null
+;
+; rgb moritz
+;
+
+; hopefully more improved version of rgb for mali
+
+; author: hackbard@hackdaworld.org
+
+
+.include "../include/2313def.inc"
+
+; defines & equals
+.def zero = r0
+.def one = r1
+.def tmp = r16
+.def count = r17
+.def red = r18
+.def green = r19
+.def blue = r20
+.def rgb_level = r21
+.equ pin_red = 0x01
+.equ pin_green = 0x02
+.equ pin_blue = 0x04
+
+; interrupt vectors
+; reset
+rjmp INIT
+; int0
+reti
+; int1
+reti
+; timer/counter capt 1
+reti
+; timer/counter compare
+reti
+; timer/counter overflow 1
+rjmp TCO1
+; timer/counter overflow 0
+reti
+; uart rx complete
+reti
+; uart data register empty
+reti
+; uart tx complete
+reti
+; analog comparator
+reti
+
+;
+; init routine
+;
+
+INIT:
+
+; stack pointer
+ldi tmp,low(RAMEND)
+out SPL,tmp
+
+; timer: clock/8
+ldi tmp,(1<<CS11)
+out TCCR1B,tmp
+
+; enable timer overflow interrupt
+ldi tmp,(1<<TOIE1)
+out TIMSK,tmp
+
+; register values
+ldi tmp,1
+mov one,tmp
+ldi tmp,0
+mov zero,tmp
+
+; port b 0-2 -> output
+; port b 0-2 -> high
+ldi tmp,0x07
+out DDRB,tmp
+out PORTB,tmp
+
+;
+; more init
+;
+
+; rgb offsets
+mov red,zero
+ldi tmp,85
+mov green,tmp
+ldi tmp,170
+mov blue,tmp
+
+; level init
+ldi rgb_level,0x07
+
+; init count variable
+mov count,zero
+
+;
+; main routine
+;
+
+MAIN:
+
+rjmp MAIN
+
+TCO1:
+
+cp count,zero
+brne CHECK_RED
+mov rgb_level,zero
+
+CHECK_RED:
+
+cp count,red
+brne CHECK_GREEN
+ori rgb_level,pin_red
+
+CHECK_GREEN:
+
+cp count,green
+brne CHECK_BLUE
+ori rgb_level,pin_green
+
+CHECK_BLUE:
+
+cp count,blue
+brne SET_PORTS
+ori rgb_level,pin_blue
+
+SET_PORTS:
+
+out PORTB,rgb_level
+
+reti
+