Article View: comp.sys.amiga.tech
Article #4259Re: Whats wrong with self Modifying Code?
From: Valentin Pepelea
Date: Sat, 07 Jul 1990 00:08
Date: Sat, 07 Jul 1990 00:08
34 lines
2129 bytes
2129 bytes
In article <1990Jul6.201743.24777@csmil.umich.edu>
chymes@fribourg.csmil.umich.edu (Charles Hymes) writes:
>
>Oh great gurus, enlighten this poor soul who hath not programmed in
>Holy Assembler sence the loly 6502 was mighty.
Image you execute some code located at address $2000. While the CPU fetches
the instructions at address $2000, the cache retains those bytes. Next time
the CPU wants to execute the code located at address $2000, the instruction
bytes are already in the cache, so no external memory cycles have to be
performed. Fine.
Now you modify the instruction byte at address $2000. Next time the CPU wants
to execute at address $2000, it thinks it already has the bytes it wants in
the instruction cache, so it executes the wrong piece of code.
"But when I write to location $2000, will I not modify the contents of the
cache?"
Yes, but you will modify the contents of the data cache, not the instruction
cache. Therefore, after modifying a piece of code, you must clear the
instruction cache.
Similarly, you must always clear the caches after a DMA transfer. (Direct
Memory Access) That's when an external device, such as a disk controller, moves
data into your motherboard ram. An alternate solution to clearing the caches
is to declare regions of memory as non-cacheable.
Valentin
--
The Goddess of democracy? "The tyrants Name: Valentin Pepelea
may distroy a statue, but they cannot Phone: (215) 431-9327
kill a god." UseNet: cbmvax!valentin@uunet.uu.net
- Ancient Chinese Proverb Claimer: I not Commodore spokesman be
Technical Details
Message-ID:
<13104@cbmvax.commodore.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!cbmvax!valentinReferences:
<1990Jul6.201328.24660@csmil.umich.edu> <1990Jul6.201743.24777@csmil.umich.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cbmvax!valentin From: valentin@cbmvax.commodore.com (Valentin Pepelea) Newsgroups: comp.sys.amiga.tech Subject: Re: Whats wrong with self Modifying Code? Keywords: religion, gurus, whats up? Message-ID: <13104@cbmvax.commodore.com> Date: 7 Jul 90 00:08:49 GMT References: <1990Jul6.201328.24660@csmil.umich.edu> <1990Jul6.201743.24777@csmil.umich.edu> Reply-To: valentin@cbmvax (Valentin Pepelea) Organization: Commodore, West Chester, PA Lines: 34