C language > Tips & tricks

Lzw compress/expand demo -- no libs, no dlls, ppj included

(1/3) > >>

Rainbow Sally:
This is a demo of the lzw algorithm for compress and expand.  The resulting exe that does both (for demo purposes) compiles to about 4K.

Compression is decent and fast.  The bulk of the zip file is the text file.

When you run your app after you compile it, enter

   LZW.HTM

Which is the test file name.  

the demo will produce new files named test.lzw (compressed) and test.out (expanded again).

Change the name of test.out to test.htm and it should appear exactly as the intput file did.

Other features:

The PPJ file is included (with relative paths so it should work in any folder on any drive).  

It is set up to produce a (almost) minimum size application.  

The source code is modified to replace getc with fgetc to avoid crash in msvcrt.  (There are other file functions in that dll that are flaky too.)

Vortex:
Hi Rainbow Sally,

Here is your executable reduced to 3072 bytes without merging sections, ppj included.

Rainbow Sally:

--- Quote from: "Vortex" ---Hi Rainbow Sally,

Here is your executable reduced to 3072 bytes without merging sections, ppj included.
--- End quote ---


Thank you Vortex.  

Cool stuff.

Rainbow Sally:
Hey!  ???

What did you compile the crt0cons.asm with?

I tried


--- Code: ---
    pocc crt0cons.asm  

--- End code ---


from the command line but pocc doesn't like it.

External assembler?

Also, I'm not sure what version of the ide you have but I got an error message about a tags file not being recognized, then poide crashed.  I removed the lzs.tags and stuff and it works fine (since the obj file already existed) but I may be missing an important step as a result.

To other users.  This is really great stuff.  We see how to change the entry address to do another function (or init) before jumping to main and how to use an obj file (possibly created by other applications?) in our own C projects.

To Vortex.  This is the kind of thing I may need to do to get more C++ obj files working in Pelles C.  Thanks for these demos.  I'm learning a lot and it's easy and it's fun.

.

Vortex:
Hi Rainbow Sally,

Happy new year :)

Yes, just as you said, I used an external assembler, MS Macro Assembler - MASM.  To get this tool, have a look at Hutch's homepage - the Masm32 project:

http://movsd.com/

crt0cons.asm is tiny C startup code reducing the size of the final executable. crt0gui.asm is the GUI version.

Assembling the source file ( ml.exe is the 32-bit assembler.) :

--- Code: ---
ml /c /coff crt0cons.asm

--- End code ---


/c     : assemble only ( no linking )
/coff : choose MS COFF object file format

Version of my IDE = 2.90.8

I don't have any idea why these tag files make crash the IDE. Maybe, Pelle can offer a solution.

About using C startup codes, you can have a look at my little project:

http://smorgasbordet.com/phpBB2/viewtopic.php?t=88

Navigation

[0] Message Index

[#] Next page

Go to full version