Re: LZ: New idea for compression program!


[Prev][Next][Index][Thread]

Re: LZ: New idea for compression program!



On Thu, 12 Sep 1996, Scott J. Rein wrote:


> At 08:03 PM 9/11/96 -0500, you wrote:
> >On Wed, 11 Sep 1996, Tony Lieuallen wrote:
> >
> >> A workaround for PROGRAM_ADDR changing:
> >> 
> >> decompress the program, call it from within the self-extracting one, and when
> >> the extracted one ends, then delete it, then return to zshell.
> >
> >Isn't PROGRAM_ADDR the address in zshell that contains the
> >offset of the executing program?  All the decompressed programs
> >internal calls and direct jumps will need that address if thats
> >what it is, and it'll need it's own address, not the address
> >of the decompressor, which is what PROGRAM_ADDR will contain.
> >
> >Unless I misunderstand about PROGRAM_ADDR, which is entirely
> >possible.
> >
> 
> Yes, everything will need that address, but when you CALL a program, won't
> zshell handle the program_addr for you?  That is how I thought it worked.
 
If you use your plan and have code in the compressed file to call the
decompressor, zshell runs the compressed file, putting it's base
address in PROGRAM_ADDR.  Then the compressed file calls the
decompressor, which expects to find it's base address in PROGRAM_ADDR.
But it has a different address than the string zshell ran, so
PROGRAM_ADDR has to be changed to reflect this.  Then when the
decompressor calls the uncompressed program, which is at another
address, PROGRAM_ADDR has to have this new address because thats
what the program expects.


The reason for this is that all the programs are org'ed at 0 so
that all the direct addresses in the code will be relative to
the offset of the program that's running.  PROGRAM_ADDR is
added to this to get the true address of the direct addresses.
The formula for any address in the program is it's offset from
the beginning of the program + the address of the beginning of
the program.  In your scenario, there are actually 3 different
programs that will be run in 3 different addresses.  There's the
compressed program, the compressor and the decompressed program.
Each will assume that PROGRAM_ADDR contains it's base address.


If you use a shell within zshell it'll still be the same.  Your
shell will need to have it's base address in PROGRAM_ADDR and
zshell will take care of that, but then you'll have to update
PROGRAM_ADDR for the decompressed program.  And maybe for the
decompressor too, but that just depends on how you write it.


Updating PROGRAM_ADDR is probably trivial assuming that it's
safe to do it at all, so it isn't really important how many
times you do it, it's no big deal.  But finding out for sure
that it's safe is really important.  Does zshell grab any
interrupts and get control and use that while your program
is running?  If it does, then you probably can't do it.  When
a program called by zshell terminates and zshell gets control
again, does it do a checksum to make sure the other program
hasn't clobbered part of it?  If so, then you might have to
resture PROGRAM_ADDR before you exit.  In fact, it's probably
smart to do that in any case so you'll be covered if zshell
ever starts doing that in a future revision.


Just about 80% of writing a program like this is figuring out
all this stuff in advance.  The other 20% is coding.  It's
the easy part and it shouldn't start till the figuring out
is done.


Barry


References: