[comp.sys.next] 030/040 incompatible caching

max@nic.gac.edu (Max Hailperin) (01/24/91)

In article <1991Jan23.161546.6623@Neon.Stanford.EDU> I wrote:
> [description of CScheme-7.1 doing weird things on 040, not on 030] ...
>I would lay very large odds that the problem concerns the [caching] ....

Here is a much simpler, safer example of how the 030 and 040 caches
behave differently than the scheme crashing stuff.  The below program
modifies a simple machine-language routine that just returns a number
to return a different number.  On the 030, it then returns the new number,
but on the 040 it still returns the old.  This is just a test program,
not an example of how anyone should really write code.  But, it is similar
to what native-code lisp/ML/... systems do for good reasons.
============================== Here's the code ======================
#include <stdio.h>

static unsigned char foo[] = {112, 13, 78, 117}; /* moveq #13, d0; rts */

main(){
  int (*fp)();
  
  fp = (int (*)()) foo;
  printf("unmodified foo (%d), returns %d.\n", foo[1], (*fp)());
  foo[1] = 7;
  printf("modified foo (%d), returns %d.\n", foo[1], (*fp)());
}
=========================== Here's the 030 output: ===========================
unmodified foo (13), returns 13.
modified foo (7), returns 7.
=========================== Here's the 040 output: ===========================
unmodified foo (13), returns 13.
modified foo (7), returns 13.