X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fm68000%2Fcpuextra.c;h=e98f1da8120f957a220e2d69898064165add532e;hb=a0fe543d62fa18a83c2c7d99d483ab5ea0f321b4;hp=b29860cc1c9d7da0e76dcd3455d64134d4b74789;hpb=b86a1645ad3fdedf85202c5563c2c5fc1e0eb03d;p=virtualjaguar diff --git a/src/m68000/cpuextra.c b/src/m68000/cpuextra.c index b29860c..e98f1da 100644 --- a/src/m68000/cpuextra.c +++ b/src/m68000/cpuextra.c @@ -21,6 +21,7 @@ int CurrentInstrCycles; struct regstruct regs; + // // Make displacement effective address for 68000 // @@ -51,6 +52,7 @@ uint32_t get_disp_ea_000(uint32_t base, uint32_t dp) #endif } + // // Create the Status Register from the flags // @@ -60,6 +62,7 @@ void MakeSR(void) | (GET_NFLG << 3) | (GET_ZFLG << 2) | (GET_VFLG << 1) | GET_CFLG); } + // // Set up the flags from Status Register // @@ -94,6 +97,7 @@ void MakeFromSR(void) // set_special(SPCFLAG_DOINT); } + // // Rudimentary exception handling. This is really stripped down from what // was in Hatari. @@ -106,18 +110,70 @@ NB: Seems that when an address exception occurs, it doesn't get handled properly // on Atari ST, because it's possible to change the MFP's vector base // and get a conflict with 'normal' cpu exceptions. // +#if 0 +/* +This is the STOP # function. Dunno if exception handling occurs when it hits here or not, because don't know if the regs.s bit is set or not! +Seems to be... + +SR----------------- +1111 11 +5432 1098 7654 3210 +---- ---- ---- ---- + 1 1 + + +*/ +unsigned long CPUFUNC(op_4e72_5)(uint32_t opcode) /* STOP */ +{ + OpcodeFamily = 44; + CurrentInstrCycles = 4; + + if (!regs.s) + { + Exception(8, 0, M68000_EXC_SRC_CPU); + } + else + { + int16_t src = get_iword_prefetch(2); + regs.sr = src; + MakeFromSR(); + m68k_setstopped(1); + m68k_incpc(4); + fill_prefetch_0(); + } + + return 4; +} +#endif +//tmp... +void WriteLog(const char * text, ...); void Exception(int nr, uint32_t oldpc, int ExceptionSource) { -printf("Exception #%i occurred!\n", nr); -printf("Vector @ #%i = %08X\n", nr, m68k_read_memory_32(nr * 4)); -//abort(); uint32_t currpc = m68k_getpc(), newpc; -printf("PC = $%08X\n", currpc); -printf("A0 = $%08X A1 = $%08X A2 = $%08X A3 = $%08X\n", m68k_areg(regs, 0), m68k_areg(regs, 1), m68k_areg(regs, 2), m68k_areg(regs, 3)); -printf("A4 = $%08X A5 = $%08X A6 = $%08X A7 = $%08X\n", m68k_areg(regs, 4), m68k_areg(regs, 5), m68k_areg(regs, 6), m68k_areg(regs, 7)); -printf("D0 = $%08X D1 = $%08X D2 = $%08X D3 = $%08X\n", m68k_dreg(regs, 0), m68k_dreg(regs, 1), m68k_dreg(regs, 2), m68k_dreg(regs, 3)); -printf("D4 = $%08X D5 = $%08X D6 = $%08X D7 = $%08X\n", m68k_dreg(regs, 4), m68k_dreg(regs, 5), m68k_dreg(regs, 6), m68k_dreg(regs, 7)); -printf("\n"); + +// Need to figure out how to report this stuff without using printf on stdout :-/ +#if 0 +char excNames[33][64] = { + "???", "???", "Bus Error", "Address Error", + "Illegal Instruction", "Zero Divide", "CHK", "TrapV", + "Privilege Violation", "Trace", "Line A", "Line F", + "???", "???", "Format Error", "Uninitialized Interrupt", + "???", "???", "???", "???", + "???", "???", "???", "???", + "Spurious/Autovector", "???", "???", "???", + "???", "???", "???", "???", + "Trap #" +}; + +WriteLog("Exception #%i occurred! (%s)\n", nr, (nr < 32 ? excNames[nr] : (nr < 48 ? "Trap #" : "????"))); +WriteLog("Vector @ #%i = %08X\n", nr, m68k_read_memory_32(nr * 4)); +//abort(); +WriteLog("PC = $%08X\n", currpc); +WriteLog("A0 = $%08X A1 = $%08X A2 = $%08X A3 = $%08X\n", m68k_areg(regs, 0), m68k_areg(regs, 1), m68k_areg(regs, 2), m68k_areg(regs, 3)); +WriteLog("A4 = $%08X A5 = $%08X A6 = $%08X A7 = $%08X\n", m68k_areg(regs, 4), m68k_areg(regs, 5), m68k_areg(regs, 6), m68k_areg(regs, 7)); +WriteLog("D0 = $%08X D1 = $%08X D2 = $%08X D3 = $%08X\n", m68k_dreg(regs, 0), m68k_dreg(regs, 1), m68k_dreg(regs, 2), m68k_dreg(regs, 3)); +WriteLog("D4 = $%08X D5 = $%08X D6 = $%08X D7 = $%08X\n", m68k_dreg(regs, 4), m68k_dreg(regs, 5), m68k_dreg(regs, 6), m68k_dreg(regs, 7)); +WriteLog("\n"); uint32_t disPC = currpc - 10; char buffer[128]; @@ -126,9 +182,10 @@ do { uint32_t oldpc = disPC; disPC += m68k_disassemble(buffer, disPC, 0); - printf("%s%08X: %s\n", (oldpc == currpc ? ">" : " "), oldpc, buffer); + WriteLog("%s%08X: %s\n", (oldpc == currpc ? ">" : " "), oldpc, buffer); } while (disPC < (currpc + 10)); +#endif /*if( nr>=2 && nr<10 ) fprintf(stderr,"Exception (-> %i bombs)!\n",nr);*/ @@ -305,6 +362,7 @@ while (disPC < (currpc + 10)); #endif } + /* The routines below take dividend and divisor as parameters. They return 0 if division by zero, or exact number of cycles otherwise. @@ -382,6 +440,7 @@ STATIC_INLINE int getDivu68kCycles_2 (uint32_t dividend, uint16_t divisor) return mcycles * 2; } + // This is called by cpuemu.c int getDivu68kCycles(uint32_t dividend, uint16_t divisor) { @@ -390,11 +449,11 @@ int getDivu68kCycles(uint32_t dividend, uint16_t divisor) return v; } + // // DIVS // Signed division // - STATIC_INLINE int getDivs68kCycles_2(int32_t dividend, int16_t divisor) { int mcycles; @@ -439,6 +498,7 @@ STATIC_INLINE int getDivs68kCycles_2(int32_t dividend, int16_t divisor) return mcycles * 2; } + // This is called by cpuemu.c int getDivs68kCycles(int32_t dividend, int16_t divisor) { @@ -446,3 +506,4 @@ int getDivs68kCycles(int32_t dividend, int16_t divisor) // write_log ("S%d ", v); return v; } +