Self-modifying code

Bjorn Lisper lisper-bjorn at CS.YALE.EDU
Wed Jul 13 07:17:52 AEST 1988


In article <4776 at killer.UUCP> chasm at killer.UUCP (Charles Marslett) writes:
>In article <33441 at yale-celray.yale.UUCP>, I write:
>> Another related issue is that self-modifying code cannot be executed
>> directly from ROM. Executing programs in ROM is an important memory-saving
>> technique in small, diskless, special-purpose systems.
>
>Actually, I always thought that ROM was much more important as a way of
>eliminating the need to load the code and as a way of guaranteeing non-
>self-modifying-ness.  Usually ROM code is larger (thus memory-consuming)
>than RAM-loaded code.  This is because most RAM based systems assume some
>form of selfmodification of code, ranging from relocation tables that avoid
>the need for self-relative addressing everywhere to file initialization code
>that gets overwritten by its own buffer....

As I wrote was actually thinking primarily of diskless systems. In such a
system the program is stored in ROM. If the program is self-modifying, its
code has to be loaded into RAM before it can execute. If not it can be
executed directly in ROM and only the data areas need to be RAM. Thus memory
is saved (we don't need the extra RAM to hold the code).

Bjorn Lisper



More information about the Comp.lang.c mailing list