A method and apparatus for applying patches to a code or data residing on a non-volatile
memory device is illustrated. A code residing at a first location in a non-volatile
memory can be replaced by a codes residing at a second locations in a memory map.
A patching device compares a first address of a first code to an address identified
by a pre-fetch instruction. If the first address matches the address identified
by the pre-fetch instruction, a pre-fetch abort is issued to facilitate replacing
a bad code residing at the first address with a good code. The good code can be
pointed to by a vector in a vector table where the address of the vector is dynamically
loaded into a program counter.