First post, by DivByZero
- Rank
- Newbie
Hi guys, I've been using two common DOS programs over the last six months:
ICD.EXE - Disable CPU cache
ICE.EXE - Enable CPU cache
These simple utilities can turn the L1 CPU cache off and on again, and they are very helpful to assist with speed throttling on older games that were designed for 386 or earlier systems, and don't have speed throttling built in. At first, these utilities seemed to work well. After installing a write-back enhanced 486 DX2 (S-Spec SX955) however, running ICD.EXE would crash, and I'd get output like this:
Disabling Internal Cache
Memory allocation error
Cannot load COMMAND, system halted
This problem went away when I changed the cache from write-back mode to write-through. My suspicion was that ICD was failing to flush the cache. Since the write-back cache may be holding changes which haven't been written to external memory (as opposed to write-through, which writes to the internal cache and forwards those writes externally), this would effectively cause memory corruption and resulting failures. I tried an alternate approach described here to build equivalent COM programs to enable and disable the cache:
https://www.rigacci.org/docs/biblio/online/fi … re/cacheoff.htm
This worked correctly. I disassembled ICD.EXE and found it uses the INVD opcode (https://www.felixcloutier.com/x86/invd), while the other tool that works uses the WBINVD opcode (https://www.felixcloutier.com/x86/wbinvd). The difference between the two is that INVD invalidates the internal cache WITHOUT writing it back to external memory, while WBINVD triggers a write to memory for dirty memory in internal and external caches. Clearly it's the second one we want here.
I couldn't find a record of this issue anywhere on the internet, so I'm documenting it here. Given this issue, I'd recommend not using any ICD.EXE files you've found in the wild. You could use the COM programs instead, or you could fix the ICD.EXE binary to use the correct instruction (change "0F 08" to "0F 09" at offset 0x218). To make things simple, I've attached a zip file to this post which contains a fixed version of ICD.EXE (called ICDFIXED.EXE) along with ICE.EXE, and I've also included CACHEON.COM and CACHEOFF.COM, which work as-is. Use whichever you prefer, but I'd advise not using the original ICD.EXE, even on processors without write-back support.