1 #define fetch8(x) fetch8func((cycles++,(x)))
8 unsigned pc
; /* Keep pbr in there too */
14 unsigned char *memory
;
15 unsigned int exception
;
19 unsigned int r
[NFAKES
];
35 #define SET_P(_bits) \
37 SET_NBIT((bits>>7)&1); \
38 SET_VBIT((bits>>6)&1); \
39 SET_MBIT((bits>>5)&1); \
40 SET_XBIT((bits>>4)&1); \
41 SET_DBIT((bits>>3)&1); \
42 SET_IBIT((bits>>2)&1); \
43 SET_ZBIT((bits>>1)&1); \
44 SET_CBIT((bits>>0)&1); }
52 #define GET_CBIT (the_cbit)
54 #define GET_DBIT (the_dbit)
55 #define GET_DBR_HIGH (the_dbr)
56 #define GET_DBR_LOW (the_dbr >> 16)
57 #define GET_DPR (the_dpr)
58 #define GET_IBIT (the_ibit)
59 #define GET_MBIT (the_mbit)
60 #define SET_XBIT(x) { the_xbit = x; }
61 #define GET_NBIT (the_nbit)
62 #define GET_PBRPC (the_pc)
63 #define GET_PBR_HIGH (the_pc & 0xff0000)
64 #define GET_PBR_LOW (the_pc >> 16)
65 #define GET_PC (the_pc & 0xffff)
67 #define GET_VBIT (the_vbit)
69 #define GET_XBIT (the_xbit)
71 #define GET_ZBIT (the_zbit)
73 #define INC_PC(x) {the_pc += x;}
74 #define POP16(x) { int _xx; POP8(x); POP8(_xx); x+= _xx<<8;}
75 #define POP24(x) { int _xx; POP8(x); POP8(_xx); x += _xx << 8; POP8(_xx); x += _xx << 16; }
76 #define POP8(x) { SET_S(GET_S +1); x = fetch8(GET_S);}
77 #define PUSH16(x) { int _xx = x;PUSH8(_xx >> 8); PUSH8(_xx);}
78 #define PUSH8(x) { store8(GET_S, x); SET_S(GET_S-1);}
79 #define SET_A(x) { the_a = x & AMASK; }
80 #define SET_B(x) { the_b = x;}
81 #define SET_CBIT(x) { the_cbit = x;}
82 #define SET_CBIT_M(x) { the_cbit = (x & (GET_MBIT ? 0x100: 0x10000)) != 0;}
83 #define SET_CBIT_X(x) { the_cbit = (x & (GET_XBIT ? 0x100: 0x10000)) != 0;}
84 #define SET_D(x) {the_d = x;}
85 #define SET_DBIT(x) { the_dbit= x;}
86 #define SET_DBR_LOW(x) {the_dbr = (x<<16);}
87 #define SET_DPR(x) { the_dpr = x;}
88 #define SET_E(x) { the_e = x;}
89 #define SET_IBIT(x) { the_ibit = x;}
90 #define SET_MBIT(x) { the_mbit = x; }
91 #define SET_NBIT(x) { the_nbit = x;}
92 #define SET_NBIT_16(x) { the_nbit= ( ((x) & (0x8000)) != 0);}
93 #define SET_NBIT_8(x) { the_nbit= ( ((x) & (0x80)) != 0);}
94 #define SET_NBIT_M(x) { if (GET_MBIT) { SET_NBIT_8(x); } else { SET_NBIT_16(x);}}
95 #define SET_NBIT_X(x) { if (GET_XBIT) { SET_NBIT_8(x); } else { SET_NBIT_16(x);}}
96 #define SET_PBR(x) { the_pc = (the_pc & 0xffff) + ((x)<<16);}
97 #define SET_PBRPC(x) { the_pc = x;}
98 #define SET_ONLY_PC(x) { the_pc = (the_pc & 0xff0000) + ((x ) & 0xffff);}
99 #define SET_S(x) {the_s = x; }
100 #define SET_VBIT_16(x) {the_vbit = ((((int)x) < -0x8000) || (((int)x) > 0x7fff));}
101 #define SET_VBIT_8(x) {the_vbit = ((((int)x) < -0x80) || (((int)x) > 0x7f));}
102 /*#define SET_VBIT_M(x) { if(GET_MBIT) {SET_VBIT_8(x);}else {SET_VBIT_16(x);}}*/
103 #define SET_ZBIT_16(x) { the_zbit = ((x & 0xffff) == 0);}
104 #define SET_ZBIT_8(x) { the_zbit = ((x & 0xff) == 0);}
105 #define SET_ZBIT_M(x) { if(GET_MBIT) {SET_ZBIT_8(x);}else {SET_ZBIT_16(x);}}
106 #define SET_ZBIT_X(x) { if(GET_XBIT) {SET_ZBIT_8(x);}else {SET_ZBIT_16(x);}}
107 #define SET_VBIT(x) { the_vbit = x; }
108 #define SET_ZBIT(x) { the_zbit = x; }
109 #define SET_X(x) { the_x = (x) & (GET_XBIT ? 0xff : 0xffff);}
110 #define SET_Y(x) { the_y = (x) & (GET_XBIT ? 0xff : 0xffff);}
112 #define AMASK ( GET_MBIT ? 0xff : 0xffff)
113 #define SMASK ( GET_MBIT ? 0x80 : 0x8000)
114 #define SET_VBIT_M(s1,acc,d) ( the_vbit = ((s1 ^ acc) & (acc ^ d) & SMASK )!=0)
116 /*#define fetch8(x) (memory[x&MMASK])*/
117 #define fetch16(x) (fetch8(x) + (fetch8((x)+1)<<8))
118 #define fetch24(x) (fetch8(x) + (fetch8((x)+1)<<8) + (fetch8((x)+2)<<16))
119 #define fetch8sext(x) ((char)fetch8(x))
120 #define fetch16sext(x) ((short)fetch16(x))
121 #define store8(x,y) {memory[x&MMASK]=y;}
122 #define store16(x,y) { store8(x,y); store8(x+1,y>>8);}
123 #define SEXTM(x) (GET_MBIT ? ((char)x): ((short)x))
126 #define STARTFUNC() \
127 register unsigned char *memory;\
147 int tick_start = get_now ();\
151 SET_E (saved_state.e); \
152 SET_P (saved_state.p); \
153 SET_A (saved_state.a); \
154 SET_X (saved_state.x); \
155 SET_Y (saved_state.y); \
156 SET_ONLY_PC (saved_state.pc); \
157 SET_PBR (saved_state.pc >> 16); \
158 SET_DBR_LOW (saved_state.dbr); \
159 SET_D (saved_state.d); \
160 SET_S (saved_state.s); \
161 memory = saved_state.memory ; \
162 { int k; for (k = 0; k < NFAKES; k++) \
163 store16(0x10 + k * 2, saved_state.r[k]); }\
171 saved_state.ticks += get_now () - tick_start;\
172 saved_state.cycles += cycles; \
173 saved_state.insts += insts; \
174 { int k; for (k = 0; k < NFAKES; k++) \
175 saved_state.r[k] = fetch16(0x10 + k * 2); }\
177 saved_state.e = GET_E; \
178 saved_state.p = GET_P; \
179 saved_state.a = GET_A; \
180 saved_state.x = GET_X; \
181 saved_state.y = GET_Y; \
182 saved_state.pc = GET_PBRPC; \
183 saved_state.dbr = GET_DBR_LOW; \
184 saved_state.d = GET_D; \
185 saved_state.s = GET_S; \
190 extern saved_state_type saved_state;
192 #define MMASK 0xfffff
194 #define RETHINK goto rethink;
This page took 0.032597 seconds and 4 git commands to generate.