add ideas-style debug console printing commands

This commit is contained in:
zeromus 2009-07-01 01:27:45 +00:00
parent a57fd04002
commit 5a0f4d989a
4 changed files with 39 additions and 2 deletions

View File

@ -7726,8 +7726,16 @@ TEMPLATE static u32 FASTCALL OP_MRC()
//--------------SWI------------------------------- //--------------SWI-------------------------------
TEMPLATE static u32 FASTCALL OP_SWI() TEMPLATE static u32 FASTCALL OP_SWI()
{ {
u32 swinum = (cpu->instruction>>16)&0xFF;
//ideas-style debug prints
if(swinum==0xFC) {
IdeasLog(cpu);
return 0;
}
if(cpu->swi_tab) { if(cpu->swi_tab) {
u32 swinum = (cpu->instruction>>16)&0x1F; swinum &= 0x1F;
return cpu->swi_tab[swinum]() + 3; return cpu->swi_tab[swinum]() + 3;
} else { } else {
/* TODO (#1#): translocated SWI vectors */ /* TODO (#1#): translocated SWI vectors */

View File

@ -21,6 +21,8 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "MMU.h"
#include "armcpu.h"
std::vector<Logger *> Logger::channels; std::vector<Logger *> Logger::channels;
@ -99,3 +101,17 @@ void Logger::log(unsigned int channel, const char * file, unsigned int line, voi
channels[channel]->setCallback(callback); channels[channel]->setCallback(callback);
} }
void IdeasLog(armcpu_t* cpu)
{
u32 adr = cpu->R[0];
printf("EMULOG%c: ",cpu->proc_ID==0?'9':'7');
for(;;) {
u8 c = MMU_read8(cpu->proc_ID,adr);
adr++;
if(!c) break;
printf("%c",c);
}
printf("\n");
}

View File

@ -24,6 +24,8 @@
#include <iostream> #include <iostream>
#include <cstdarg> #include <cstdarg>
struct armcpu_t;
class Logger { class Logger {
protected: protected:
void (*callback)(const Logger& logger, const char * format); void (*callback)(const Logger& logger, const char * format);
@ -112,4 +114,6 @@ public:
#define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) #define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__)
#define INFO(...) INFOC(10, __VA_ARGS__) #define INFO(...) INFOC(10, __VA_ARGS__)
void IdeasLog(armcpu_t* cpu);
#endif #endif

View File

@ -893,11 +893,20 @@ TEMPLATE static u32 FASTCALL OP_B_COND()
TEMPLATE static u32 FASTCALL OP_SWI_THUMB() TEMPLATE static u32 FASTCALL OP_SWI_THUMB()
{ {
u32 swinum = cpu->instruction & 0xFF;
//ideas-style debug prints
if(swinum==0xFC) {
IdeasLog(cpu);
return 0;
}
if(cpu->swi_tab) { if(cpu->swi_tab) {
//zero 25-dec-2008 - in arm, we were masking to 0x1F. //zero 25-dec-2008 - in arm, we were masking to 0x1F.
//this is probably safer since an invalid opcode could crash the emu //this is probably safer since an invalid opcode could crash the emu
//zero 30-jun-2009 - but they say that the ideas 0xFF should crash the device...
//u32 swinum = cpu->instruction & 0xFF; //u32 swinum = cpu->instruction & 0xFF;
u32 swinum = cpu->instruction & 0x1F; swinum &= 0x1F;
return cpu->swi_tab[swinum]() + 3; return cpu->swi_tab[swinum]() + 3;
} }
else { else {