Но ты-же коммунист, =mse=!!!... И АВР затарахтел 32-битными счётчиками ;О)...
;18*8+14*8+12=268 cy(13,4uS) 32bit wide
;3,26uS (65 cycles) free
.def temporary_l =r0
.def temporary_h =r1
.def current_port_l =r26
.def current_port_h =r27
.def old_port_l =r28
.def old_port_h =r29
.def minus_1_container =r30
.def _3_byte_counter =r31
.def _4_byte_ch_0_counter =r16
.def _4_byte_ch_1_counter =r17
.def _4_byte_ch_2_counter =r2
.def _4_byte_ch_3_counter =r3
.def _4_byte_ch_4_counter =r4
.def _4_byte_ch_5_counter =r5
.def _4_byte_ch_6_counter =r6
.def _4_byte_ch_7_counter =r7
.def _4_byte_ch_8_counter =r8
.def _4_byte_ch_9_counter =r9
.def _4_byte_ch_10_counter =r10
.def _4_byte_ch_11_counter =r11
.def _4_byte_ch_12_counter =r12
.def _4_byte_ch_13_counter =r13
.def _4_byte_ch_14_counter =r14
.def _4_byte_ch_15_counter =r15
.def _3_byte_ch_8_counter =r18
.def _3_byte_ch_9_counter =r19
.def _3_byte_ch_10_counter =r20
.def _3_byte_ch_11_counter =r21
.def _3_byte_ch_12_counter =r22
.def _3_byte_ch_13_counter =r23
.def _3_byte_ch_14_counter =r24
.def _3_byte_ch_15_counter =r25
.dseg
channel_0_counter: .byte 3
channel_1_counter: .byte 3
channel_2_counter: .byte 3
channel_3_counter: .byte 3
channel_4_counter: .byte 3
channel_5_counter: .byte 3
channel_6_counter: .byte 3
channel_7_counter: .byte 3
channel_8_counter: .byte 2
channel_9_counter: .byte 2
channel_10_counter: .byte 2
channel_11_counter: .byte 2
channel_12_counter: .byte 2
channel_13_counter: .byte 2
channel_14_counter: .byte 2
channel_15_counter: .byte 2
.cseg
rjmp startup
startup:
;....
main_cy:
ldi minus_1_container,low(-1) ;1
in current_port_l,pinc ;1
in current_port_h,pinb ;1
movw temporary_l,current_port_l ;1
eor temporary_l,old_port_l ;1
eor temporary_h,old_port_h ;1
movw old_port_l,current_port_l ;1
and temporary_l,current_port_l ;1
and temporary_h,current_port_h ;1
sbrs temporary_l,0 ;2
rjmp other_L_channel_analyse
lds current_port_l,channel_0_counter ;2
lds current_port_h,channel_0_counter+1 ;2
lds _3_byte_counter,channel_0_counter+2 ;2
sub current_port_l,minus_1_container ;1
sbc current_port_h,minus_1_container ;1
sbc _3_byte_counter,minus_1_container ;1
sbc _4_byte_ch_0_counter,minus_1_container ;1
sts channel_0_counter,current_port_l ;2
sts channel_0_counter+1,current_port_h ;2
sts channel_0_counter+2,_3_byte_counter ;2
;*8
other_L_channel_analyse:
;...
sbrs temporary_h,0 ;2
rjmp other_H_channel_analyse
lds current_port_l,channel_8_counter ;2
lds current_port_h,channel_8_counter+1 ;2
sub current_port_l,minus_1_container ;1
sbc current_port_h,minus_1_container ;1
sbc _3_byte_ch_8_counter,minus_1_container ;1
sbc _4_byte_ch_8_counter,minus_1_container ;1
sts channel_8_counter,current_port_l ;2
sts channel_8_counter+1,current_port_h ;2
other_H_channel_analyse: ;*8
;...
;sbis hardware_interrupts_flags,terminate_flag ;1
rjmp main_cy ;2
;service of counters may be use registers
;
;temporary_l
;temoprary_h
;current_port_l
;current_port_h
;minus_1_container
;_3_byte_counter
;
;