Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!uw-beaver!ubc-cs!alberta!aunro!ukma!rex!samsung!cs.utexas.edu!sun-barr!rutgers!cbmvax!mks From: mks@cbmvax.commodore.com (Michael Sinz) Newsgroups: comp.sys.amiga.programmer Subject: Re: Self modifying code Message-ID: <22156@cbmvax.commodore.com> Date: 4 Jun 91 12:20:15 GMT References: <1991May30.005339.14067@cs.umu.se> <1991Jun2.091922.13501@unislc.uucp> Reply-To: mks@cbmvax.commodore.com (Michael Sinz) Organization: Commodore, West Chester, PA Lines: 36 In article mwm@pa.dec.com (Mike (My Watch Has Windows) Meyer) writes: >In article <1991Jun2.091922.13501@unislc.uucp> ttobler@unislc.uucp (Trent Tobler) writes: > But that was just an example. Suppose I want to write an interactive > language that compiles directly to machine language which I may choose > to then execute (I believe JForth does this?) > >Picking a nit, that's not self-modifying code, but just generating >code. Unfortunately, the problem being discussedd isn't really >self-modifying code, but data/code confusion. Self-modifying code is >just one of the most common examples of that technic. LISP macros are >another common example. Well, in LISP (as in REXX), the macros are not compiled and thus they are not really changing data into code. (Unless you have a LISP compiler...) > Coding time can be reduce by leaps and bounds if after I type the > definition of a command, I can test immediately without doing the > compile-link-run sequence from the operating system. > > So, what is a good way to implement this type of thing? You can generate the code into memory. You just need to make a call to the system's cache coherency routines to make sure it is all there before you try to execute the code. In the Amiga, this routine is in EXEC and is called CacheClearU() (CacheClearE() is the enhanced version where you can give it a more exact definition of what needs to be cleared) /----------------------------------------------------------------------\ | /// Michael Sinz - Amiga Software Engineer | | /// Operating System Development Group | | /// BIX: msinz UUNET: rutgers!cbmvax!mks | |\\\/// | | \XX/ "I don't think so" said Ren'e Descartes, then he vanished. | \----------------------------------------------------------------------/