On 2013-05-31, at 11:18, Marko Mäkelä wrote: Hi Marko! >> if (*byte0 == 0xff && *byte1 & 0xc0 == 0xc0) // 8 bits in first byte, 2 bits in the second > > If you assigned the bytes to local variables and inverted them, you could compare against zero, which is implicit in many ISAs (including the 6502 and x86) and thus save some instructions. Very good hint. I'll take this into account once all this eventually starts working (damn - with all the bit shifting and wrapping around the buffer, the code gets much bigger and complex than I expected it to be. I start to feel like I am doing something the wrong way) > char b0 = *byte0; > char b1 = *byte1; > > if (!b0 && !(b1 & 0xc0)) break; > > If this is at least a 16-bit system, you could also assign the two bytes to an integer, invert it and write code like this (I guess you can keep the loop unrolled): > [...] > I realized an even better way: > > const unsigned mask = (1 << 10) - 1; > > if (!(b & mask)) break; > b >>= 1; > if (!(b & mask)) break; > b >>= 1; > ... Looks elegant indeed. Yet I am not sure how cc65 (one of potential targets) would handle this and am afraid it might perform poorly there. -- SD! Message was sent through the cbm-hackers mailing listReceived on 2013-05-31 13:01:08
Archive generated by hypermail 2.2.0.