[comp.sys.mac.programmer] turning off instruction cache on MAC II

bier@speedy.cs.wisc.edu (George Bier) (03/26/88)

I know this has been asked before but I have yet to see a posted answer,
my apologies if one went by that I missed.

I need to shut off the instruction cache on the 68020 to allow for some
tight self-modifying code.

I know that there is a public domain program to do this, but what I really
want is to be able to include whatever the magic invocation is as part of
the start up code of my application, (the application will determine if
it is running on a 68020 or not and invoke the code accordingly).

Any help is appreciated,

--george

ARPA:	bier@cs.wisc.edu
UUCP:   ...!{harvard,ihnp4,seismo,topaz,akgua,allegra,usbvax}!uwvax!bier

korn@Apple.COM (Peter "Arrgh" Korn) (03/26/88)

In article <5453@spool.cs.wisc.edu> bier@speedy.cs.wisc.edu (George Bier) writes:
>I need to shut off the instruction cache on the 68020 to allow for some
>tight self-modifying code.
>
>I know that there is a public domain program to do this, but what I really
>want is to be able to include whatever the magic invocation is as part of
>the start up code of my application, (the application will determine if
>it is running on a 68020 or not and invoke the code accordingly).

Do to this, simply get yourself a 68020 book and put the op-code in from
Assembly (I'd tell you what it is, but my 68020 book isn't handy).  However,
there are a number of things your should be aware of when you do this,
especially if it's in a commercial application.

#1  you may not be the only one running on the machine.  Well behaved
    programs leave the state of the machine every time they are juggled
    out.  However,

#2  even when your program is the foreground application, turning off
    the cache will affect everyone else running in the background, which
    is also asocial.  And,

#3  This makes your code not very portable to later 680x0 machines, like
    those running 68030 processors (I believe that several companies
    have already announced 68030 boards for the Mac II).  These machines
    have other caches to worry about (seperate instruction and data 
    caches).


I don't know what it is you are trying to do, but I would look very hard
at all other possibilities before writing self-modifying code.  If the
program were a commercial one, I would prefer the performance hit (whatever
it might be) to the support headaches.

Peter
-- 
 Peter "Arrgh" Korn    korn@apple.com   !hplabs!amdahl!apple!korn    "Hi mom!"