home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
- From: d88-jwa@dront.nada.kth.se (Jon WΣtte)
- Subject: Re: Proper way to do Self-Modifying code?
- Message-ID: <1993Jan4.120353.16699@kth.se>
- Sender: usenet@kth.se (Usenet)
- Nntp-Posting-Host: dront.nada.kth.se
- Organization: Royal Institute of Technology, Stockholm, Sweden
- References: <wfFp_jO00WB707kGgq@andrew.cmu.edu>
- Date: Mon, 4 Jan 1993 12:03:53 GMT
- Lines: 31
-
- In <wfFp_jO00WB707kGgq@andrew.cmu.edu> at15+@andrew.cmu.edu (Andrew Lewis Tepper) writes:
-
- >Is there an accepted way to do this on the Mac? I know that
- >self-modifying code can cause problems on chips with caches, so I want
- >to be as "kosher" as possible.
-
- if ( TrapAvailable ( _HwPriv ) ) {
-
- /* FIC also calls FlushDataCache */
- FlushInstructionCache ( ) ;
- }
-
- Of course you'll want to put the result of TrapAvailable in
- a global at startup. Not to mention first modifying ALL the
- figures, then flushing the cache ONCE before starting to
- call the code.
-
- However, I think you could write the code quite conflict-free
- and as fast using just address-register-relative addressing
- and maybe a data register for rowBytes. Modifying the instructions
- data takes time to do; I think using a register pair would be
- FASTER - and more compatible.
-
- Cheers,
-
- / h+
-
- --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
-
- -- I don't fear death, it's dying that scares me.
-