Topic: Selfmodifying Code
Author: Yannick de Kercadio <kercadio@limsi.fr>
Date: 1999/04/19 Raw View
superdude wrote:
>
> It's unclear what you're asking about. Compiler produces object code not
> source code so what is selfmodifying code?
> G.B.
>
> Johann Fischer <SilverBanana@t-online.de> wrote in message
> news:37136FCA.74344557@t-online.com...
> > Hi!
> >
> > Is there somewhere a C++ compiler that supports selfmodifying code or is
> > there a c++ extension for such a feature?
Self-modifying code usually means that the execution of the code will
modify the *executable* code itself. It *was* usefull a long time ago,
when computers were shipped with 8 Kb of memory. Many processors had a
"branch" instruction, but also a "branch never" instruction. And they
differed only by one bit. This let you put a boolean flag *in the code*,
and the modification of the flag results in the desired modification in
the code's behaviour, without any test instruction.
Another common way to use it is to compile at run time some routine with
its data (typically a routine moving some picture on the screen). It
*used* to be faster on some processors, because immediate load
instructions were faster than those requiring a dereference.
Doing the same in C++ would require some representation of the
executable code in C++, and some way to modify it. You would loose the
benefits of having a machine independant program. Or you would have to
define precisely a virtual machine on which C++ code executes (just like
in LISP, Prolog, or Java).
I think that:
1) comp.std.c++ is not the right group to discuss this matter
2) C++ does not and should not handle such programming tricks. See LISP,
for instance, or some other language that is bound to some well-defined
machine.
3) the recent pipe-line architectures encourage the programmer to
separate the code from the data. Therefore, there si no longer need for
self-modifying code
'Hope this helps.
--
Yannick de Kercadio
kercadio@limsi.fr
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Roy Brokvam" <roy.brokvam@conax.com>
Date: 1999/04/20 Raw View
Johann Fischer wrote in message <37136FCA.74344557@t-online.com>...
>Is there somewhere a C++ compiler that supports selfmodifying code or is
>there a c++ extension for such a feature?
Self-modifying code was considered B A D design already in the 70s. I don't
think the evolution of languages and operating systems calls for any change
in this view.
Besides, on operating systems with permission control, and on virus-checked
systems, the program may even be rejected if it tries to modify the
executable file.
If I remember correctly, some Borland products once put user-configurable
settings in the executable. A better alternative is to use initialisation
files or the registry (if you are running on M$ only).
I can think of only one situation where you would want to design and
maintain a self-modifying system; an embedded system with little RAM running
on an operating system with no support for paging nor any other form of
dynamically loaded executable code (from ROM/xEPROM). I believe most
embedded system programmers struggling with little RAM still do assembly.
Regards,
Roy Brokvam
roy.brokvam@conax.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Tom Payne <thp@hill.cs.ucr.edu>
Date: 1999/04/15 Raw View
Johann Fischer <SilverBanana@t-online.de> wrote:
: Hi!
: Is there somewhere a C++ compiler that supports selfmodifying code or is
: there a c++ extension for such a feature?
Nearly all do, in the sense that a C++ program can read and modify its
own source file. But I doubt that is what you have in mind.
I've often wished that I had an interpret/eval function to which I
could submit a string containing a C++ code fragment.
Tom Payne
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: SilverBanana@t-online.de (Johann Fischer)
Date: 1999/04/13 Raw View
Hi!
Is there somewhere a C++ compiler that supports selfmodifying code or is
there a c++ extension for such a feature?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: superdude <me@web1.ucar.edu>
Date: 1999/04/14 Raw View
It's unclear what you're asking about. Compiler produces object code not
source code so what is selfmodifying code?
G.B.
Johann Fischer <SilverBanana@t-online.de> wrote in message
news:37136FCA.74344557@t-online.com...
> Hi!
>
> Is there somewhere a C++ compiler that supports selfmodifying code or is
> there a c++ extension for such a feature?
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: paul@ra.avid.com (Paul Miller)
Date: 1999/04/14 Raw View
SilverBanana@t-online.de (Johann Fischer) writes:
>Is there somewhere a C++ compiler that supports selfmodifying code or is
>there a c++ extension for such a feature?
I'm curious - what would be a use for self-modifying code? I've heard
it used for parsers or compilers but I have no idea why.
Considering it would be completely non-portable, however, I doubt this
is the right group for this.
--
Paul T. Miller | Paul_Miller@avid.com
Principal Engineer | Opinions expressed here are my own.
Avid Technology, Inc. - Graphics and Effects Software Group
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]