home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20595 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.4 KB  |  44 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
  3. From: d88-jwa@dront.nada.kth.se (Jon WΣtte)
  4. Subject: Re: Proper way to do Self-Modifying code?
  5. Message-ID: <1993Jan4.120353.16699@kth.se>
  6. Sender: usenet@kth.se (Usenet)
  7. Nntp-Posting-Host: dront.nada.kth.se
  8. Organization: Royal Institute of Technology, Stockholm, Sweden
  9. References: <wfFp_jO00WB707kGgq@andrew.cmu.edu>
  10. Date: Mon, 4 Jan 1993 12:03:53 GMT
  11. Lines: 31
  12.  
  13. In <wfFp_jO00WB707kGgq@andrew.cmu.edu> at15+@andrew.cmu.edu (Andrew Lewis Tepper) writes:
  14.  
  15. >Is there an accepted way to do this on the Mac?  I know that
  16. >self-modifying code can cause problems on chips with caches, so I want
  17. >to be as "kosher" as possible.
  18.  
  19.     if ( TrapAvailable ( _HwPriv ) ) {
  20.  
  21.         /* FIC also calls FlushDataCache */
  22.         FlushInstructionCache ( ) ;
  23.     }
  24.  
  25. Of course you'll want to put the result of TrapAvailable in
  26. a global at startup. Not to mention first modifying ALL the
  27. figures, then flushing the cache ONCE before starting to
  28. call the code.
  29.  
  30. However, I think you could write the code quite conflict-free
  31. and as fast using just address-register-relative addressing
  32. and maybe a data register for rowBytes. Modifying the instructions
  33. data takes time to do; I think using a register pair would be
  34. FASTER - and more compatible.
  35.  
  36. Cheers,
  37.  
  38.                             / h+
  39.  
  40. -- 
  41.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  42.  
  43.  -- I don't fear death, it's dying that scares me.
  44.