Shop OBEX P1 Docs P2 Docs Learn Events
String to bytes — Parallax Forums

String to bytes

giannissamgiannissam Posts: 22
edited 2009-04-07 02:09 in Propeller 1
Hello, i've been trying to convert a string to bytes in this way
say the string is "jj"
in binary its
01101010 01101010

i want to make

00000000 00000000
10000000 10000000
10000000 10000000
00000000 00000000
10000000 10000000
00000000 00000000
10000000 10000000
00000000 00000000

i made a code (attached) but somehow when it gets to the second j the bin is diferent. (By the way in my code i havent masked the bin numbers so i can see the process)

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-05 21:25
    Hello Giannissam,

    from a quick look at your code I guess the memoryarea of

      EncBit byte  '" ",0
    
    



    is too small as it contains only ONE byte

    how about

      EncBit byte  0,0,0,0,0,0,0,0
             byte  0,0,0,0,0,0,0,0
             byte  0,0,0,0,0,0,0,0
             byte  0,0,0,0,0,0,0,0
    
    



    to have a memory area of 32 bytes ?

    Your encoding is compressed as much as possible
    how about decompressing it for testpurposes

    I mean one line of code for
    checking if bit is 0 or 1
    another line for setting msb
    another line for increment the pointer
    another line for shifting the bits ONE bit left etc.
    and if this works properly starting to compress it

    best regards

    Stefan
  • giannissamgiannissam Posts: 22
    edited 2009-04-07 02:09
    actually i wanted to make lsb not msb. but anyway u helped a lot. thanx
Sign In or Register to comment.