Короче написал, что надо было:
Код: Выделить всё
.include "m16def.inc"
.def temp =r17
.def temp2 =r18
.def temp3 =r19
.def a1 =r20
.def a2 =r21
.def a3 =r22
.def a4 =r23
.def a5 =r24
.def a6 =r25
.def a7 =r26
.def a8 =r27
.def Delay =r29
.def Delay2 =r30
.def Delay3 =r31
LDI temp2,0xFF
OUT DDRB,temp2
ldi temp2,0b11111111
ldi a1,0b00000001
ldi a2,0b00000010
ldi a3,0b00000100
ldi a4,0b00001000
ldi a5,0b00010000
ldi a6,0b00100000
ldi a7,0b01000000
ldi a8,0b10000000
out PORTB, temp2
BEGIN:
ldi Delay3,0b00000010
DLY:
dec Delay
brne DLY
dec Delay2
brne DLY
dec Delay3
brne DLY
in temp,PINA
andi temp, 0b00000001
cpi temp, 0b00000001
breq INIT1
EOR temp2,a1
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT1:
in temp,PINA
andi temp, 0b00000010
cpi temp, 0b00000010
breq INIT2
EOR temp2,a2
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT2:
in temp,PINA
andi temp, 0b00000100
cpi temp, 0b00000100
breq INIT3
EOR temp2,a3
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT3:
in temp,PINA
andi temp, 0b00001000
cpi temp, 0b00001000
breq INIT4
EOR temp2,a4
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT4:
in temp,PINA
andi temp, 0b00010000
cpi temp, 0b00010000
breq INIT5
EOR temp2,a5
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT5:
in temp,PINA
andi temp, 0b00100000
cpi temp, 0b00100000
breq INIT6
EOR temp2,a6
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT6:
in temp,PINA
andi temp, 0b01000000
cpi temp, 0b01000000
breq INIT7
EOR temp2,a7
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT7:
in temp,PINA
andi temp, 0b10000000
cpi temp, 0b10000000
breq INIT8
EOR temp2,a8
OUT PORTB,temp2
in temp,PINA
rjmp TRAP
INIT8:
rjmp BEGIN
TRAP:
in temp3,PINA
cp temp,temp3
breq TRAP
rjmp BEGIN
Кому ни лень, или может интересно будет - посмотрите, может код можно компактнее сделать.
Да и на счёт задержки ещё стоит подумать (DLY)... Тут просто время подогнал под удобное удерживание клавиши, но какая длительность не знаю. А вообще антидребезг делается так: сравнивается два значения - после нажатия кнопки и перед тем как отпустить, если они окажутся одинаковыми, то антидребезг удался...