Re: [PATCH -ac] Panicking in morse code

From: Daniel Phillips (phillips@arcor.de)
Date: Thu Jul 25 2002 - 22:43:09 EST


On Thursday 25 July 2002 14:51, Bill Davidsen wrote:
> On Fri, 19 Jul 2002, Alan Cox wrote:
>
> > > +static const char * morse[] = {
> > > + ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", /* A-H */
> > > + "..", ".---.", "-.-", ".-..", "--", "-.", "---", ".--.", /* I-P */
> > > + "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", /* Q-X */
> > > + "-.--", "--..", /* Y-Z */
> > > + "-----", ".----", "..---", "...--", "....-", /* 0-4 */
> > > + ".....", "-....", "--...", "---..", "----." /* 5-9 */
> >
> > How about using bitmasks here. Say top five bits being the length, lower
> > 5 bits being 1 for dash 0 for dit ?
>
> ??? If the length is 1..5 I suspect you could use the top two bits and fit
> the whole thing in a byte. But since bytes work well, use the top three
> bits for length without the one bit offset. Still a big win over strings,
> although a LOT harder to get right by eye.

Please read back through the thread and see how 255 different 7 bit codes
complete with lengths can be packed into 8 bits.

-- 
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 30 2002 - 14:00:22 EST