CLC
// R19, R18, R17, R16
ldi R20, 7
loop:
ASR R19
ROR R18
ROR R17
ROR R16
dec R20
cpi R20, 0
BRNE loop
0x8A
>1000 1010
>0100 0101
>0010 0010
0x22
// R16< The sequence we are searching in
// R17< 0000 1010
// R18< 0000 1111
// R19< tmporary spot for R16
LDI R17, 0b00001010
LDI R18, 0b00001111
// do it 8 times
LDI R20, 8
LOOP:
MOV R19, R16 // Copy R16 to R19
AND R19, R18 // Remove the front nibble
CP R19, R17 // Compare to 1010
// Did we find 1010?
BREQ FOUND
ROR R16 // shift it right to check the next 4 bits
DEC R20
cpi R20, 0
BREQ NOTFOUND // Did we not find it?
JMP LOOP
FOUND: // WE FOUND IT
// does something
jmp FINISH
NOTFOUND: // WE DIDN'T FIND IT
// does something else
FINISH:
ret
Therefore: