CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Location
    bangalore india
    Posts
    183

    memory compression

    hi all,
    i am downloading a program to a hardware device having limited memory.
    is it possible to compress different parts of the program in the device and decompress it when it is to be used?
    which algorithm shall i use?
    thanx in advance
    ratheeshravi
    Known Is A Drop..
    Unknown Is An Ocean....

    Programming Contest...

  2. #2
    Join Date
    Sep 2002
    Posts
    1,747
    To do this, you need to be able to separate your code into chunks that have as little coupling as possible between them. You must then be able to have an encryption/decryption engine that operates on the chunks fit in the memory and develop the rules for encryption/decryption of chunks prior to calls from one chunk to another. This is difficult in standard c++ because the language does not have a notion of the size of functions, but is possible if the c++ works directly on the machine language memory area of the code using unsafe casts and builds function pointers. However, this is only a reasonable approach if the size of the encryption/decryption engine + a decompression buffer do not make the excutable larger than the compressed version.

    The proper compression algorithm depends on the instruction set of the processor you are targetting. If it is a small, fixed (N) bit instruction set, then an N-bit huffman compression could be proper (or at least compression on the operand bit size if the data bit size is a multiple).

    Also note that such techniques decrease the performance of the program, which is often not acceptable for embedded devices.
    */*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

    "It's hard to believe in something you don't understand." -- the sidhi X-files episode

    galathaea: prankster, fablist, magician, liar

  3. #3
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    If you are using WinCE or something similar, you can write most of your code in a .dll and decompress it before you dynamically load it. It is fairly simple to do.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured