Date: Fri, 7 Jan 94 23:52:27 PST From: stevev AT miser DOT uoregon DOT edu (Steve VanDevender) To: DJ Delorie Cc: astor AT alkymi DOT unit DOT no, djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: What is the address of the code? DJ Delorie writes: > WARNING: Because of the way the cache works on the 386 and 486, > opcodes you modify may not be reflected in the cache and won't do what > you expect. The "jmp $+2" trick does NOT work with the 486. See > libsrc/c/dos/int21x.s for an example of self-modiying code that does > work. The 386 has no internal cache, but has a prefetch queue. The 486 internal cache should not cause any problems for self-modifying code all by itself; since instructions and data are cached the same way, modified code in a cache line will be executed as expected. It is my understanding that it is the instruction prefetch queue on the 8086, 80286, and 80386 that makes writing self-modifying code more difficult, because the prefetch queue does not act like a cache and modifying instructions that have already been fetched will not have any effect. Offhand I do not know if the 486 has a prefetch queue in addition to its internal cache; it seems that the cache would make a prefetch queue unnecessary, though.