;combi.asm .include "1200def.inc" .def A=r16 .def Abar=r17 .def B=r18 .def Bbar=r19 .def C=r20 .def Dbar=r21 .def temp=r22 .cseg .org 0 rjmp RESET ;reset handle RESET: ldi temp, 0b00001111; out DDRB, temp ;PB0-3 are inputs ;PB4-7 are outputs loop_here: in temp, PINB ;read PORTB pins mov A, temp mov Abar, temp com Abar ;invert A mov B, temp mov Bbar, temp com Bbar ;invert B mov C, temp mov Dbar, temp com Dbar ;invert D andi A, 1 ;isolate the bit for A andi Abar, 1 ;isolate the bit for Abar lsr B ;get input B to position bit0 lsr Bbar lsr C ;get input C to position bit0 lsr C lsr Dbar ;get input D to position bit0 lsr Dbar lsr Dbar andi B, 1 andi Bbar, 1 andi C, 1 andi Dbar, 1 and A, Bbar ;A = A * Bbar and B, Abar ;B = Abar * B and C, Dbar ;C = C * Dbar or A, B ;A = (A * Bbar) + (Abar * B) and A, C ;A = ((A * Bbar) + (Abar * B))* (C * Dbar) and A, 1 cpi A, 1 breq Its1 cbi PORTB, 4 ;no its 0, so reset PB4 rjmp loop_here Its1: sbi PORTB, 4 rjmp loop_here