Don't let ASM test crash and burn if it can't open file

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5262 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2010-04-01 05:52:17 +00:00
parent 47f6192004
commit 9cf7cb6cb8
4 changed files with 37 additions and 17 deletions

View File

@ -7,4 +7,4 @@ void initialise_fat();
void init_crap();
void end();
void end();

View File

@ -36,7 +36,8 @@ u32 inval_table[][2] = {
void Print(const char* text)
{
printf(text);
fprintf(f, text);
if(f)
fprintf(f, text);
}
void ShowModifies(u32 inst)
{
@ -93,7 +94,8 @@ void RunInstruction(u32 inst)
printf("unable to open output file\n");
printf("%s: InputNum: %d Modifies(flags): ", instructions[inst].name, instructions[inst].numInput);
fprintf(f, "%s: InputNum: %d Modifies(flags): ", instructions[inst].name, instructions[inst].numInput);
if(f)
fprintf(f, "%s: InputNum: %d Modifies(flags): ", instructions[inst].name, instructions[inst].numInput);
ShowModifies(inst);
Print("\n");
@ -101,6 +103,7 @@ void RunInstruction(u32 inst)
{
inval1 = inval_table[i][0];
inval2 = inval_table[i][1];
outval = 0;
// Show our input values and where we are at on the array
printf("\x1b[%i;0H", i);
@ -138,13 +141,16 @@ void RunInstruction(u32 inst)
// same in the file
fprintf(f, ":i=%08x, %08x:o=%08x\n\t", inval1,inval2, outval);
if(modCR0)
fprintf(f, "CR0:(%08x ~ %08x)", cr1,cr2);
if(modCR1)
fprintf(f, "CR1:(%08x ~ %08x)", cr11,cr12);
if(modXER)
fprintf(f, "XER:(%08x ~ %08x)", xer1, xer2);
if(f)
{
fprintf(f, ":i=%08x, %08x:o=%08x\n\t", inval1,inval2, outval);
if(modCR0)
fprintf(f, "CR0:(%08x ~ %08x)", cr1,cr2);
if(modCR1)
fprintf(f, "CR1:(%08x ~ %08x)", cr11,cr12);
if(modXER)
fprintf(f, "XER:(%08x ~ %08x)", xer1, xer2);
}
// see the difference in flags if any
if(modCR0)
@ -152,7 +158,8 @@ void RunInstruction(u32 inst)
u32 cr_diff = cr2&~cr1;
if (cr_diff) {
printf(" CR0D:%08x",cr_diff);
fprintf(f, " CR0D:%08x",cr_diff);
if(f)
fprintf(f, " CR0D:%08x",cr_diff);
}
}
if(modCR1)
@ -160,7 +167,8 @@ void RunInstruction(u32 inst)
u32 cr1_diff = cr12&~cr11;
if (cr1_diff) {
printf(" CR1D:%08x",cr1_diff);
fprintf(f, " CR1D:%08x",cr1_diff);
if(f)
fprintf(f, " CR1D:%08x",cr1_diff);
}
}
if(modXER)
@ -168,10 +176,13 @@ void RunInstruction(u32 inst)
u32 xer_diff = xer2&~xer1;
if (xer_diff) {
printf(" XERD:%08x",xer_diff);
fprintf(f, " XERD:%08x",xer_diff);
if(f)
fprintf(f, " XERD:%08x",xer_diff);
}
}
fprintf(f,"\n");
if(f)
fprintf(f,"\n");
}
fclose(f);
if(f)
fclose(f);
}

View File

@ -25,6 +25,16 @@
#include "asm_tables.h"
#include "Helpers.h"
#ifdef __APPLE__
void die(char *msg){}
void initialise_fat(){}
void init_crap(){}
void end(){}
#endif
FILE *f = NULL;
int main(int argc, char **argv) {

View File

@ -1,3 +1,2 @@
all:
g++ -S -arch ppc Instructions/asm_float.cpp
g++ -g -arch ppc dolphintest_asm.cpp asm_tables.cpp Helpers.cpp Instructions/asm_integer.cpp Instructions/asm_float.cpp OSX/Init.cpp -o Test
g++ -g -arch ppc dolphintest_asm.cpp asm_tables.cpp Helpers.cpp asm_integer.cpp asm_float.cpp -o Test