comparison engine.c @ 21:1925cfa982fe

fixing trace
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 09 Jul 2018 11:25:28 +0900
parents e3b08716aa53
children 5217f23f2f9e
comparison
equal deleted inserted replaced
20:49fac9474858 21:1925cfa982fe
37 Byte aca,acb; 37 Byte aca,acb;
38 Byte *breg=&aca,*areg=&acb; 38 Byte *breg=&aca,*areg=&acb;
39 static int tracetrick=0; 39 static int tracetrick=0;
40 extern long romstart; 40 extern long romstart;
41 41
42 #ifdef USE_MMU 42 #ifndef USE_MMU
43
44 static Byte mem1(Word adr) {
45 if ((adr&0xfe00)==(IOPAGE&0xfe00)) return do_input(adr&0x1ff);
46 return mem[adr];
47 }
48
49 static void SETBYTE1(Word a,Byte n) {
50 if ((a&0xfe00)==(IOPAGE&0xfe00)) do_output(a&0x1ff,n);
51 if(!(a>=romstart))mem[a]=n;
52 }
53 #define mem(a) mem1(a)
54 #define SETBYTE(a,n) SETBYTE1(a,n);
55
56 #else
57
58 int paddr(Word adr, Byte *immu) {
59 if ((adr&0xfe00)==(IOPAGE&0xfe00)) return memsize-0x10000+adr;
60 return (immu[ (adr) >> 13 ] <<13 ) + ((adr) & 0x1fff );
61 }
43 62
44 Byte * mem0(Byte *iphymem, Word adr, Byte *immu) { 63 Byte * mem0(Byte *iphymem, Word adr, Byte *immu) {
45 if ((adr&0xfe00)==(IOPAGE&0xfe00)) return &mem[adr]; 64 return & iphymem[ paddr(adr,immu) ];
46 int addr = (immu[ (adr) >> 13 ] <<13 ) + ((adr) & 0x1fff );
47 return & iphymem[ addr ];
48 } 65 }
49 66
50 static Byte mem1(Byte *iphymem, Word adr, Byte *immu) { 67 static Byte mem1(Byte *iphymem, Word adr, Byte *immu) {
51 if ((adr&0xfe00)==(IOPAGE&0xfe00)) return do_input(adr&0x1ff); 68 if ((adr&0xfe00)==(IOPAGE&0xfe00)) return do_input(adr&0x1ff);
52 Byte *p = mem0(iphymem, adr, immu); 69 Byte *p = mem0(iphymem, adr, immu);
69 if(!(p-phymem>=romstart)) { \ 86 if(!(p-phymem>=romstart)) { \
70 *p=n; \ 87 *p=n; \
71 } \ 88 } \
72 } \ 89 } \
73 } 90 }
74
75
76 #else
77
78 static Byte mem1(Word adr) {
79 if ((adr&0xfe00)==(IOPAGE&0xfe00)) return do_input(adr&0x1ff);
80 return mem[adr];
81 }
82
83 static void SETBYTE1(Word a,Byte n) {
84 if ((a&0xfe00)==(IOPAGE&0xfe00)) do_output(a&0x1ff,n);
85 if(!(a>=romstart))mem[a]=n;
86 }
87 #define mem(a) mem1(a)
88 #define SETBYTE(a,n) SETBYTE1(a,n);
89 91
90 #endif 92 #endif
91 93
92 #define GETWORD(a) (mem(a)<<8|mem((a)+1)) 94 #define GETWORD(a) (mem(a)<<8|mem((a)+1))
93 #define SETWORD(a,n) {Word a1=a;SETBYTE(a1,n>>8);SETBYTE(a1+1,n);} 95 #define SETWORD(a,n) {Word a1=a;SETBYTE(a1,n>>8);SETBYTE(a1+1,n);}