Article View: comp.sys.amiga.tech
Article #4244Re: Self Modifying Code!
From: Checkpoint Technologies
Date: Fri, 06 Jul 1990 14:25
Date: Fri, 06 Jul 1990 14:25
36 lines
2411 bytes
2411 bytes
In article <293@smosjc.UUCP> brett@smosjc.UUCP (Brett Coon) writes:
>Is there an acceptable means to write self-modifying code on the Amiga?
>
>Assuming for the sake of argument that I have a good reason to do such
>a thing (and there's a good chance I don't), can I do it without risking
>future compatibility? My current plan is to select one of a few possible
>versions of the code at the beginning, and then patch the code to use the
>appropriate version. It would be done once, during initialization, so
>performance at this point is entirely unimportant. What I envision is an
>operating system call to clear the instruction cache, or do nothing if there
>is no cache. Surely something like this is done by the loader, right?
>
>Please, don't tell me the evils of self-modifying code, I'll only use it if
>I have to. Pretend this question is entirely academic.
OK, well, there's a purely theoretical way to do it that is free of
danger from any kind of cache problems...
Write your code out to a file in hunk format, then LoadSeg() it in. For
better speed, write it to RAM:, that should work just as well.
LoadSeg() must be capable of dealing with stale instruction cache in the
presence of any large cache, or it won't work. On the 68030, I don't
think it does, but then, after all the writing and reading, it's truly
doubtful that there'd be any stale I-cache in the area of your new
segment.
Oh, and BTW, this will work under 1.3. The other suggestion, use the
new 2.0 cache control function, will only work under 2.0 and later.
And finally, of course... self-modifying code is not a good thing to
do.
--
First comes the logo: C H E C K P O I N T T E C H N O L O G I E S / /
\\ / /
Then, the disclaimer: All expressed opinions are, indeed, opinions. \ / o
Now for the witty part: I'm pink, therefore, I'm spam! \/
Technical Details
Message-ID:
<20214@grebyn.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!jarthur!usc!cs.utexas.edu!rice!uupsi!grebyn!ckpReferences:
<293@smosjc.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!jarthur!usc!cs.utexas.edu!rice!uupsi!grebyn!ckp From: ckp@grebyn.com (Checkpoint Technologies) Newsgroups: comp.sys.amiga.tech Subject: Re: Self Modifying Code! Keywords: help, danger, cache, no flames Message-ID: <20214@grebyn.com> Date: 6 Jul 90 14:25:02 GMT References: <293@smosjc.UUCP> Reply-To: ckp@grebyn.UUCP (Checkpoint Technologies) Organization: Grebyn Timesharing, Vienna, VA, USA Lines: 36