Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cis.ohio-state.edu!ucbvax!bloom-beacon!eru!hagbard!sunic!dkuug!diku!bombadil From: bombadil@diku.dk (Kristian Nielsen) Newsgroups: comp.sys.amiga.programmer Subject: Re: Self modifying code Message-ID: <1991May29.134419.4980@odin.diku.dk> Date: 29 May 91 13:44:19 GMT References: <5005@orbit.cts.com> <1991May28.120630.10150@cs.umu.se> Sender: bombadil@freja.diku.dk Organization: Department of Computer Science, U of Copenhagen Lines: 38 dvljrt@cs.umu.se (Joakim Rosqvist) writes: >Ok, I have heard before that you should not use self modifying code. >Can anybody give a good reason for this, besides it being bad programming >pratice. >I just got the RKM manuals and they only stated "for compatibilty with >010/020/030 etc. don't use selfmodifying code" >Could it be that data written to an address that is also in cachememory >will update the memory, but not the cache? Yes, this is the problem - I believe on the '040 its even worse, since a write might only go to the (data) cache and not be written to memory until later. >Consider for instance that I would like to write a fast completely >unwinded linedrawing routine and wrote code for drawing one pixel. >Then when the program start, I would allocate memory for 320 such routines >and putting 320 copies of my routine there. Would this be considered as >selfmodifying code, and therefore forbidden? Yes, this, too will break on 680x0 with cache. >If so, compare it to when the OS is loading a program that contains >non-PC relative references to itself which will have to be rewritten >depending on the address the code was loaded to. Yes, the OS has to do this, so it has to know how to flush the cache - actually the loading of the code itself could be termed selfmodifying. I think 2.0 includes a function like LoadSeg() that 'loads' code from a SegList already in memory. And before asking about being 1.3-compatible: don't bother (at least when 2.0 becomes avaiable). Hopefully (IMHO), in 6 months it will be impossible to buy an 1.3 Amiga. >/$DR.HEX$ >-------------------------------------------- >Email to: dvljrt@cs.umu.se >2 Windows on the screen? Oh no, not me. I just Logout & Go.