It's not entirely folklore. We used to do this sort of thing
all the time in the AppleII and 64KB PC days. Heck I used
to have a switch construct in PC assembler that pushed the
the segment and instruction pointer to stack, added a few bytes,
then pushed a destination onto the stack and did an IRET.
The routines it jumped to did an IRET to come back. I saved
like 24 bytes by doing it "wrong" and basically broke any
disassembler out there. Also, it was faster... =)
Evil self-modifying code was the only way you could
get anything to work in non-glacial speed on the Apple.
My friend Rick wrote an 8 direction generalized 8x8 pixel
block move that self modified itself in a tight loop.
It could smoothly move about 50 cells of 8x8 tiles faster
than the screen refresh and was about 130ish bytes. The
original way had taken over a 1k and he wanted more room
for tiles. And yes, we explored modifying the code a bit
to use it as graphic tiles first. =)
Writing in a memory budget was terrific for helping you
think outside the box...
--
$you = new YOU;
honk() if $you->love(perl) | [reply] |
I know that they saved a lot of memory by using what some would consider some very odd tricks, in the programming of the Personal Rapid Transit, which is the transportation system at my university (West Virginia University). You would be surprised how much info they squeezed into some VERY tight space.
Just Another Perl Backpacker | [reply] |