PicBasic text compress routine


Results 1 to 12 of 12

Threaded View

  1. #7
    tdavis80's Avatar
    tdavis80 Guest


    Did you find this post helpful? Yes | No

    Talking

    As I read your example another idea comes to mind.

    Are the strings predictable? Are the non-numerics always in the same place?
    If yes, ignore them and only store the numbers.

    for the numbers, use packed decimal format. It is VERY easy to encode/decode with picbasic. Packed decimal stores 2 numbers per byte by using a nibble per digit.

    Example:

    14332569 = 8 bytes
    Store the hex as: 14 33 25 69 = 4 bytes

    You can encode/decode by simply shifting the data on the byte.

    If you 40 chars were 36 numbers plus 4 alphas, the result would be 18 bytes which you could decode and reinsert the alphas in the appropriate places.

    If the alphas could appear anywhere but are always 1 of a small set of possibilities your still in luck. The packed decimal uses 0-9 but still leaves you a-f for your own use (6 special characters).

    another example:

    Lets assume ";" = A "=" = B

    Then 12254324;3654=6554 (18 bytes) would encode as:

    hex= 12 25 43 24 A3 65 4B 65 54 (9 bytes)

    are we getting closer?

    ps: I just read your comment about your entire character set. This is good news because it means you could definately use the packed decimal format for 2:1 encoding with low code overhead.
    Last edited by tdavis80; - 26th November 2005 at 05:04.

Similar Threads

  1. Picbasic VS C Compiler
    By koossa in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th October 2005, 21:44
  2. Replies: 22
    Last Post: - 12th July 2005, 17:39
  3. Can an asm interrupt contain gosub to a picbasic routine?
    By sougata in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st April 2005, 19:49
  4. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 10:04
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts