.device attiny13a init: clr r18 ldi r16, 0b00001010 out ddrb, r16 select: sbis pinb, 0 rjmp s1 sbis pinb, 2 rjmp s2 rjmp select s1: inc r18 sbi portb, 1 rcall delay cbi portb,1 rcall delay rjmp select s2: sbi portb, 3 rcall delay cbi portb, 3 andi r18, 0b00000111 rjmp function function: cpi r18, 0 breq and cpi r18, 1 breq and cpi r18, 2 breq or cpi r18, 3 breq not cpi r18, 4 breq nand cpi r18, 5 breq nor cpi r18, 6 breq xor cpi r18, 7 breq xnor clr r18 rjmp init and: rcall input and r16, r17 rcall output rjmp and or: rcall input or r16, r17 rcall output rjmp or not: rcall input com r16 rcall output rjmp not nand: rcall input and r16, r17 com r16 andi r16, 0b00000010 rcall output rjmp nand nor: rcall input or r16, r17 com r16 andi r16, 0b00000010 rcall output rjmp nor xor: rcall input eor r16, r17 rcall output rjmp xor xnor: rcall input eor r16, r17 com r16 andi r16, 0b00000010 rcall output rjmp xnor input: in r16, pinb com r16 mov r17, r16 andi r16, 0b00000001 lsl r16 andi r17, 0b00000100 lsr r17 ret output: andi r16, 0b00000010 out portb, r16 ret delay: ldi r16, 150 delay1: ldi r17, 250 delay2: dec r17 brne delay2 dec r16 brne delay1 ret