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)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.