You don't say what CPU you're using, and whether it is 8, 16, 32 or 64 bits or whatever. rerouter gives some good ideas.
Probably it doesn't matter how you do it, CPUs are so fast.
If you're going to use a series of tests, as rerouter suggests, then if possible put the ones most likely to fail first. Tests and branches on microcontrollers are often slow, especially taken ones.
for (int count=1; count<=80; ++count){
byte b = readbyte();
//...
if (b != 255) continue;
if (count < 70) continue;
if (count > 73 && count < 77) continue;
++correct;
}
if (correct != 7) error();
But probably it's faster to do it without branches:
short mask = 0;
for (int count=1; count<=80; ++count){
byte b = readbyte();
mask <<= 1;
if (b == 255) mask |= 1;
}
short check = 0b1111000111; // GNU extension, otherwise 0x3C7
if ((mask & check) != check) error();
If your CPU has predication (e.g. ARM/Thumb2), conditional select ARM64, conditional move (X86), or conditional set (x86, MIPS, ARM64, RISC-V) then updating mask inside the loop doesn't need any branches and should be really fast.
But the whole idea seems kinda dumb to me. Why not do a simple checksum over the entire packet? That won't need any branches inside the loop either.