FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

SYSTEM

Clear the 68040 processor cache


The 68040 processor has a data cache that is unique in causing unexplainable crashes, especially if you are writing self-modifying code. The solution is to clear the cache before the offending line of code.

The easy part is clearing the cache; the hard part is finding the spot to do it. Here is the code to clear the cache:

LOCAL FN FlushCache
  LONG IF gCPU&=68040
    ` dc.w $A0BD
  END IF
END FN

You would get the CPU type earlier in the program with these routines:

LOCAL FN GetCPU
  DIM cpuType&
  cpuType& = FN GESTALT (_gestaltProcessorType)
END FN=cpuType&

LOCAL FN GetEnvironment
  IF FN GetCPU=_gestalt68040 THEN gCPU&=68040
END FN

As for the part of the code that's causing the crash, it usually happens when you're using inline assembler and jumping to certain lines of code (in FB it may even be at a GOTO statement). You'll probably want to use MacsBug to narrow your search.

Wave