trunk/src/emu/cpu/spc700/spc700.c
| r26761 | r26762 | |
| 65 | 65 | #include "debugger.h" |
| 66 | 66 | #include "spc700.h" |
| 67 | 67 | |
| 68 | | /* CPU Structure */ |
| 69 | | struct spc700i_cpu |
| 70 | | { |
| 71 | | uint a; /* Accumulator */ |
| 72 | | uint x; /* Index Register X */ |
| 73 | | uint y; /* Index Register Y */ |
| 74 | | uint s; /* Stack Pointer */ |
| 75 | | uint pc; /* Program Counter */ |
| 76 | | uint ppc; /* Previous Program Counter */ |
| 77 | | uint flag_n; /* Negative Flag */ |
| 78 | | uint flag_z; /* Zero flag */ |
| 79 | | uint flag_v; /* Overflow Flag */ |
| 80 | | uint flag_p; /* Direct Page Flag */ |
| 81 | | uint flag_b; /* BRK Instruction Flag */ |
| 82 | | uint flag_h; /* Half-carry Flag */ |
| 83 | | uint flag_i; /* Interrupt Mask Flag */ |
| 84 | | uint flag_c; /* Carry Flag */ |
| 85 | | uint line_irq; /* Status of the IRQ line */ |
| 86 | | uint line_nmi; /* Status of the NMI line */ |
| 87 | | uint line_rst; /* Status of the RESET line */ |
| 88 | | uint ir; /* Instruction Register */ |
| 89 | | device_irq_acknowledge_callback int_ack; |
| 90 | | legacy_cpu_device *device; |
| 91 | | address_space *program; |
| 92 | | uint stopped; /* stopped status */ |
| 93 | | int ICount; |
| 94 | | uint source; |
| 95 | | uint destination; |
| 96 | | uint temp1, temp2, temp3; |
| 97 | | short spc_int16; |
| 98 | | int spc_int32; |
| 99 | | }; |
| 100 | 68 | |
| 101 | | INLINE spc700i_cpu *get_safe_token(device_t *device) |
| 102 | | { |
| 103 | | assert(device != NULL); |
| 104 | | assert(device->type() == SPC700); |
| 105 | | return (spc700i_cpu *)downcast<legacy_cpu_device *>(device)->token(); |
| 106 | | } |
| 107 | | |
| 108 | 69 | /* ======================================================================== */ |
| 109 | 70 | /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */ |
| 110 | 71 | /* ======================================================================== */ |
| 111 | 72 | |
| 112 | | /* This should be set to the default size of your processor (min 16 bit) */ |
| 113 | | #undef uint |
| 114 | | #define uint unsigned int |
| 115 | | |
| 116 | | #undef uint8 |
| 117 | | #define uint8 unsigned char |
| 118 | | |
| 119 | 73 | #undef int8 |
| 120 | 74 | |
| 121 | 75 | /* Allow for architectures that don't have 8-bit sizes */ |
| r26761 | r26762 | |
| 183 | 137 | #define VECTOR_IRQ 0xfffc /* IRQ ??? what is real vector? */ |
| 184 | 138 | #define VECTOR_NMI 0xfffa /* NMI ??? what is real vector? */ |
| 185 | 139 | |
| 186 | | #define REG_A cpustate->a /* Accumulator */ |
| 187 | | #define REG_X cpustate->x /* Index X Register */ |
| 188 | | #define REG_Y cpustate->y /* Index Y Register */ |
| 189 | | #define REG_S cpustate->s /* Stack Pointer */ |
| 190 | | #define REG_PC cpustate->pc /* Program Counter */ |
| 191 | | #define REG_PPC cpustate->ppc /* Previous Program Counter */ |
| 192 | | #define REG_P cpustate->p /* Processor Status Register */ |
| 193 | | #define FLAG_NZ cpustate->flag_n = cpustate->flag_z /* Negative Flag and inverted Zero flag */ |
| 194 | | #define FLAG_N cpustate->flag_n /* Negative flag */ |
| 195 | | #define FLAG_Z cpustate->flag_z /* Inverted Zero flag */ |
| 196 | | #define FLAG_V cpustate->flag_v /* Overflow Flag */ |
| 197 | | #define FLAG_P cpustate->flag_p /* Direct Page Flag */ |
| 198 | | #define FLAG_B cpustate->flag_b /* BRK Instruction Flag */ |
| 199 | | #define FLAG_H cpustate->flag_h /* Decimal Mode Flag */ |
| 200 | | #define FLAG_I cpustate->flag_i /* Interrupt Mask Flag */ |
| 201 | | #define FLAG_C cpustate->flag_c /* Carry Flag */ |
| 202 | | #define LINE_IRQ cpustate->line_irq /* Status of the IRQ line */ |
| 203 | | #define LINE_NMI cpustate->line_nmi /* Status of the NMI line */ |
| 204 | | #define REG_IR cpustate->ir /* Instruction Register */ |
| 205 | | #define INT_ACK cpustate->int_ack /* Interrupt Acknowledge function pointer */ |
| 206 | | #define CLOCKS cpustate->ICount /* Clock cycles remaining */ |
| 207 | | #define CPU_STOPPED cpustate->stopped /* Stopped status */ |
| 140 | #define REG_A m_a /* Accumulator */ |
| 141 | #define REG_X m_x /* Index X Register */ |
| 142 | #define REG_Y m_y /* Index Y Register */ |
| 143 | #define REG_S m_s /* Stack Pointer */ |
| 144 | #define REG_PC m_pc /* Program Counter */ |
| 145 | #define REG_PPC m_ppc /* Previous Program Counter */ |
| 146 | #define REG_P m_p /* Processor Status Register */ |
| 147 | #define FLAG_NZ m_flag_n = m_flag_z /* Negative Flag and inverted Zero flag */ |
| 148 | #define FLAG_N m_flag_n /* Negative flag */ |
| 149 | #define FLAG_Z m_flag_z /* Inverted Zero flag */ |
| 150 | #define FLAG_V m_flag_v /* Overflow Flag */ |
| 151 | #define FLAG_P m_flag_p /* Direct Page Flag */ |
| 152 | #define FLAG_B m_flag_b /* BRK Instruction Flag */ |
| 153 | #define FLAG_H m_flag_h /* Decimal Mode Flag */ |
| 154 | #define FLAG_I m_flag_i /* Interrupt Mask Flag */ |
| 155 | #define FLAG_C m_flag_c /* Carry Flag */ |
| 156 | #define LINE_IRQ m_line_irq /* Status of the IRQ line */ |
| 157 | #define LINE_NMI m_line_nmi /* Status of the NMI line */ |
| 158 | #define REG_IR m_ir /* Instruction Register */ |
| 159 | #define CLOCKS m_ICount /* Clock cycles remaining */ |
| 160 | #define CPU_STOPPED m_stopped /* Stopped status */ |
| 208 | 161 | |
| 209 | | #define SRC cpustate->source /* Source Operand */ |
| 210 | | #define DST cpustate->destination /* Destination Operand */ |
| 211 | | #define TMP1 cpustate->temp1 /* temporary result 1 */ |
| 212 | | #define TMP2 cpustate->temp2 /* temporary result 2 */ |
| 213 | | #define TMP3 cpustate->temp3 /* temporary result 3 */ |
| 162 | #define SRC m_source /* Source Operand */ |
| 163 | #define DST m_destination /* Destination Operand */ |
| 164 | #define TMP1 m_temp1 /* temporary result 1 */ |
| 165 | #define TMP2 m_temp2 /* temporary result 2 */ |
| 166 | #define TMP3 m_temp3 /* temporary result 3 */ |
| 214 | 167 | |
| 215 | 168 | #define STOP_LEVEL_STOP 1 |
| 216 | 169 | #define STOP_LEVEL_SLEEP 2 |
| r26761 | r26762 | |
| 247 | 200 | /* ================================= MAME ================================= */ |
| 248 | 201 | /* ======================================================================== */ |
| 249 | 202 | |
| 250 | | #define spc700_read_8(addr) cpustate->program->read_byte(addr) |
| 251 | | #define spc700_write_8(addr,data) cpustate->program->write_byte(addr,data) |
| 203 | #define spc700_read_8(addr) m_program->read_byte(addr) |
| 204 | #define spc700_write_8(addr,data) m_program->write_byte(addr,data) |
| 252 | 205 | |
| 253 | 206 | #define spc700_read_8_direct(A) spc700_read_8(A) |
| 254 | 207 | #define spc700_write_8_direct(A, V) spc700_write_8(A, V) |
| 255 | | //#define spc700_read_instruction(A) memory_decrypted_read_byte(cpustate->program,A) |
| 256 | | //#define spc700_read_8_immediate(A) memory_raw_read_byte(cpustate->program,A) |
| 257 | | #define spc700_read_instruction(A) cpustate->program->read_byte(A) |
| 258 | | #define spc700_read_8_immediate(A) cpustate->program->read_byte(A) |
| 208 | //#define spc700_read_instruction(A) memory_decrypted_read_byte(m_program,A) |
| 209 | //#define spc700_read_8_immediate(A) memory_raw_read_byte(m_program,A) |
| 210 | #define spc700_read_instruction(A) m_program->read_byte(A) |
| 211 | #define spc700_read_8_immediate(A) m_program->read_byte(A) |
| 259 | 212 | #define spc700_jumping(A) |
| 260 | 213 | #define spc700_branching(A) |
| 261 | 214 | |
| 262 | 215 | |
| 263 | 216 | |
| 217 | const device_type SPC700 = &device_creator<spc700_device>; |
| 218 | |
| 219 | |
| 220 | spc700_device::spc700_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 221 | : cpu_device(mconfig, SPC700, "SPC700", tag, owner, clock, "spc700", __FILE__) |
| 222 | , m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0) |
| 223 | { |
| 224 | } |
| 225 | |
| 226 | |
| 264 | 227 | /* ======================================================================== */ |
| 265 | 228 | /* ============================ UTILITY MACROS ============================ */ |
| 266 | 229 | /* ======================================================================== */ |
| r26761 | r26762 | |
| 269 | 232 | #define CLK(A) CLOCKS -= (A) |
| 270 | 233 | #define CLK_ALL() CLOCKS = 0 |
| 271 | 234 | |
| 272 | | #define BREAKOUT break |
| 273 | 235 | |
| 274 | | INLINE uint read_8_normal(spc700i_cpu *cpustate, uint address) |
| 236 | UINT32 spc700_device::read_8_normal(UINT32 address) |
| 275 | 237 | { |
| 276 | 238 | address = MAKE_UINT_16(address); |
| 277 | 239 | return spc700_read_8(address); |
| 278 | 240 | } |
| 279 | 241 | |
| 280 | | INLINE uint read_8_immediate(spc700i_cpu *cpustate, uint address) |
| 242 | UINT32 spc700_device::read_8_immediate(UINT32 address) |
| 281 | 243 | { |
| 282 | 244 | address = MAKE_UINT_16(address); |
| 283 | 245 | return spc700_read_8_immediate(address); |
| 284 | 246 | } |
| 285 | 247 | |
| 286 | | #ifdef UNUSED_FUNCTION |
| 287 | | INLINE uint read_8_instruction(spc700i_cpu *cpustate, uint address) |
| 248 | UINT32 spc700_device::read_8_instruction(UINT32 address) |
| 288 | 249 | { |
| 289 | 250 | address = MAKE_UINT_16(address); |
| 290 | 251 | return spc700_read_instruction(address); |
| 291 | 252 | } |
| 292 | | #endif |
| 293 | 253 | |
| 294 | | INLINE uint read_8_direct(spc700i_cpu *cpustate, uint address) |
| 254 | UINT32 spc700_device::read_8_direct(UINT32 address) |
| 295 | 255 | { |
| 296 | 256 | address = MAKE_UINT_8(address) | FLAG_P; |
| 297 | 257 | return spc700_read_8_direct(address); |
| 298 | 258 | } |
| 299 | 259 | |
| 300 | | INLINE void write_8_normal(spc700i_cpu *cpustate, uint address, uint value) |
| 260 | void spc700_device::write_8_normal(UINT32 address, UINT32 value) |
| 301 | 261 | { |
| 302 | 262 | address = MAKE_UINT_16(address); |
| 303 | 263 | value = MAKE_UINT_8(value); |
| 304 | 264 | spc700_write_8(address, value); |
| 305 | 265 | } |
| 306 | 266 | |
| 307 | | INLINE void write_8_direct(spc700i_cpu *cpustate, uint address, uint value) |
| 267 | void spc700_device::write_8_direct(UINT32 address, UINT32 value) |
| 308 | 268 | { |
| 309 | 269 | address = MAKE_UINT_8(address) | FLAG_P; |
| 310 | 270 | value = MAKE_UINT_8(value); |
| r26761 | r26762 | |
| 312 | 272 | } |
| 313 | 273 | |
| 314 | 274 | |
| 315 | | INLINE uint read_16_normal(spc700i_cpu *cpustate, uint address) |
| 275 | UINT32 spc700_device::read_16_normal(UINT32 address) |
| 316 | 276 | { |
| 317 | | return read_8_normal(cpustate, address) | (read_8_normal(cpustate, address+1)<<8); |
| 277 | return read_8_normal(address) | (read_8_normal(address+1)<<8); |
| 318 | 278 | } |
| 319 | 279 | |
| 320 | | INLINE uint read_16_immediate(spc700i_cpu *cpustate, uint address) |
| 280 | UINT32 spc700_device::read_16_immediate(UINT32 address) |
| 321 | 281 | { |
| 322 | | return read_8_immediate(cpustate, address) | (read_8_immediate(cpustate, address+1)<<8); |
| 282 | return read_8_immediate(address) | (read_8_immediate(address+1)<<8); |
| 323 | 283 | } |
| 324 | 284 | |
| 325 | | INLINE uint read_16_direct(spc700i_cpu *cpustate, uint address) |
| 285 | UINT32 spc700_device::read_16_direct(UINT32 address) |
| 326 | 286 | { |
| 327 | | return read_8_direct(cpustate, address) | (read_8_direct(cpustate, address+1)<<8); |
| 287 | return read_8_direct(address) | (read_8_direct(address+1)<<8); |
| 328 | 288 | } |
| 329 | 289 | |
| 330 | | INLINE void write_16_direct(spc700i_cpu *cpustate, uint address, uint value) |
| 290 | void spc700_device::write_16_direct(UINT32 address, UINT32 value) |
| 331 | 291 | { |
| 332 | | write_8_direct(cpustate, address, value); |
| 333 | | write_8_direct(cpustate, address+1, value>>8); |
| 292 | write_8_direct(address, value); |
| 293 | write_8_direct(address+1, value>>8); |
| 334 | 294 | } |
| 335 | 295 | |
| 336 | 296 | /* Low level memory access macros */ |
| 337 | | #define read_8_NORM(A) read_8_normal(cpustate, A) |
| 338 | | #define read_8_IMM(A) read_8_immediate(cpustate, A) |
| 339 | | #define read_8_ABS(A) read_8_normal(cpustate, A) |
| 340 | | #define read_8_ABX(A) read_8_normal(cpustate, A) |
| 341 | | #define read_8_ABY(A) read_8_normal(cpustate, A) |
| 342 | | #define read_8_AXI(A) read_8_normal(cpustate, A) |
| 343 | | #define read_8_DP(A) read_8_direct(cpustate, A) |
| 344 | | #define read_8_DPX(A) read_8_direct(cpustate, A) |
| 345 | | #define read_8_DPY(A) read_8_direct(cpustate, A) |
| 346 | | #define read_8_DPI(A) read_8_normal(cpustate, A) |
| 347 | | #define read_8_DXI(A) read_8_normal(cpustate, A) |
| 348 | | #define read_8_DIY(A) read_8_normal(cpustate, A) |
| 349 | | #define read_8_STK(A) read_8_normal(cpustate, A) |
| 350 | | #define read_8_XI(A) read_8_direct(cpustate, A) |
| 351 | | #define read_8_XII(A) read_8_direct(cpustate, A) |
| 352 | | #define read_8_YI(A) read_8_direct(cpustate, A) |
| 297 | #define read_8_NORM(A) read_8_normal(A) |
| 298 | #define read_8_IMM(A) read_8_immediate(A) |
| 299 | #define read_8_ABS(A) read_8_normal(A) |
| 300 | #define read_8_ABX(A) read_8_normal(A) |
| 301 | #define read_8_ABY(A) read_8_normal(A) |
| 302 | #define read_8_AXI(A) read_8_normal(A) |
| 303 | #define read_8_DP(A) read_8_direct(A) |
| 304 | #define read_8_DPX(A) read_8_direct(A) |
| 305 | #define read_8_DPY(A) read_8_direct(A) |
| 306 | #define read_8_DPI(A) read_8_normal(A) |
| 307 | #define read_8_DXI(A) read_8_normal(A) |
| 308 | #define read_8_DIY(A) read_8_normal(A) |
| 309 | #define read_8_STK(A) read_8_normal(A) |
| 310 | #define read_8_XI(A) read_8_direct(A) |
| 311 | #define read_8_XII(A) read_8_direct(A) |
| 312 | #define read_8_YI(A) read_8_direct(A) |
| 353 | 313 | |
| 354 | 314 | |
| 355 | | #define read_16_NORM(A) read_16_normal(cpustate, A) |
| 356 | | #define read_16_IMM(A) read_16_immediate(cpustate, A) |
| 357 | | #define read_16_ABS(A) read_16_absolute(cpustate, A) |
| 358 | | #define read_16_ABX(A) read_16_normal(cpustate, A) |
| 359 | | #define read_16_DP(A) read_16_direct(cpustate, A) |
| 360 | | #define read_16_DPX(A) read_16_direct(cpustate, A) |
| 361 | | #define read_16_DPY(A) read_16_direct(cpustate, A) |
| 362 | | #define read_16_DPI(A) read_16_normal(cpustate, A) |
| 363 | | #define read_16_VEC(A) read_16_normal(cpustate, A) |
| 364 | | #define read_16_XI(A) read_16_direct(cpustate, A) |
| 365 | | #define read_16_XII(A) read_16_direct(cpustate, A) |
| 366 | | #define read_16_YI(A) read_16_direct(cpustate, A) |
| 315 | #define read_16_NORM(A) read_16_normal(A) |
| 316 | #define read_16_IMM(A) read_16_immediate(A) |
| 317 | #define read_16_ABS(A) read_16_absolute(A) |
| 318 | #define read_16_ABX(A) read_16_normal(A) |
| 319 | #define read_16_DP(A) read_16_direct(A) |
| 320 | #define read_16_DPX(A) read_16_direct(A) |
| 321 | #define read_16_DPY(A) read_16_direct(A) |
| 322 | #define read_16_DPI(A) read_16_normal(A) |
| 323 | #define read_16_VEC(A) read_16_normal(A) |
| 324 | #define read_16_XI(A) read_16_direct(A) |
| 325 | #define read_16_XII(A) read_16_direct(A) |
| 326 | #define read_16_YI(A) read_16_direct(A) |
| 367 | 327 | |
| 368 | | #define write_8_NORM(A, V) write_8_normal(cpustate, A, V) |
| 369 | | #define write_8_IMM(A, V) write_8_normal(cpustate, A, V) |
| 370 | | #define write_8_ABS(A, V) write_8_normal(cpustate, A, V) |
| 371 | | #define write_8_ABX(A, V) write_8_normal(cpustate, A, V) |
| 372 | | #define write_8_ABY(A, V) write_8_normal(cpustate, A, V) |
| 373 | | #define write_8_AXI(A, V) write_8_normal(cpustate, A, V) |
| 374 | | #define write_8_DP(A, V) write_8_direct(cpustate, A, V) |
| 375 | | #define write_8_DPX(A, V) write_8_direct(cpustate, A, V) |
| 376 | | #define write_8_DPY(A, V) write_8_direct(cpustate, A, V) |
| 377 | | #define write_8_DPI(A, V) write_8_normal(cpustate, A, V) |
| 378 | | #define write_8_DXI(A, V) write_8_normal(cpustate, A, V) |
| 379 | | #define write_8_DIY(A, V) write_8_normal(cpustate, A, V) |
| 380 | | #define write_8_STK(A, V) write_8_normal(cpustate, A, V) |
| 381 | | #define write_8_XI(A, V) write_8_direct(cpustate, A, V) |
| 382 | | #define write_8_XII(A, V) write_8_direct(cpustate, A, V) |
| 383 | | #define write_8_YI(A, V) write_8_direct(cpustate, A, V) |
| 328 | #define write_8_NORM(A, V) write_8_normal(A, V) |
| 329 | #define write_8_IMM(A, V) write_8_normal(A, V) |
| 330 | #define write_8_ABS(A, V) write_8_normal(A, V) |
| 331 | #define write_8_ABX(A, V) write_8_normal(A, V) |
| 332 | #define write_8_ABY(A, V) write_8_normal(A, V) |
| 333 | #define write_8_AXI(A, V) write_8_normal(A, V) |
| 334 | #define write_8_DP(A, V) write_8_direct(A, V) |
| 335 | #define write_8_DPX(A, V) write_8_direct(A, V) |
| 336 | #define write_8_DPY(A, V) write_8_direct(A, V) |
| 337 | #define write_8_DPI(A, V) write_8_normal(A, V) |
| 338 | #define write_8_DXI(A, V) write_8_normal(A, V) |
| 339 | #define write_8_DIY(A, V) write_8_normal(A, V) |
| 340 | #define write_8_STK(A, V) write_8_normal(A, V) |
| 341 | #define write_8_XI(A, V) write_8_direct(A, V) |
| 342 | #define write_8_XII(A, V) write_8_direct(A, V) |
| 343 | #define write_8_YI(A, V) write_8_direct(A, V) |
| 384 | 344 | |
| 385 | | #define write_16_NORM(A, V) write_16_normal(cpustate, A, V) |
| 386 | | #define write_16_ABS(A, V) write_16_normal(cpustate, A, V) |
| 387 | | #define write_16_ABX(A, V) write_16_normal(cpustate, A, V) |
| 388 | | #define write_16_ABY(A, V) write_16_normal(cpustate, A, V) |
| 389 | | #define write_16_AXI(A, V) write_16_normal(cpustate, A, V) |
| 390 | | #define write_16_DP(A, V) write_16_direct(cpustate, A, V) |
| 391 | | #define write_16_DPX(A, V) write_16_direct(cpustate, A, V) |
| 392 | | #define write_16_DPY(A, V) write_16_direct(cpustate, A, V) |
| 393 | | #define write_16_DPI(A, V) write_16_normal(cpustate, A, V) |
| 394 | | #define write_16_DXI(A, V) write_16_normal(cpustate, A, V) |
| 395 | | #define write_16_DIY(A, V) write_16_normal(cpustate, A, V) |
| 396 | | #define write_16_STK(A, V) write_16_normal(cpustate, A, V) |
| 397 | | #define write_16_XI(A, V) write_16_direct(cpustate, A, V) |
| 398 | | #define write_16_XII(A, V) write_16_direct(cpustate, A, V) |
| 399 | | #define write_16_YI(A, V) write_16_direct(cpustate, A, V) |
| 345 | #define write_16_NORM(A, V) write_16_normal(A, V) |
| 346 | #define write_16_ABS(A, V) write_16_normal(A, V) |
| 347 | #define write_16_ABX(A, V) write_16_normal(A, V) |
| 348 | #define write_16_ABY(A, V) write_16_normal(A, V) |
| 349 | #define write_16_AXI(A, V) write_16_normal(A, V) |
| 350 | #define write_16_DP(A, V) write_16_direct(A, V) |
| 351 | #define write_16_DPX(A, V) write_16_direct(A, V) |
| 352 | #define write_16_DPY(A, V) write_16_direct(A, V) |
| 353 | #define write_16_DPI(A, V) write_16_normal(A, V) |
| 354 | #define write_16_DXI(A, V) write_16_normal(A, V) |
| 355 | #define write_16_DIY(A, V) write_16_normal(A, V) |
| 356 | #define write_16_STK(A, V) write_16_normal(A, V) |
| 357 | #define write_16_XI(A, V) write_16_direct(A, V) |
| 358 | #define write_16_XII(A, V) write_16_direct(A, V) |
| 359 | #define write_16_YI(A, V) write_16_direct(A, V) |
| 400 | 360 | |
| 401 | 361 | |
| 402 | | #define OPER_8_IMM(cpustate) read_8_IMM(EA_IMM(cpustate)) |
| 403 | | #define OPER_8_ABS(cpustate) read_8_ABS(EA_ABS(cpustate)) |
| 404 | | #define OPER_8_ABX(cpustate) read_8_ABX(EA_ABX(cpustate)) |
| 405 | | #define OPER_8_ABY(cpustate) read_8_ABY(EA_ABY(cpustate)) |
| 406 | | #define OPER_8_AXI(cpustate) read_8_IND(EA_IND(cpustate)) |
| 407 | | #define OPER_8_DP(cpustate) read_8_DP(EA_DP(cpustate)) |
| 408 | | #define OPER_8_DPX(cpustate) read_8_DPX(EA_DPX(cpustate)) |
| 409 | | #define OPER_8_DPY(cpustate) read_8_DPY(EA_DPY(cpustate)) |
| 410 | | #define OPER_8_DPI(cpustate) read_8_DPI(EA_DPI(cpustate)) |
| 411 | | #define OPER_8_DXI(cpustate) read_8_DXI(EA_DXI(cpustate)) |
| 412 | | #define OPER_8_DIY(cpustate) read_8_DIY(EA_DIY(cpustate)) |
| 413 | | #define OPER_8_XI(cpustate) read_8_XI(EA_XI(cpustate)) |
| 414 | | #define OPER_8_XII(cpustate) read_8_XI(EA_XII(cpustate)) |
| 415 | | #define OPER_8_YI(cpustate) read_8_YI(EA_YI(cpustate)) |
| 362 | #define OPER_8_IMM() read_8_IMM(EA_IMM()) |
| 363 | #define OPER_8_ABS() read_8_ABS(EA_ABS()) |
| 364 | #define OPER_8_ABX() read_8_ABX(EA_ABX()) |
| 365 | #define OPER_8_ABY() read_8_ABY(EA_ABY()) |
| 366 | #define OPER_8_AXI() read_8_IND(EA_IND()) |
| 367 | #define OPER_8_DP() read_8_DP(EA_DP()) |
| 368 | #define OPER_8_DPX() read_8_DPX(EA_DPX()) |
| 369 | #define OPER_8_DPY() read_8_DPY(EA_DPY()) |
| 370 | #define OPER_8_DPI() read_8_DPI(EA_DPI()) |
| 371 | #define OPER_8_DXI() read_8_DXI(EA_DXI()) |
| 372 | #define OPER_8_DIY() read_8_DIY(EA_DIY()) |
| 373 | #define OPER_8_XI() read_8_XI(EA_XI()) |
| 374 | #define OPER_8_XII() read_8_XI(EA_XII()) |
| 375 | #define OPER_8_YI() read_8_YI(EA_YI()) |
| 416 | 376 | |
| 417 | | #define OPER_16_IMM(cpustate) read_16_IMM(EA_IMM16(cpustate)) |
| 418 | | #define OPER_16_ABS(cpustate) read_16_ABS(EA_ABS(cpustate)) |
| 419 | | #define OPER_16_ABX(cpustate) read_16_ABX(EA_ABX(cpustate)) |
| 420 | | #define OPER_16_ABY(cpustate) read_16_ABY(EA_ABY(cpustate)) |
| 421 | | #define OPER_16_AXI(cpustate) read_16_IND(EA_IND(cpustate)) |
| 422 | | #define OPER_16_DP(cpustate) read_16_DP(EA_DP(cpustate)) |
| 423 | | #define OPER_16_DPX(cpustate) read_16_DPX(EA_DPX(cpustate)) |
| 424 | | #define OPER_16_DPY(cpustate) read_16_DPY(EA_DPY(cpustate)) |
| 425 | | #define OPER_16_DPI(cpustate) read_16_DPI(EA_DXI(cpustate)) |
| 426 | | #define OPER_16_DXI(cpustate) read_16_DXI(EA_DXI(cpustate)) |
| 427 | | #define OPER_16_DIY(cpustate) read_16_DIY(EA_DIY(cpustate)) |
| 428 | | #define OPER_16_XI(cpustate) read_16_XI(EA_XI(cpustate)) |
| 429 | | #define OPER_16_XII(cpustate) read_16_XI(EA_XII(cpustate)) |
| 430 | | #define OPER_16_YI(cpustate) read_16_YI(EA_YI(cpustate)) |
| 377 | #define OPER_16_IMM() read_16_IMM(EA_IMM16()) |
| 378 | #define OPER_16_ABS() read_16_ABS(EA_ABS()) |
| 379 | #define OPER_16_ABX() read_16_ABX(EA_ABX()) |
| 380 | #define OPER_16_ABY() read_16_ABY(EA_ABY()) |
| 381 | #define OPER_16_AXI() read_16_IND(EA_IND()) |
| 382 | #define OPER_16_DP() read_16_DP(EA_DP()) |
| 383 | #define OPER_16_DPX() read_16_DPX(EA_DPX()) |
| 384 | #define OPER_16_DPY() read_16_DPY(EA_DPY()) |
| 385 | #define OPER_16_DPI() read_16_DPI(EA_DXI()) |
| 386 | #define OPER_16_DXI() read_16_DXI(EA_DXI()) |
| 387 | #define OPER_16_DIY() read_16_DIY(EA_DIY()) |
| 388 | #define OPER_16_XI() read_16_XI(EA_XI()) |
| 389 | #define OPER_16_XII() read_16_XI(EA_XII()) |
| 390 | #define OPER_16_YI() read_16_YI(EA_YI()) |
| 431 | 391 | |
| 432 | 392 | /* Effective Address Calculations */ |
| 433 | | INLINE uint EA_IMM(spc700i_cpu *cpustate) {return REG_PC++;} |
| 434 | | INLINE uint EA_IMM16(spc700i_cpu *cpustate) {REG_PC += 2; return REG_PC-2;} |
| 435 | | INLINE uint EA_ABS(spc700i_cpu *cpustate) {return OPER_16_IMM(cpustate);} |
| 436 | | INLINE uint EA_ABX(spc700i_cpu *cpustate) {return EA_ABS(cpustate) + REG_X;} |
| 437 | | INLINE uint EA_ABY(spc700i_cpu *cpustate) {return EA_ABS(cpustate) + REG_Y;} |
| 438 | | INLINE uint EA_AXI(spc700i_cpu *cpustate) {return OPER_16_ABX(cpustate);} |
| 439 | | INLINE uint EA_DP(spc700i_cpu *cpustate) {return OPER_8_IMM(cpustate);} |
| 440 | | INLINE uint EA_DPX(spc700i_cpu *cpustate) {return (EA_DP(cpustate) + REG_X)&0xff;} |
| 441 | | INLINE uint EA_DPY(spc700i_cpu *cpustate) {return (EA_DP(cpustate) + REG_Y)&0xff;} |
| 442 | | INLINE uint EA_DXI(spc700i_cpu *cpustate) {return OPER_16_DPX(cpustate);} |
| 443 | | INLINE uint EA_DIY(spc700i_cpu *cpustate) {uint addr = OPER_16_DP(cpustate); if((addr&0xff00) != ((addr+REG_Y)&0xff00)) CLK(1); return addr + REG_Y;} |
| 444 | | INLINE uint EA_XI(spc700i_cpu *cpustate) {return REG_X;} |
| 445 | | INLINE uint EA_XII(spc700i_cpu *cpustate) {uint val = REG_X;REG_X = MAKE_UINT_8(REG_X+1);return val;} |
| 446 | | INLINE uint EA_YI(spc700i_cpu *cpustate) {return REG_Y;} |
| 393 | UINT32 spc700_device::EA_IMM() {return REG_PC++;} |
| 394 | UINT32 spc700_device::EA_IMM16() {REG_PC += 2; return REG_PC-2;} |
| 395 | UINT32 spc700_device::EA_ABS() {return OPER_16_IMM();} |
| 396 | UINT32 spc700_device::EA_ABX() {return EA_ABS() + REG_X;} |
| 397 | UINT32 spc700_device::EA_ABY() {return EA_ABS() + REG_Y;} |
| 398 | UINT32 spc700_device::EA_AXI() {return OPER_16_ABX();} |
| 399 | UINT32 spc700_device::EA_DP() {return OPER_8_IMM();} |
| 400 | UINT32 spc700_device::EA_DPX() {return (EA_DP() + REG_X)&0xff;} |
| 401 | UINT32 spc700_device::EA_DPY() {return (EA_DP() + REG_Y)&0xff;} |
| 402 | UINT32 spc700_device::EA_DXI() {return OPER_16_DPX();} |
| 403 | UINT32 spc700_device::EA_DIY() {UINT32 addr = OPER_16_DP(); if((addr&0xff00) != ((addr+REG_Y)&0xff00)) CLK(1); return addr + REG_Y;} |
| 404 | UINT32 spc700_device::EA_XI() {return REG_X;} |
| 405 | UINT32 spc700_device::EA_XII() {UINT32 val = REG_X;REG_X = MAKE_UINT_8(REG_X+1);return val;} |
| 406 | UINT32 spc700_device::EA_YI() {return REG_Y;} |
| 447 | 407 | |
| 448 | 408 | |
| 449 | 409 | |
| 450 | 410 | /* Change the Program Counter */ |
| 451 | | INLINE void JUMP(spc700i_cpu *cpustate, uint address) |
| 411 | void spc700_device::JUMP(UINT32 address) |
| 452 | 412 | { |
| 453 | 413 | REG_PC = address; |
| 454 | 414 | spc700_jumping(REG_PC); |
| 455 | 415 | } |
| 456 | 416 | |
| 457 | | INLINE void BRANCH(spc700i_cpu *cpustate, uint offset) |
| 417 | void spc700_device::BRANCH(UINT32 offset) |
| 458 | 418 | { |
| 459 | 419 | REG_PC = MAKE_UINT_16(REG_PC + MAKE_INT_8(offset)); |
| 460 | 420 | spc700_branching(REG_PC); |
| r26761 | r26762 | |
| 463 | 423 | |
| 464 | 424 | #define GET_REG_YA() (REG_A | (REG_Y<<8)) |
| 465 | 425 | |
| 466 | | INLINE void SET_REG_YA(spc700i_cpu *cpustate, uint value) |
| 426 | void spc700_device::SET_REG_YA(UINT32 value) |
| 467 | 427 | { |
| 468 | 428 | REG_A = MAKE_UINT_8(value); |
| 469 | 429 | REG_Y = MAKE_UINT_8(value>>8); |
| r26761 | r26762 | |
| 480 | 440 | ((!FLAG_Z) << 1) | \ |
| 481 | 441 | CFLAG_AS_1()) |
| 482 | 442 | |
| 483 | | INLINE void SET_FLAG_I(spc700i_cpu *cpustate, uint value); |
| 484 | | |
| 485 | 443 | /* Set the Process Status Register */ |
| 486 | | INLINE void SET_REG_P(spc700i_cpu *cpustate, uint value) |
| 444 | void spc700_device::SET_REG_P(UINT32 value) |
| 487 | 445 | { |
| 488 | 446 | FLAG_N = (value & 0x80); |
| 489 | 447 | FLAG_Z = !(value & 2); |
| r26761 | r26762 | |
| 492 | 450 | FLAG_B = value & FLAGPOS_B; |
| 493 | 451 | FLAG_H = value & HFLAG_SET; |
| 494 | 452 | FLAG_C = value << 8; |
| 495 | | SET_FLAG_I(cpustate, value); |
| 453 | SET_FLAG_I(value); |
| 496 | 454 | } |
| 497 | 455 | |
| 498 | 456 | /* Push/Pull data to/from the stack */ |
| 499 | | INLINE void PUSH_8(spc700i_cpu *cpustate, uint value) |
| 457 | void spc700_device::PUSH_8(UINT32 value) |
| 500 | 458 | { |
| 501 | 459 | write_8_STK(REG_S+STACK_PAGE, value); |
| 502 | 460 | REG_S = MAKE_UINT_8(REG_S - 1); |
| 503 | 461 | } |
| 504 | 462 | |
| 505 | | INLINE uint PULL_8(spc700i_cpu *cpustate) |
| 463 | UINT32 spc700_device::PULL_8() |
| 506 | 464 | { |
| 507 | 465 | REG_S = MAKE_UINT_8(REG_S + 1); |
| 508 | 466 | return read_8_STK(REG_S+STACK_PAGE); |
| 509 | 467 | } |
| 510 | 468 | |
| 511 | | INLINE void PUSH_16(spc700i_cpu *cpustate, uint value) |
| 469 | void spc700_device::PUSH_16(UINT32 value) |
| 512 | 470 | { |
| 513 | | PUSH_8(cpustate, value>>8); |
| 514 | | PUSH_8(cpustate, value); |
| 471 | PUSH_8(value>>8); |
| 472 | PUSH_8(value); |
| 515 | 473 | } |
| 516 | 474 | |
| 517 | | INLINE uint PULL_16(spc700i_cpu *cpustate) |
| 475 | UINT32 spc700_device::PULL_16() |
| 518 | 476 | { |
| 519 | | uint value = PULL_8(cpustate); |
| 520 | | return value | (PULL_8(cpustate)<<8); |
| 477 | UINT32 value = PULL_8(); |
| 478 | return value | (PULL_8()<<8); |
| 521 | 479 | } |
| 522 | 480 | |
| 523 | | #if !SPC700_OPTIMIZE_SNES |
| 524 | | INLINE void CHECK_IRQ(spc700i_cpu *cpustate) |
| 481 | void spc700_device::CHECK_IRQ() |
| 525 | 482 | { |
| 526 | 483 | if(FLAG_I & LINE_IRQ) |
| 527 | 484 | SERVICE_IRQ(); |
| 528 | 485 | } |
| 529 | | #endif /* SPC700_OPTIMIZE_SNES */ |
| 530 | 486 | |
| 531 | | INLINE void SET_FLAG_I(spc700i_cpu *cpustate, uint value) |
| 487 | void spc700_device::SERVICE_IRQ() |
| 532 | 488 | { |
| 489 | fatalerror("spc700: SERVICE_IRQ() not implemented yet!\n"); |
| 490 | } |
| 491 | |
| 492 | |
| 493 | void spc700_device::SET_FLAG_I(UINT32 value) |
| 494 | { |
| 533 | 495 | FLAG_I = value & IFLAG_SET; |
| 534 | 496 | #if !SPC700_OPTIMIZE_SNES |
| 535 | | CHECK_IRQ(cpustate); |
| 497 | CHECK_IRQ(); |
| 536 | 498 | #endif |
| 537 | 499 | } |
| 538 | 500 | |
| r26761 | r26762 | |
| 541 | 503 | /* ======================================================================== */ |
| 542 | 504 | |
| 543 | 505 | #define SUBOP_ADC(A, B) \ |
| 544 | | cpustate->spc_int16 = (A) + (B) + CFLAG_AS_1(); \ |
| 506 | m_spc_int16 = (A) + (B) + CFLAG_AS_1(); \ |
| 545 | 507 | TMP1 = ((A) & 0x0f) + (CFLAG_AS_1()); \ |
| 546 | | FLAG_C = (cpustate->spc_int16 > 0xff) ? CFLAG_SET : 0; \ |
| 547 | | FLAG_V = (~((A) ^ (B))) & (((A) ^ cpustate->spc_int16) & 0x80); \ |
| 548 | | FLAG_H = (((cpustate->spc_int16 & 0x0f) - TMP1) & 0x10) >> 1; \ |
| 549 | | FLAG_NZ = (UINT8)cpustate->spc_int16 |
| 508 | FLAG_C = (m_spc_int16 > 0xff) ? CFLAG_SET : 0; \ |
| 509 | FLAG_V = (~((A) ^ (B))) & (((A) ^ m_spc_int16) & 0x80); \ |
| 510 | FLAG_H = (((m_spc_int16 & 0x0f) - TMP1) & 0x10) >> 1; \ |
| 511 | FLAG_NZ = (UINT8)m_spc_int16 |
| 550 | 512 | |
| 551 | 513 | |
| 552 | 514 | /* Add With Carry */ |
| 553 | 515 | #define OP_ADC(BCLK, MODE) \ |
| 554 | 516 | CLK(BCLK); \ |
| 555 | | SRC = OPER_8_##MODE(cpustate); \ |
| 517 | SRC = OPER_8_##MODE(); \ |
| 556 | 518 | SUBOP_ADC(SRC, REG_A); \ |
| 557 | | REG_A = (UINT8)cpustate->spc_int16; |
| 519 | REG_A = (UINT8)m_spc_int16; |
| 558 | 520 | |
| 559 | 521 | |
| 560 | 522 | /* Add With Carry to memory */ |
| 561 | 523 | #define OP_ADCM(BCLK, SMODE, DMODE) \ |
| 562 | 524 | CLK(BCLK); \ |
| 563 | | SRC = OPER_8_##SMODE(cpustate); \ |
| 564 | | DST = EA_##DMODE(cpustate); \ |
| 525 | SRC = OPER_8_##SMODE(); \ |
| 526 | DST = EA_##DMODE(); \ |
| 565 | 527 | SUBOP_ADC(SRC, read_8_##DMODE(DST)); \ |
| 566 | | write_8_##DMODE(DST, (UINT8)cpustate->spc_int16) |
| 528 | write_8_##DMODE(DST, (UINT8)m_spc_int16) |
| 567 | 529 | |
| 568 | 530 | /* Add word */ |
| 569 | 531 | #define OP_ADDW(BCLK) \ |
| 570 | 532 | CLK(BCLK); \ |
| 571 | | SRC = OPER_16_DP(cpustate); \ |
| 533 | SRC = OPER_16_DP(); \ |
| 572 | 534 | DST = GET_REG_YA(); \ |
| 573 | 535 | TMP1 = ((SRC) & 0xff) + ((DST) & 0xff); \ |
| 574 | 536 | TMP2 = (TMP1 > 0xff) ? 1 : 0; \ |
| 575 | 537 | TMP3 = ((SRC) >> 8) + ((DST) >> 8) + TMP2; \ |
| 576 | | cpustate->spc_int16 = ((TMP1 & 0xff) + (TMP3 << 8)) & 0xffff; \ |
| 538 | m_spc_int16 = ((TMP1 & 0xff) + (TMP3 << 8)) & 0xffff; \ |
| 577 | 539 | FLAG_C = (TMP3 > 0xff) ? CFLAG_SET : 0; \ |
| 578 | 540 | FLAG_H = ((unsigned) ((((DST) >> 8) & 0x0F) + \ |
| 579 | 541 | (((SRC) >> 8) & 0x0F) + TMP2)) > 0x0F ? HFLAG_SET : 0; \ |
| 580 | | FLAG_V = (~((DST) ^ (SRC)) & ((SRC) ^ (UINT16) cpustate->spc_int16) & 0x8000) ? VFLAG_SET : 0; \ |
| 581 | | FLAG_Z = (cpustate->spc_int16 != 0); \ |
| 582 | | FLAG_N = (cpustate->spc_int16>>8); \ |
| 583 | | SET_REG_YA(cpustate, cpustate->spc_int16); |
| 542 | FLAG_V = (~((DST) ^ (SRC)) & ((SRC) ^ (UINT16) m_spc_int16) & 0x8000) ? VFLAG_SET : 0; \ |
| 543 | FLAG_Z = (m_spc_int16 != 0); \ |
| 544 | FLAG_N = (m_spc_int16>>8); \ |
| 545 | SET_REG_YA(m_spc_int16); |
| 584 | 546 | |
| 585 | 547 | /* Logical AND with accumulator */ |
| 586 | 548 | #define OP_AND(BCLK, MODE) \ |
| 587 | 549 | CLK(BCLK); \ |
| 588 | | FLAG_NZ = REG_A &= OPER_8_##MODE(cpustate) |
| 550 | FLAG_NZ = REG_A &= OPER_8_##MODE() |
| 589 | 551 | |
| 590 | 552 | /* Logical AND operand */ |
| 591 | 553 | #define OP_ANDM(BCLK, SMODE, DMODE) \ |
| 592 | 554 | CLK(BCLK); \ |
| 593 | | FLAG_NZ = OPER_8_##SMODE(cpustate); \ |
| 594 | | DST = EA_##DMODE(cpustate); \ |
| 555 | FLAG_NZ = OPER_8_##SMODE(); \ |
| 556 | DST = EA_##DMODE(); \ |
| 595 | 557 | FLAG_NZ &= read_8_##DMODE(DST); \ |
| 596 | 558 | write_8_##DMODE(DST, FLAG_NZ) |
| 597 | 559 | |
| 598 | 560 | /* Logical AND bit to C */ |
| 599 | 561 | #define OP_AND1(BCLK) \ |
| 600 | 562 | CLK(BCLK); \ |
| 601 | | DST = EA_IMM16(cpustate); \ |
| 563 | DST = EA_IMM16(); \ |
| 602 | 564 | if(FLAG_C & CFLAG_SET) \ |
| 603 | 565 | { \ |
| 604 | 566 | DST = read_16_IMM(DST); \ |
| r26761 | r26762 | |
| 611 | 573 | /* AND negated bit to C */ |
| 612 | 574 | #define OP_ANDN1(BCLK) \ |
| 613 | 575 | CLK(BCLK); \ |
| 614 | | DST = EA_IMM16(cpustate); \ |
| 576 | DST = EA_IMM16(); \ |
| 615 | 577 | if(FLAG_C & CFLAG_SET) \ |
| 616 | 578 | { \ |
| 617 | 579 | DST = read_16_IMM(DST); \ |
| r26761 | r26762 | |
| 630 | 592 | /* Arithmetic Shift Left operand */ |
| 631 | 593 | #define OP_ASLM(BCLK, MODE) \ |
| 632 | 594 | CLK(BCLK); \ |
| 633 | | DST = EA_##MODE(cpustate); \ |
| 595 | DST = EA_##MODE(); \ |
| 634 | 596 | FLAG_C = read_8_##MODE(DST) << 1; \ |
| 635 | 597 | FLAG_NZ = MAKE_UINT_8(FLAG_C); \ |
| 636 | 598 | write_8_##MODE(DST, FLAG_NZ) |
| r26761 | r26762 | |
| 638 | 600 | /* Branch if Bit Reset */ |
| 639 | 601 | #define OP_BBC(BCLK, BIT) \ |
| 640 | 602 | CLK(BCLK); \ |
| 641 | | SRC = OPER_8_DP(cpustate); \ |
| 642 | | DST = OPER_8_IMM(cpustate); \ |
| 603 | SRC = OPER_8_DP(); \ |
| 604 | DST = OPER_8_IMM(); \ |
| 643 | 605 | if(!(SRC & BIT)) \ |
| 644 | 606 | { \ |
| 645 | 607 | CLK(2); \ |
| 646 | | BRANCH(cpustate, DST); \ |
| 608 | BRANCH(DST); \ |
| 647 | 609 | } |
| 648 | 610 | |
| 649 | 611 | /* Branch if Bit Set */ |
| 650 | 612 | #define OP_BBS(BCLK, BIT) \ |
| 651 | 613 | CLK(BCLK); \ |
| 652 | | SRC = OPER_8_DP(cpustate); \ |
| 653 | | DST = OPER_8_IMM(cpustate); \ |
| 614 | SRC = OPER_8_DP(); \ |
| 615 | DST = OPER_8_IMM(); \ |
| 654 | 616 | if(SRC & BIT) \ |
| 655 | 617 | { \ |
| 656 | 618 | CLK(2); \ |
| 657 | | BRANCH(cpustate, DST); \ |
| 619 | BRANCH(DST); \ |
| 658 | 620 | } |
| 659 | 621 | |
| 660 | 622 | /* Branch on Condition Code */ |
| 661 | 623 | #define OP_BCC(BCLK, COND) \ |
| 662 | 624 | CLK(BCLK); \ |
| 663 | | DST = OPER_8_IMM(cpustate); \ |
| 625 | DST = OPER_8_IMM(); \ |
| 664 | 626 | if(COND) \ |
| 665 | 627 | { \ |
| 666 | 628 | CLK(2); \ |
| 667 | | BRANCH(cpustate, DST); \ |
| 629 | BRANCH(DST); \ |
| 668 | 630 | } |
| 669 | 631 | |
| 670 | 632 | /* Branch Unconditional */ |
| 671 | 633 | /* speed up busy loops */ |
| 672 | 634 | #define OP_BRA(BCLK) \ |
| 673 | 635 | CLK(BCLK); \ |
| 674 | | BRANCH(cpustate, OPER_8_IMM(cpustate)); \ |
| 636 | BRANCH(OPER_8_IMM()); \ |
| 675 | 637 | if(REG_PC == REG_PPC) \ |
| 676 | 638 | CLK_ALL() |
| 677 | 639 | |
| 678 | 640 | /* Cause a Break interrupt */ |
| 679 | 641 | #define OP_BRK(BCLK) \ |
| 680 | 642 | CLK(BCLK); \ |
| 681 | | PUSH_16(cpustate, REG_PC); \ |
| 682 | | PUSH_8(cpustate, GET_REG_P()); \ |
| 643 | PUSH_16(REG_PC); \ |
| 644 | PUSH_8(GET_REG_P()); \ |
| 683 | 645 | FLAG_B |= FLAGPOS_B; \ |
| 684 | 646 | FLAG_I = IFLAG_CLEAR; \ |
| 685 | | JUMP(cpustate, read_16_VEC(VECTOR_BRK)) |
| 647 | JUMP(read_16_VEC(VECTOR_BRK)) |
| 686 | 648 | |
| 687 | 649 | /* Call subroutine */ |
| 688 | 650 | #define OP_CALL(BCLK) \ |
| 689 | 651 | CLK(BCLK); \ |
| 690 | | DST = EA_ABS(cpustate); \ |
| 691 | | PUSH_16(cpustate, REG_PC); \ |
| 692 | | JUMP(cpustate, DST) |
| 652 | DST = EA_ABS(); \ |
| 653 | PUSH_16(REG_PC); \ |
| 654 | JUMP(DST) |
| 693 | 655 | |
| 694 | 656 | /* Compare accumulator and branch if not equal */ |
| 695 | 657 | #define OP_CBNE(BCLK, MODE) \ |
| 696 | 658 | CLK(BCLK); \ |
| 697 | | SRC = OPER_8_##MODE(cpustate); \ |
| 698 | | DST = EA_IMM(cpustate); \ |
| 659 | SRC = OPER_8_##MODE(); \ |
| 660 | DST = EA_IMM(); \ |
| 699 | 661 | if(SRC != REG_A) \ |
| 700 | 662 | { \ |
| 701 | 663 | CLK(2); \ |
| 702 | | BRANCH(cpustate, read_8_IMM(DST)); \ |
| 664 | BRANCH(read_8_IMM(DST)); \ |
| 703 | 665 | } |
| 704 | 666 | |
| 705 | 667 | /* Clear Carry flag */ |
| r26761 | r26762 | |
| 710 | 672 | /* Clear Memory Bit */ |
| 711 | 673 | #define OP_CLR(BCLK, BIT) \ |
| 712 | 674 | CLK(BCLK); \ |
| 713 | | DST = EA_DP(cpustate); \ |
| 675 | DST = EA_DP(); \ |
| 714 | 676 | SRC = read_8_DP(DST) & ~BIT; \ |
| 715 | 677 | write_8_DP(DST, SRC) |
| 716 | 678 | |
| r26761 | r26762 | |
| 728 | 690 | /* Compare operand to register */ |
| 729 | 691 | #define OP_CMPR(BCLK, REG, MODE) \ |
| 730 | 692 | CLK(BCLK); \ |
| 731 | | SRC = OPER_8_##MODE(cpustate); \ |
| 732 | | cpustate->spc_int16 = (short)REG - (short)SRC; \ |
| 733 | | FLAG_C = (cpustate->spc_int16 >= 0) ? CFLAG_SET : 0; \ |
| 734 | | FLAG_NZ = MAKE_UINT_8(cpustate->spc_int16); |
| 693 | SRC = OPER_8_##MODE(); \ |
| 694 | m_spc_int16 = (short)REG - (short)SRC; \ |
| 695 | FLAG_C = (m_spc_int16 >= 0) ? CFLAG_SET : 0; \ |
| 696 | FLAG_NZ = MAKE_UINT_8(m_spc_int16); |
| 735 | 697 | |
| 736 | 698 | /* Compare memory */ |
| 737 | 699 | #define OP_CMPM(BCLK, SMODE, DMODE) \ |
| 738 | 700 | CLK(BCLK); \ |
| 739 | | SRC = OPER_8_##SMODE(cpustate); \ |
| 740 | | cpustate->spc_int16 = (short)OPER_8_##DMODE(cpustate) - (short)SRC; \ |
| 741 | | FLAG_C = (cpustate->spc_int16 >= 0) ? CFLAG_SET : 0; \ |
| 742 | | FLAG_NZ = MAKE_UINT_8(cpustate->spc_int16); |
| 701 | SRC = OPER_8_##SMODE(); \ |
| 702 | m_spc_int16 = (short)OPER_8_##DMODE() - (short)SRC; \ |
| 703 | FLAG_C = (m_spc_int16 >= 0) ? CFLAG_SET : 0; \ |
| 704 | FLAG_NZ = MAKE_UINT_8(m_spc_int16); |
| 743 | 705 | |
| 744 | 706 | /* Compare word */ |
| 745 | 707 | #define OP_CMPW(BCLK, MODE) \ |
| 746 | 708 | CLK(BCLK); \ |
| 747 | | SRC = OPER_16_##MODE(cpustate); \ |
| 748 | | cpustate->spc_int32 = (int)GET_REG_YA() - (int)SRC; \ |
| 749 | | FLAG_C = (cpustate->spc_int32 >= 0) ? CFLAG_SET : 0; \ |
| 750 | | FLAG_NZ = NZFLAG_16(cpustate->spc_int32); |
| 709 | SRC = OPER_16_##MODE(); \ |
| 710 | m_spc_int32 = (int)GET_REG_YA() - (int)SRC; \ |
| 711 | FLAG_C = (m_spc_int32 >= 0) ? CFLAG_SET : 0; \ |
| 712 | FLAG_NZ = NZFLAG_16(m_spc_int32); |
| 751 | 713 | |
| 752 | 714 | /* Decimal adjust for addition */ |
| 753 | 715 | #define OP_DAA(BCLK) \ |
| r26761 | r26762 | |
| 788 | 750 | #define OP_DBNZR(BCLK) \ |
| 789 | 751 | CLK(BCLK); \ |
| 790 | 752 | REG_Y = MAKE_UINT_8(REG_Y - 1); \ |
| 791 | | DST = EA_IMM(cpustate); \ |
| 753 | DST = EA_IMM(); \ |
| 792 | 754 | if(REG_Y != 0) \ |
| 793 | 755 | { \ |
| 794 | 756 | CLK(2); \ |
| 795 | | BRANCH(cpustate, read_8_IMM(DST)); \ |
| 757 | BRANCH(read_8_IMM(DST)); \ |
| 796 | 758 | } |
| 797 | 759 | |
| 798 | 760 | /* Decrement operand and branch if not zero */ |
| 799 | 761 | /* Speed up busy loops but do reads/writes for compatibility */ |
| 800 | 762 | #define OP_DBNZM(BCLK) \ |
| 801 | 763 | CLK(BCLK); \ |
| 802 | | DST = EA_DP(cpustate); \ |
| 764 | DST = EA_DP(); \ |
| 803 | 765 | SRC = MAKE_UINT_8(read_8_DP(DST) - 1); \ |
| 804 | 766 | write_8_DP(DST, SRC); \ |
| 805 | | DST = EA_IMM(cpustate); \ |
| 767 | DST = EA_IMM(); \ |
| 806 | 768 | if(SRC != 0) \ |
| 807 | 769 | { \ |
| 808 | 770 | CLK(2); \ |
| 809 | | BRANCH(cpustate, read_8_IMM(DST)); \ |
| 771 | BRANCH(read_8_IMM(DST)); \ |
| 810 | 772 | } |
| 811 | 773 | |
| 812 | 774 | /* Decrement register */ |
| r26761 | r26762 | |
| 817 | 779 | /* Decrement operand */ |
| 818 | 780 | #define OP_DECM(BCLK, MODE) \ |
| 819 | 781 | CLK(BCLK); \ |
| 820 | | DST = EA_##MODE(cpustate); \ |
| 782 | DST = EA_##MODE(); \ |
| 821 | 783 | FLAG_NZ = MAKE_UINT_8(read_8_##MODE(DST) - 1); \ |
| 822 | 784 | write_8_##MODE(DST, FLAG_NZ) |
| 823 | 785 | |
| 824 | 786 | /* Decrement word */ |
| 825 | 787 | #define OP_DECW(BCLK) \ |
| 826 | 788 | CLK(BCLK); \ |
| 827 | | DST = EA_DP(cpustate); \ |
| 789 | DST = EA_DP(); \ |
| 828 | 790 | FLAG_NZ = MAKE_UINT_16(read_16_DP(DST) - 1); \ |
| 829 | 791 | write_16_DP(DST, FLAG_Z); \ |
| 830 | 792 | FLAG_NZ = NZFLAG_16(FLAG_Z) |
| r26761 | r26762 | |
| 849 | 811 | if (TMP1 & 1) TMP1 = ((TMP1 - TMP2) & 0x1ffff); \ |
| 850 | 812 | } \ |
| 851 | 813 | FLAG_V = (TMP1 & 0x100) ? VFLAG_SET : 0; \ |
| 852 | | SET_REG_YA(cpustate, (((TMP1 >> 9) & 0xff) << 8) + (TMP1 & 0xff)); \ |
| 814 | SET_REG_YA((((TMP1 >> 9) & 0xff) << 8) + (TMP1 & 0xff)); \ |
| 853 | 815 | FLAG_NZ = MAKE_UINT_8(GET_REG_YA()); |
| 854 | 816 | |
| 855 | 817 | /* Enable interrupts */ |
| r26761 | r26762 | |
| 860 | 822 | /* Exclusive Or operand to accumulator */ |
| 861 | 823 | #define OP_EOR(BCLK, MODE) \ |
| 862 | 824 | CLK(BCLK); \ |
| 863 | | FLAG_NZ = REG_A ^= OPER_8_##MODE(cpustate) |
| 825 | FLAG_NZ = REG_A ^= OPER_8_##MODE() |
| 864 | 826 | |
| 865 | 827 | /* Logical EOR operand */ |
| 866 | 828 | #define OP_EORM(BCLK, SMODE, DMODE) \ |
| 867 | 829 | CLK(BCLK); \ |
| 868 | | FLAG_NZ = OPER_8_##SMODE(cpustate); \ |
| 869 | | DST = EA_##DMODE(cpustate); \ |
| 830 | FLAG_NZ = OPER_8_##SMODE(); \ |
| 831 | DST = EA_##DMODE(); \ |
| 870 | 832 | FLAG_NZ ^= read_8_##DMODE(DST); \ |
| 871 | 833 | write_8_##DMODE(DST, FLAG_NZ) |
| 872 | 834 | |
| 873 | 835 | /* Exclusive OR bit to C */ |
| 874 | 836 | #define OP_EOR1(BCLK) \ |
| 875 | 837 | CLK(BCLK); \ |
| 876 | | DST = OPER_16_IMM(cpustate); \ |
| 838 | DST = OPER_16_IMM(); \ |
| 877 | 839 | SRC = 1 << (DST >> 13); \ |
| 878 | 840 | DST &= 0x1fff; \ |
| 879 | 841 | if(read_8_NORM(DST) & SRC) \ |
| r26761 | r26762 | |
| 887 | 849 | /* Increment operand */ |
| 888 | 850 | #define OP_INCM(BCLK, MODE) \ |
| 889 | 851 | CLK(BCLK); \ |
| 890 | | DST = EA_##MODE(cpustate); \ |
| 852 | DST = EA_##MODE(); \ |
| 891 | 853 | FLAG_NZ = MAKE_UINT_8(read_8_##MODE(DST) + 1); \ |
| 892 | 854 | write_8_##MODE(DST, FLAG_NZ) |
| 893 | 855 | |
| 894 | 856 | /* Increment word */ |
| 895 | 857 | #define OP_INCW(BCLK) \ |
| 896 | 858 | CLK(BCLK); \ |
| 897 | | DST = EA_DP(cpustate); \ |
| 859 | DST = EA_DP(); \ |
| 898 | 860 | FLAG_NZ = MAKE_UINT_16(read_16_DP(DST) + 1); \ |
| 899 | 861 | write_16_DP(DST, FLAG_Z); \ |
| 900 | 862 | FLAG_NZ = NZFLAG_16(FLAG_Z) |
| r26761 | r26762 | |
| 903 | 865 | /* If we're in a busy loop, eat all clock cycles */ |
| 904 | 866 | #define OP_JMP(BCLK, MODE) \ |
| 905 | 867 | CLK(BCLK); \ |
| 906 | | JUMP(cpustate, EA_##MODE(cpustate)); \ |
| 868 | JUMP(EA_##MODE()); \ |
| 907 | 869 | if(REG_PC == REG_PPC) \ |
| 908 | 870 | CLK_ALL() |
| 909 | 871 | |
| 910 | 872 | /* Jump to Subroutine */ |
| 911 | 873 | #define OP_JSR(BCLK, MODE) \ |
| 912 | 874 | CLK(BCLK); \ |
| 913 | | PUSH_16(cpustate, REG_PC); \ |
| 914 | | JUMP(cpustate, EA_##MODE(cpustate)) |
| 875 | PUSH_16(REG_PC); \ |
| 876 | JUMP(EA_##MODE()) |
| 915 | 877 | |
| 916 | 878 | /* Logical Shift Right accumulator */ |
| 917 | 879 | #define OP_LSR(BCLK) \ |
| r26761 | r26762 | |
| 922 | 884 | /* Logical Shift Right operand */ |
| 923 | 885 | #define OP_LSRM(BCLK, MODE) \ |
| 924 | 886 | CLK(BCLK); \ |
| 925 | | DST = EA_##MODE(cpustate); \ |
| 887 | DST = EA_##MODE(); \ |
| 926 | 888 | FLAG_NZ = read_8_##MODE(DST); \ |
| 927 | 889 | FLAG_C = FLAG_NZ << 8; \ |
| 928 | 890 | FLAG_NZ >>= 1; \ |
| r26761 | r26762 | |
| 936 | 898 | /* Move from register to memory */ |
| 937 | 899 | #define OP_MOVRM(BCLK, SREG, DMODE) \ |
| 938 | 900 | CLK(BCLK); \ |
| 939 | | write_8_##DMODE(EA_##DMODE(cpustate), SREG) |
| 901 | write_8_##DMODE(EA_##DMODE(), SREG) |
| 940 | 902 | |
| 941 | 903 | /* Move from memory to register */ |
| 942 | 904 | #define OP_MOVMR(BCLK, SMODE, DREG) \ |
| 943 | 905 | CLK(BCLK); \ |
| 944 | | FLAG_NZ = DREG = OPER_8_##SMODE(cpustate) |
| 906 | FLAG_NZ = DREG = OPER_8_##SMODE() |
| 945 | 907 | |
| 946 | 908 | /* Move from memory to memory */ |
| 947 | 909 | #define OP_MOVMM(BCLK, SMODE, DMODE) \ |
| 948 | 910 | CLK(BCLK); \ |
| 949 | | SRC = OPER_8_##SMODE(cpustate); \ |
| 950 | | DST = EA_##DMODE(cpustate); \ |
| 911 | SRC = OPER_8_##SMODE(); \ |
| 912 | DST = EA_##DMODE(); \ |
| 951 | 913 | write_8_##DMODE(DST, SRC) |
| 952 | 914 | |
| 953 | 915 | /* Move word register to memory */ |
| 954 | 916 | #define OP_MOVWRM(BCLK) \ |
| 955 | 917 | CLK(BCLK); \ |
| 956 | | write_16_DP(EA_DP(cpustate), GET_REG_YA()) |
| 918 | write_16_DP(EA_DP(), GET_REG_YA()) |
| 957 | 919 | |
| 958 | 920 | /* Move word memory to register */ |
| 959 | 921 | #define OP_MOVWMR(BCLK) \ |
| 960 | 922 | CLK(BCLK); \ |
| 961 | | FLAG_NZ = OPER_16_DP(cpustate); \ |
| 962 | | SET_REG_YA(cpustate, FLAG_Z); \ |
| 923 | FLAG_NZ = OPER_16_DP(); \ |
| 924 | SET_REG_YA(FLAG_Z); \ |
| 963 | 925 | FLAG_NZ = NZFLAG_16(FLAG_Z) |
| 964 | 926 | |
| 965 | 927 | /* Move from Stack pointer to X */ |
| r26761 | r26762 | |
| 975 | 937 | /* Move bit from memory to C */ |
| 976 | 938 | #define OP_MOV1C(BCLK) \ |
| 977 | 939 | CLK(BCLK); \ |
| 978 | | DST = OPER_16_IMM(cpustate); \ |
| 940 | DST = OPER_16_IMM(); \ |
| 979 | 941 | SRC = 1 << (DST >> 13); \ |
| 980 | 942 | DST &= 0x1fff; \ |
| 981 | 943 | FLAG_C = ((read_8_NORM(DST) & SRC) != 0) << 8 |
| r26761 | r26762 | |
| 983 | 945 | /* Move bit from C to memory */ |
| 984 | 946 | #define OP_MOV1M(BCLK) \ |
| 985 | 947 | CLK(BCLK); \ |
| 986 | | DST = OPER_16_IMM(cpustate); \ |
| 948 | DST = OPER_16_IMM(); \ |
| 987 | 949 | SRC = 1 << (DST >> 13); \ |
| 988 | 950 | DST &= 0x1fff; \ |
| 989 | 951 | if(FLAG_C & CFLAG_SET) \ |
| r26761 | r26762 | |
| 1011 | 973 | /* NOT bit */ |
| 1012 | 974 | #define OP_NOT1(BCLK) \ |
| 1013 | 975 | CLK(BCLK); \ |
| 1014 | | DST = OPER_16_IMM(cpustate); \ |
| 976 | DST = OPER_16_IMM(); \ |
| 1015 | 977 | SRC = 1 << (DST >> 13); \ |
| 1016 | 978 | DST &= 0x1fff; \ |
| 1017 | 979 | write_8_NORM(DST, read_8_NORM(DST) ^ SRC) |
| r26761 | r26762 | |
| 1019 | 981 | /* Logical OR operand to accumulator */ |
| 1020 | 982 | #define OP_OR(BCLK, MODE) \ |
| 1021 | 983 | CLK(BCLK); \ |
| 1022 | | FLAG_NZ = REG_A |= OPER_8_##MODE(cpustate) |
| 984 | FLAG_NZ = REG_A |= OPER_8_##MODE() |
| 1023 | 985 | |
| 1024 | 986 | /* Logical OR operand */ |
| 1025 | 987 | #define OP_ORM(BCLK, SMODE, DMODE) \ |
| 1026 | 988 | CLK(BCLK); \ |
| 1027 | | FLAG_NZ = OPER_8_##SMODE(cpustate); \ |
| 1028 | | DST = EA_##DMODE(cpustate); \ |
| 989 | FLAG_NZ = OPER_8_##SMODE(); \ |
| 990 | DST = EA_##DMODE(); \ |
| 1029 | 991 | FLAG_NZ |= read_8_##DMODE(DST); \ |
| 1030 | 992 | write_8_##DMODE(DST, FLAG_NZ) |
| 1031 | 993 | |
| 1032 | 994 | /* Logical OR bit to C */ |
| 1033 | 995 | #define OP_OR1(BCLK) \ |
| 1034 | 996 | CLK(BCLK); \ |
| 1035 | | DST = EA_IMM16(cpustate); \ |
| 997 | DST = EA_IMM16(); \ |
| 1036 | 998 | if(!(FLAG_C & CFLAG_SET)) \ |
| 1037 | 999 | { \ |
| 1038 | 1000 | DST = read_16_IMM(DST); \ |
| r26761 | r26762 | |
| 1045 | 1007 | /* OR negated bit to C */ |
| 1046 | 1008 | #define OP_ORN1(BCLK) \ |
| 1047 | 1009 | CLK(BCLK); \ |
| 1048 | | DST = EA_IMM16(cpustate); \ |
| 1010 | DST = EA_IMM16(); \ |
| 1049 | 1011 | if(!(FLAG_C & CFLAG_SET)) \ |
| 1050 | 1012 | { \ |
| 1051 | 1013 | DST = read_16_IMM(DST); \ |
| r26761 | r26762 | |
| 1058 | 1020 | /* UPage Call */ |
| 1059 | 1021 | #define OP_PCALL(BCLK) \ |
| 1060 | 1022 | CLK(BCLK); \ |
| 1061 | | DST = EA_DP(cpustate); \ |
| 1062 | | PUSH_16(cpustate, REG_PC); \ |
| 1063 | | JUMP(cpustate, 0xff00 | DST) |
| 1023 | DST = EA_DP(); \ |
| 1024 | PUSH_16(REG_PC); \ |
| 1025 | JUMP(0xff00 | DST) |
| 1064 | 1026 | |
| 1065 | 1027 | /* Push a register to the stack */ |
| 1066 | 1028 | #define OP_PUSH(BCLK, REG) \ |
| 1067 | 1029 | CLK(BCLK); \ |
| 1068 | | PUSH_8(cpustate, REG) |
| 1030 | PUSH_8(REG) |
| 1069 | 1031 | |
| 1070 | 1032 | /* Push the Processor Status Register to the stack */ |
| 1071 | 1033 | #define OP_PHP(BCLK) \ |
| 1072 | 1034 | CLK(BCLK); \ |
| 1073 | | PUSH_8(cpustate, GET_REG_P()) |
| 1035 | PUSH_8(GET_REG_P()) |
| 1074 | 1036 | |
| 1075 | 1037 | /* Pull a register from the stack */ |
| 1076 | 1038 | #define OP_PULL(BCLK, REG) \ |
| 1077 | 1039 | CLK(BCLK); \ |
| 1078 | | REG = PULL_8(cpustate) |
| 1040 | REG = PULL_8() |
| 1079 | 1041 | |
| 1080 | 1042 | /* Pull the Processor Status Register from the stack */ |
| 1081 | 1043 | #define OP_PLP(BCLK) \ |
| 1082 | 1044 | CLK(BCLK); \ |
| 1083 | | SET_REG_P(cpustate, PULL_8(cpustate)) |
| 1045 | SET_REG_P(PULL_8()) |
| 1084 | 1046 | |
| 1085 | 1047 | /* Return from Subroutine */ |
| 1086 | 1048 | #define OP_RET(BCLK) \ |
| 1087 | 1049 | CLK(BCLK); \ |
| 1088 | | JUMP(cpustate, PULL_16(cpustate)) |
| 1050 | JUMP(PULL_16()) |
| 1089 | 1051 | |
| 1090 | 1052 | /* Return from Interrupt */ |
| 1091 | 1053 | #define OP_RETI(BCLK) \ |
| 1092 | 1054 | CLK(BCLK); \ |
| 1093 | | SET_REG_P(cpustate, PULL_8(cpustate)); \ |
| 1094 | | JUMP(cpustate, PULL_16(cpustate)) |
| 1055 | SET_REG_P(PULL_8()); \ |
| 1056 | JUMP(PULL_16()) |
| 1095 | 1057 | |
| 1096 | 1058 | /* Rotate Left the accumulator */ |
| 1097 | 1059 | #define OP_ROL(BCLK) \ |
| r26761 | r26762 | |
| 1102 | 1064 | /* Rotate Left an operand */ |
| 1103 | 1065 | #define OP_ROLM(BCLK, MODE) \ |
| 1104 | 1066 | CLK(BCLK); \ |
| 1105 | | DST = EA_##MODE(cpustate); \ |
| 1067 | DST = EA_##MODE(); \ |
| 1106 | 1068 | FLAG_C = (read_8_##MODE(DST)<<1) | CFLAG_AS_1(); \ |
| 1107 | 1069 | FLAG_NZ = MAKE_UINT_8(FLAG_C); \ |
| 1108 | 1070 | write_8_##MODE(DST, FLAG_NZ) |
| r26761 | r26762 | |
| 1117 | 1079 | /* Rotate Right an operand */ |
| 1118 | 1080 | #define OP_RORM(BCLK, MODE) \ |
| 1119 | 1081 | CLK(BCLK); \ |
| 1120 | | DST = EA_##MODE(cpustate); \ |
| 1082 | DST = EA_##MODE(); \ |
| 1121 | 1083 | FLAG_NZ = read_8_##MODE(DST) | (FLAG_C & 0x100); \ |
| 1122 | 1084 | FLAG_C = FLAG_NZ << 8; \ |
| 1123 | 1085 | FLAG_NZ >>= 1; \ |
| r26761 | r26762 | |
| 1126 | 1088 | /* Subtract with Carry */ |
| 1127 | 1089 | #define OP_SBC(BCLK, MODE) \ |
| 1128 | 1090 | CLK(BCLK); \ |
| 1129 | | SRC = OPER_8_##MODE(cpustate); \ |
| 1091 | SRC = OPER_8_##MODE(); \ |
| 1130 | 1092 | TMP2 = REG_A - SRC - (CFLAG_AS_1() ^ 1); \ |
| 1131 | 1093 | SUBOP_ADC(REG_A, ~SRC); \ |
| 1132 | 1094 | FLAG_C = (TMP2 <= 0xff) ? CFLAG_SET : 0; \ |
| 1133 | | REG_A = (UINT8)cpustate->spc_int16; |
| 1095 | REG_A = (UINT8)m_spc_int16; |
| 1134 | 1096 | |
| 1135 | 1097 | /* Subtract With Carry to memory */ |
| 1136 | 1098 | #define OP_SBCM(BCLK, SMODE, DMODE) \ |
| 1137 | 1099 | CLK(BCLK); \ |
| 1138 | | SRC = OPER_8_##SMODE(cpustate); \ |
| 1139 | | DST = EA_##DMODE(cpustate); \ |
| 1100 | SRC = OPER_8_##SMODE(); \ |
| 1101 | DST = EA_##DMODE(); \ |
| 1140 | 1102 | TMP3 = read_8_##DMODE(DST); \ |
| 1141 | 1103 | TMP2 = TMP3 - SRC - (CFLAG_AS_1() ^ 1); \ |
| 1142 | 1104 | SUBOP_ADC(~SRC, TMP3); \ |
| 1143 | 1105 | FLAG_C = (TMP2 <= 0xff) ? CFLAG_SET : 0; \ |
| 1144 | | write_8_##DMODE(DST, (UINT8)cpustate->spc_int16) |
| 1106 | write_8_##DMODE(DST, (UINT8)m_spc_int16) |
| 1145 | 1107 | |
| 1146 | 1108 | /* Set Carry flag */ |
| 1147 | 1109 | #define OP_SETC(BCLK) \ |
| r26761 | r26762 | |
| 1156 | 1118 | /* Set Memory Bit */ |
| 1157 | 1119 | #define OP_SET(BCLK, BIT) \ |
| 1158 | 1120 | CLK(BCLK); \ |
| 1159 | | DST = EA_DP(cpustate); \ |
| 1121 | DST = EA_DP(); \ |
| 1160 | 1122 | SRC = read_8_DP(DST) | BIT; \ |
| 1161 | 1123 | write_8_DP(DST, SRC) |
| 1162 | 1124 | |
| r26761 | r26762 | |
| 1175 | 1137 | /* Subtract word */ |
| 1176 | 1138 | #define OP_SUBW(BCLK) \ |
| 1177 | 1139 | CLK(BCLK); \ |
| 1178 | | SRC = OPER_16_DP(cpustate); \ |
| 1140 | SRC = OPER_16_DP(); \ |
| 1179 | 1141 | DST = GET_REG_YA(); \ |
| 1180 | 1142 | TMP1 = ((DST) & 0xff) - ((SRC) & 0xff); \ |
| 1181 | 1143 | TMP2 = (TMP1 > 0xff) ? 1 : 0; \ |
| 1182 | 1144 | TMP3 = ((DST) >> 8) - ((SRC) >> 8) - TMP2; \ |
| 1183 | | cpustate->spc_int16 = ((TMP1 & 0xff) + (TMP3 << 8)) & 0xffff; \ |
| 1145 | m_spc_int16 = ((TMP1 & 0xff) + (TMP3 << 8)) & 0xffff; \ |
| 1184 | 1146 | FLAG_C = (TMP3 <= 0xff) ? CFLAG_SET : 0; \ |
| 1185 | 1147 | FLAG_H = ((unsigned) ((((DST) >> 8) & 0x0F) - \ |
| 1186 | 1148 | (((SRC) >> 8) & 0x0F) - TMP2)) > 0x0F ? 0: HFLAG_SET; \ |
| 1187 | | FLAG_V = (((DST) ^ (SRC)) & ((DST) ^ (UINT16) cpustate->spc_int16) & 0x8000) ? VFLAG_SET : 0; \ |
| 1188 | | FLAG_Z = (cpustate->spc_int16 != 0); \ |
| 1189 | | FLAG_N = (cpustate->spc_int16>>8); \ |
| 1190 | | SET_REG_YA(cpustate, cpustate->spc_int16); |
| 1149 | FLAG_V = (((DST) ^ (SRC)) & ((DST) ^ (UINT16) m_spc_int16) & 0x8000) ? VFLAG_SET : 0; \ |
| 1150 | FLAG_Z = (m_spc_int16 != 0); \ |
| 1151 | FLAG_N = (m_spc_int16>>8); \ |
| 1152 | SET_REG_YA(m_spc_int16); |
| 1191 | 1153 | |
| 1192 | 1154 | /* Table Call */ |
| 1193 | 1155 | #define OP_TCALL(BCLK, NUM) \ |
| 1194 | 1156 | CLK(BCLK); \ |
| 1195 | | PUSH_16(cpustate, REG_PC); \ |
| 1196 | | JUMP(cpustate, read_16_NORM(0xffc0 + ((15-NUM)<<1))) |
| 1157 | PUSH_16(REG_PC); \ |
| 1158 | JUMP(read_16_NORM(0xffc0 + ((15-NUM)<<1))) |
| 1197 | 1159 | |
| 1198 | 1160 | /* Test and Clear Bits */ |
| 1199 | 1161 | #define OP_TCLR1(BCLK, MODE) \ |
| 1200 | 1162 | CLK(BCLK); \ |
| 1201 | | DST = EA_##MODE(cpustate); \ |
| 1163 | DST = EA_##MODE(); \ |
| 1202 | 1164 | FLAG_NZ = read_8_##MODE(DST); \ |
| 1203 | 1165 | write_8_##MODE(DST, FLAG_NZ & ~REG_A); \ |
| 1204 | 1166 | FLAG_NZ &= REG_A |
| r26761 | r26762 | |
| 1206 | 1168 | /* Test and Set Bits */ |
| 1207 | 1169 | #define OP_TSET1(BCLK, MODE) \ |
| 1208 | 1170 | CLK(BCLK); \ |
| 1209 | | DST = EA_##MODE(cpustate); \ |
| 1171 | DST = EA_##MODE(); \ |
| 1210 | 1172 | FLAG_NZ = read_8_##MODE(DST); \ |
| 1211 | 1173 | write_8_##MODE(DST, FLAG_NZ | REG_A); \ |
| 1212 | 1174 | FLAG_NZ &= REG_A |
| r26761 | r26762 | |
| 1224 | 1186 | /* ================================= API ================================== */ |
| 1225 | 1187 | /* ======================================================================== */ |
| 1226 | 1188 | |
| 1227 | | static void state_register( legacy_cpu_device *device ) |
| 1189 | void spc700_device::device_start() |
| 1228 | 1190 | { |
| 1229 | | spc700i_cpu *cpustate = get_safe_token(device); |
| 1191 | m_program = &space(AS_PROGRAM); |
| 1230 | 1192 | |
| 1231 | | device->save_item(NAME(cpustate->a)); |
| 1232 | | device->save_item(NAME(cpustate->x)); |
| 1233 | | device->save_item(NAME(cpustate->y)); |
| 1234 | | device->save_item(NAME(cpustate->s)); |
| 1235 | | device->save_item(NAME(cpustate->pc)); |
| 1236 | | device->save_item(NAME(cpustate->ppc)); |
| 1237 | | device->save_item(NAME(cpustate->flag_n)); |
| 1238 | | device->save_item(NAME(cpustate->flag_z)); |
| 1239 | | device->save_item(NAME(cpustate->flag_v)); |
| 1240 | | device->save_item(NAME(cpustate->flag_p)); |
| 1241 | | device->save_item(NAME(cpustate->flag_b)); |
| 1242 | | device->save_item(NAME(cpustate->flag_h)); |
| 1243 | | device->save_item(NAME(cpustate->flag_i)); |
| 1244 | | device->save_item(NAME(cpustate->flag_c)); |
| 1245 | | device->save_item(NAME(cpustate->line_irq)); |
| 1246 | | device->save_item(NAME(cpustate->line_nmi)); |
| 1247 | | device->save_item(NAME(cpustate->line_rst)); |
| 1248 | | device->save_item(NAME(cpustate->ir)); |
| 1249 | | device->save_item(NAME(cpustate->stopped)); |
| 1250 | | device->save_item(NAME(cpustate->ICount)); |
| 1251 | | device->save_item(NAME(cpustate->source)); |
| 1252 | | device->save_item(NAME(cpustate->destination)); |
| 1253 | | device->save_item(NAME(cpustate->temp1)); |
| 1254 | | device->save_item(NAME(cpustate->temp2)); |
| 1255 | | device->save_item(NAME(cpustate->temp3)); |
| 1256 | | device->save_item(NAME(cpustate->spc_int16)); |
| 1257 | | device->save_item(NAME(cpustate->spc_int32)); |
| 1193 | save_item(NAME(m_a)); |
| 1194 | save_item(NAME(m_x)); |
| 1195 | save_item(NAME(m_y)); |
| 1196 | save_item(NAME(m_s)); |
| 1197 | save_item(NAME(m_pc)); |
| 1198 | save_item(NAME(m_ppc)); |
| 1199 | save_item(NAME(m_flag_n)); |
| 1200 | save_item(NAME(m_flag_z)); |
| 1201 | save_item(NAME(m_flag_v)); |
| 1202 | save_item(NAME(m_flag_p)); |
| 1203 | save_item(NAME(m_flag_b)); |
| 1204 | save_item(NAME(m_flag_h)); |
| 1205 | save_item(NAME(m_flag_i)); |
| 1206 | save_item(NAME(m_flag_c)); |
| 1207 | save_item(NAME(m_line_irq)); |
| 1208 | save_item(NAME(m_line_nmi)); |
| 1209 | save_item(NAME(m_line_rst)); |
| 1210 | save_item(NAME(m_ir)); |
| 1211 | save_item(NAME(m_stopped)); |
| 1212 | save_item(NAME(m_ICount)); |
| 1213 | save_item(NAME(m_source)); |
| 1214 | save_item(NAME(m_destination)); |
| 1215 | save_item(NAME(m_temp1)); |
| 1216 | save_item(NAME(m_temp2)); |
| 1217 | save_item(NAME(m_temp3)); |
| 1218 | save_item(NAME(m_spc_int16)); |
| 1219 | save_item(NAME(m_spc_int32)); |
| 1220 | |
| 1221 | // Register state for debugger |
| 1222 | state_add( SPC700_PC, "PC", m_pc ).formatstr("%04X"); |
| 1223 | state_add( SPC700_S, "S", m_s ).formatstr("%02X"); |
| 1224 | state_add( SPC700_P, "P", m_debugger_temp ).callimport().callexport().formatstr("%02X"); |
| 1225 | state_add( SPC700_A, "A", m_a ).formatstr("%02X"); |
| 1226 | state_add( SPC700_X, "X", m_x ).formatstr("%02X"); |
| 1227 | state_add( SPC700_Y, "Y", m_y ).formatstr("%02X"); |
| 1228 | |
| 1229 | state_add(STATE_GENPC, "curpc", m_pc).formatstr("%04X").noshow(); |
| 1230 | state_add(STATE_GENSP, "GENSP", m_debugger_temp).mask(0x1ff).callexport().formatstr("%04X").noshow(); |
| 1231 | state_add(STATE_GENFLAGS, "GENFLAGS", m_debugger_temp).formatstr("%8s").noshow(); |
| 1232 | state_add(STATE_GENPCBASE, "GENPCBASE", m_ppc).formatstr("%04X").noshow(); |
| 1233 | |
| 1234 | m_icountptr = &m_ICount; |
| 1258 | 1235 | } |
| 1259 | 1236 | |
| 1260 | | static CPU_INIT( spc700 ) |
| 1237 | |
| 1238 | void spc700_device::state_string_export(const device_state_entry &entry, astring &string) |
| 1261 | 1239 | { |
| 1262 | | spc700i_cpu *cpustate = get_safe_token(device); |
| 1240 | switch (entry.index()) |
| 1241 | { |
| 1242 | case STATE_GENFLAGS: |
| 1243 | string.printf("%c%c%c%c%c%c%c%c", |
| 1244 | (m_flag_n & 0x80) ? 'N':'.', |
| 1245 | ((m_flag_v & 0x80) >> 1) ? 'V':'.', |
| 1246 | (m_flag_p>>3) ? 'P':'.', |
| 1247 | (m_flag_b) ? 'B':'.', |
| 1248 | (m_flag_h & HFLAG_SET) ? 'H':'.', |
| 1249 | ( m_flag_i) ? 'I':'.', |
| 1250 | ((!m_flag_z) << 1) ? 'Z':'.', |
| 1251 | ((m_flag_c >> 8)&1) ? 'C':'.' |
| 1252 | ); |
| 1253 | break; |
| 1254 | } |
| 1255 | } |
| 1263 | 1256 | |
| 1264 | | state_register(device); |
| 1265 | 1257 | |
| 1266 | | INT_ACK = irqcallback; |
| 1267 | | cpustate->device = device; |
| 1268 | | cpustate->program = &device->space(AS_PROGRAM); |
| 1258 | void spc700_device::state_import(const device_state_entry &entry) |
| 1259 | { |
| 1260 | switch (entry.index()) |
| 1261 | { |
| 1262 | case SPC700_P: |
| 1263 | SET_REG_P(m_debugger_temp); |
| 1264 | break; |
| 1265 | } |
| 1269 | 1266 | } |
| 1270 | 1267 | |
| 1271 | 1268 | |
| 1272 | | static CPU_RESET( spc700 ) |
| 1269 | void spc700_device::state_export(const device_state_entry &entry) |
| 1273 | 1270 | { |
| 1274 | | spc700i_cpu *cpustate = get_safe_token(device); |
| 1271 | switch (entry.index()) |
| 1272 | { |
| 1273 | case SPC700_P: |
| 1274 | m_debugger_temp = ((m_flag_n & 0x80) | |
| 1275 | ((m_flag_v & 0x80) >> 1) | |
| 1276 | m_flag_p>>3 | |
| 1277 | m_flag_b | |
| 1278 | (m_flag_h & HFLAG_SET) | |
| 1279 | m_flag_i | |
| 1280 | ((!m_flag_z) << 1) | |
| 1281 | ((m_flag_c >> 8)&1)); |
| 1282 | break; |
| 1275 | 1283 | |
| 1284 | case STATE_GENSP: |
| 1285 | m_debugger_temp = m_s + STACK_PAGE; |
| 1286 | break; |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | |
| 1291 | void spc700_device::device_reset() |
| 1292 | { |
| 1276 | 1293 | CPU_STOPPED = 0; |
| 1277 | | #if !SPC700_OPTIMIZE_SNES |
| 1278 | 1294 | LINE_IRQ = 0; |
| 1279 | 1295 | LINE_NMI = 0; |
| 1280 | | #endif /* SPC700_OPTIMIZE_SNES */ |
| 1281 | 1296 | REG_S = 0; |
| 1282 | 1297 | FLAG_NZ = NZFLAG_CLEAR; |
| 1283 | 1298 | FLAG_V = VFLAG_CLEAR; |
| r26761 | r26762 | |
| 1286 | 1301 | FLAG_H = HFLAG_CLEAR; |
| 1287 | 1302 | FLAG_I = IFLAG_CLEAR; |
| 1288 | 1303 | FLAG_C = CFLAG_CLEAR; |
| 1289 | | JUMP(cpustate, read_16_VEC(VECTOR_RST)); |
| 1304 | JUMP(read_16_VEC(VECTOR_RST)); |
| 1290 | 1305 | } |
| 1291 | 1306 | |
| 1292 | | /* Exit and clean up */ |
| 1293 | | static CPU_EXIT( spc700 ) |
| 1294 | | { |
| 1295 | | /* nothing to do yet */ |
| 1296 | | } |
| 1297 | 1307 | |
| 1298 | | |
| 1299 | | /* Assert or clear the NMI line of the CPU */ |
| 1300 | | static void spc700_set_nmi_line(spc700i_cpu *cpustate,int state) |
| 1308 | void spc700_device::execute_set_input( int inptnum, int state ) |
| 1301 | 1309 | { |
| 1302 | | #if !SPC700_OPTIMIZE_SNES |
| 1303 | | if(state == CLEAR_LINE) |
| 1304 | | LINE_NMI = 0; |
| 1305 | | else if(!LINE_NMI) |
| 1310 | if ( inptnum == INPUT_LINE_NMI ) |
| 1306 | 1311 | { |
| 1307 | | LINE_NMI = 1; |
| 1308 | | CLK(7); |
| 1309 | | PUSH_16(cpustate, REG_PC); |
| 1310 | | PUSH_8(cpustate, GET_REG_P()); |
| 1311 | | JUMP(cpustate, read_16_VEC(VECTOR_NMI)); |
| 1312 | | } |
| 1312 | /* Assert or clear the NMI line of the CPU */ |
| 1313 | #if !SPC700_OPTIMIZE_SNES |
| 1314 | if(state == CLEAR_LINE) |
| 1315 | LINE_NMI = 0; |
| 1316 | else if(!LINE_NMI) |
| 1317 | { |
| 1318 | LINE_NMI = 1; |
| 1319 | CLK(7); |
| 1320 | PUSH_16(REG_PC); |
| 1321 | PUSH_8(GET_REG_P()); |
| 1322 | JUMP(read_16_VEC(VECTOR_NMI)); |
| 1323 | } |
| 1313 | 1324 | #endif /* SPC700_OPTIMIZE_SNES */ |
| 1314 | | } |
| 1315 | | |
| 1316 | | /* Assert or clear the IRQ line of the CPU */ |
| 1317 | | static void spc700_set_irq_line(spc700i_cpu *cpustate,int line, int state) |
| 1318 | | { |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | /* Assert or clear the IRQ line of the CPU */ |
| 1319 | 1329 | #if !SPC700_OPTIMIZE_SNES |
| 1320 | | LINE_IRQ = (state != CLEAR_LINE) ? IRQ_SET : IRQ_CLEAR; |
| 1321 | | CHECK_IRQ(); |
| 1330 | LINE_IRQ = (state != CLEAR_LINE) ? IRQ_SET : IRQ_CLEAR; |
| 1331 | CHECK_IRQ(); |
| 1322 | 1332 | #endif /* SPC700_OPTIMIZE_SNES */ |
| 1333 | } |
| 1323 | 1334 | } |
| 1324 | 1335 | |
| 1325 | 1336 | #include "spc700ds.h" |
| 1326 | 1337 | |
| 1338 | offs_t spc700_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) |
| 1339 | { |
| 1340 | return CPU_DISASSEMBLE_NAME(spc700)(this, buffer, pc, oprom, opram, options); |
| 1341 | } |
| 1342 | |
| 1327 | 1343 | //int dump_flag = 0; |
| 1328 | 1344 | |
| 1329 | 1345 | /* Execute instructions for <clocks> cycles */ |
| 1330 | | static CPU_EXECUTE( spc700 ) |
| 1346 | void spc700_device::execute_run() |
| 1331 | 1347 | { |
| 1332 | | spc700i_cpu *cpustate = get_safe_token(device); |
| 1333 | | |
| 1334 | 1348 | if (CPU_STOPPED) |
| 1335 | 1349 | { |
| 1336 | 1350 | CLOCKS = 0; |
| r26761 | r26762 | |
| 1339 | 1353 | while(CLOCKS > 0) |
| 1340 | 1354 | { |
| 1341 | 1355 | REG_PPC = REG_PC; |
| 1342 | | debugger_instruction_hook(device, REG_PC); |
| 1356 | debugger_instruction_hook(this, REG_PC); |
| 1343 | 1357 | REG_PC++; |
| 1344 | 1358 | |
| 1345 | | switch(REG_IR = read_8_immediate(cpustate, REG_PPC)) |
| 1359 | switch(REG_IR = read_8_immediate(REG_PPC)) |
| 1346 | 1360 | { |
| 1347 | 1361 | case 0x00: OP_NOP ( 2 ); break; /* NOP */ |
| 1348 | 1362 | case 0x01: OP_TCALL ( 8, 0 ); break; /* TCALL 0 */ |
| r26761 | r26762 | |
| 1664 | 1678 | } |
| 1665 | 1679 | } |
| 1666 | 1680 | |
| 1667 | | |
| 1668 | | /************************************************************************** |
| 1669 | | * Generic set_info |
| 1670 | | **************************************************************************/ |
| 1671 | | |
| 1672 | | static CPU_SET_INFO( spc700 ) |
| 1673 | | { |
| 1674 | | spc700i_cpu *cpustate = get_safe_token(device); |
| 1675 | | |
| 1676 | | switch (state) |
| 1677 | | { |
| 1678 | | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 1679 | | case CPUINFO_INT_INPUT_STATE + 0: spc700_set_irq_line(cpustate, 0, info->i); break; |
| 1680 | | case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI: spc700_set_nmi_line(cpustate, info->i); break; |
| 1681 | | |
| 1682 | | case CPUINFO_INT_PC: |
| 1683 | | case CPUINFO_INT_REGISTER + SPC700_PC: REG_PC = MAKE_UINT_16(info->i); break; |
| 1684 | | case CPUINFO_INT_SP: |
| 1685 | | case CPUINFO_INT_REGISTER + SPC700_S: REG_S = MAKE_UINT_8(info->i); break; |
| 1686 | | case CPUINFO_INT_REGISTER + SPC700_P: SET_REG_P(cpustate, info->i); break; |
| 1687 | | case CPUINFO_INT_REGISTER + SPC700_A: REG_A = MAKE_UINT_8(info->i); break; |
| 1688 | | case CPUINFO_INT_REGISTER + SPC700_X: REG_X = MAKE_UINT_8(info->i); break; |
| 1689 | | case CPUINFO_INT_REGISTER + SPC700_Y: REG_Y = MAKE_UINT_8(info->i); break; |
| 1690 | | } |
| 1691 | | } |
| 1692 | | |
| 1693 | | |
| 1694 | | |
| 1695 | | /************************************************************************** |
| 1696 | | * Generic get_info |
| 1697 | | **************************************************************************/ |
| 1698 | | |
| 1699 | | CPU_GET_INFO( spc700 ) |
| 1700 | | { |
| 1701 | | spc700i_cpu *cpustate = (device != NULL && device->token() != NULL) ? get_safe_token(device) : NULL; |
| 1702 | | uint p = 0; |
| 1703 | | |
| 1704 | | if (cpustate != NULL) |
| 1705 | | { |
| 1706 | | p = ((cpustate->flag_n & 0x80) | |
| 1707 | | ((cpustate->flag_v & 0x80) >> 1) | |
| 1708 | | cpustate->flag_p>>3 | |
| 1709 | | cpustate->flag_b | |
| 1710 | | (cpustate->flag_h & HFLAG_SET) | |
| 1711 | | cpustate->flag_i | |
| 1712 | | ((!cpustate->flag_z) << 1) | |
| 1713 | | ((cpustate->flag_c >> 8)&1)); |
| 1714 | | } |
| 1715 | | |
| 1716 | | switch (state) |
| 1717 | | { |
| 1718 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1719 | | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(spc700i_cpu); break; |
| 1720 | | case CPUINFO_INT_INPUT_LINES: info->i = 1; break; |
| 1721 | | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; |
| 1722 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 1723 | | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; |
| 1724 | | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break; |
| 1725 | | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break; |
| 1726 | | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 3; break; |
| 1727 | | case CPUINFO_INT_MIN_CYCLES: info->i = 2; break; |
| 1728 | | case CPUINFO_INT_MAX_CYCLES: info->i = 8; break; |
| 1729 | | |
| 1730 | | case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM: info->i = 8; break; |
| 1731 | | case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM: info->i = 16; break; |
| 1732 | | case CPUINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM: info->i = 0; break; |
| 1733 | | case CPUINFO_INT_DATABUS_WIDTH + AS_DATA: info->i = 0; break; |
| 1734 | | case CPUINFO_INT_ADDRBUS_WIDTH + AS_DATA: info->i = 0; break; |
| 1735 | | case CPUINFO_INT_ADDRBUS_SHIFT + AS_DATA: info->i = 0; break; |
| 1736 | | case CPUINFO_INT_DATABUS_WIDTH + AS_IO: info->i = 0; break; |
| 1737 | | case CPUINFO_INT_ADDRBUS_WIDTH + AS_IO: info->i = 0; break; |
| 1738 | | case CPUINFO_INT_ADDRBUS_SHIFT + AS_IO: info->i = 0; break; |
| 1739 | | |
| 1740 | | case CPUINFO_INT_INPUT_STATE + 0: info->i = (LINE_IRQ == IRQ_SET) ? ASSERT_LINE : CLEAR_LINE; break; |
| 1741 | | |
| 1742 | | case CPUINFO_INT_PREVIOUSPC: info->i = REG_PPC; break; |
| 1743 | | |
| 1744 | | case CPUINFO_INT_PC: |
| 1745 | | case CPUINFO_INT_REGISTER + SPC700_PC: info->i = REG_PC; break; |
| 1746 | | case CPUINFO_INT_SP: |
| 1747 | | case CPUINFO_INT_REGISTER + SPC700_S: info->i = REG_S + STACK_PAGE; break; |
| 1748 | | case CPUINFO_INT_REGISTER + SPC700_P: info->i = GET_REG_P(); break; |
| 1749 | | case CPUINFO_INT_REGISTER + SPC700_A: info->i = REG_A; break; |
| 1750 | | case CPUINFO_INT_REGISTER + SPC700_X: info->i = REG_X; break; |
| 1751 | | case CPUINFO_INT_REGISTER + SPC700_Y: info->i = REG_Y; break; |
| 1752 | | |
| 1753 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1754 | | case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(spc700); break; |
| 1755 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(spc700); break; |
| 1756 | | case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(spc700); break; |
| 1757 | | case CPUINFO_FCT_EXIT: info->exit = CPU_EXIT_NAME(spc700); break; |
| 1758 | | case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(spc700); break; |
| 1759 | | case CPUINFO_FCT_BURN: info->burn = NULL; break; |
| 1760 | | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(spc700); break; |
| 1761 | | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->ICount; break; |
| 1762 | | |
| 1763 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1764 | | case CPUINFO_STR_NAME: strcpy(info->s, "SPC700"); break; |
| 1765 | | case CPUINFO_STR_SHORTNAME: strcpy(info->s, "spc700"); break; |
| 1766 | | case CPUINFO_STR_FAMILY: strcpy(info->s, "Sony SPC700"); break; |
| 1767 | | case CPUINFO_STR_VERSION: strcpy(info->s, "1.1"); break; |
| 1768 | | case CPUINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1769 | | case CPUINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME team, all rights reserved."); break; |
| 1770 | | |
| 1771 | | case CPUINFO_STR_FLAGS: |
| 1772 | | sprintf(info->s, "%c%c%c%c%c%c%c%c", |
| 1773 | | p & 0x80 ? 'N':'.', |
| 1774 | | p & 0x40 ? 'V':'.', |
| 1775 | | p & 0x20 ? 'P':'.', |
| 1776 | | p & 0x10 ? 'B':'.', |
| 1777 | | p & 0x08 ? 'H':'.', |
| 1778 | | p & 0x04 ? 'I':'.', |
| 1779 | | p & 0x02 ? 'Z':'.', |
| 1780 | | p & 0x01 ? 'C':'.'); |
| 1781 | | break; |
| 1782 | | |
| 1783 | | case CPUINFO_STR_REGISTER + SPC700_PC: sprintf(info->s, "PC:%04X", cpustate->pc); break; |
| 1784 | | case CPUINFO_STR_REGISTER + SPC700_S: sprintf(info->s, "S:%02X", cpustate->s); break; |
| 1785 | | case CPUINFO_STR_REGISTER + SPC700_P: sprintf(info->s, "P:%02X", p); break; |
| 1786 | | case CPUINFO_STR_REGISTER + SPC700_A: sprintf(info->s, "A:%02X", cpustate->a); break; |
| 1787 | | case CPUINFO_STR_REGISTER + SPC700_X: sprintf(info->s, "X:%02X", cpustate->x); break; |
| 1788 | | case CPUINFO_STR_REGISTER + SPC700_Y: sprintf(info->s, "Y:%02X", cpustate->y); break; |
| 1789 | | } |
| 1790 | | } |
| 1791 | | |
| 1792 | | DEFINE_LEGACY_CPU_DEVICE(SPC700, spc700); |
| 1793 | | |
| 1794 | 1681 | /* ======================================================================== */ |
| 1795 | 1682 | /* ============================== END OF FILE ============================= */ |
| 1796 | 1683 | /* ======================================================================== */ |