More work on create test (almost working beside some annoying bug)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3451 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-06-15 16:48:34 +00:00
parent ae463c4ac4
commit cac04c958b
4 changed files with 61 additions and 57 deletions

View File

@ -758,7 +758,7 @@ bool DSPAssembler::AssembleFile(const char *fname, int pass)
return false;
}
printf("%s: Pass %d\n", fname, pass);
//printf("%s: Pass %d\n", fname, pass);
code_line = 0;
m_cur_pass = pass;

View File

@ -1,11 +1,11 @@
tests/arith_test.ds
tests/dr_test.ds
tests/mul_test.ds
tests/neg_test.ds
tests/ir_test.ds
tests/if_test.ds
tests/if_test2.ds
tests/if_test3.ds
tests/if_test4.ds
tests/if_test5.ds
tests/dsp_test.ds
tests/arith_test.ds
tests/dr_test.ds
tests/mul_test.ds
tests/neg_test.ds
tests/ir_test.ds
tests/if_test.ds
tests/if_test2.ds
tests/if_test3.ds
tests/if_test4.ds
tests/if_test5.ds
tests/dsp_test.ds

View File

@ -20,47 +20,22 @@ sub parseString {
sub generateSRFull {
my $res = shift;
my $body = shift;
my $start = shift;
my $end = shift;
$res .= join "\n", map {my $b = sprintf "\#0x%04X", $_; (my $a = $body) =~ s/\@SR\@/$b/g; $a} 1..65535;
$res .= join "\n", map {my $b = sprintf "\#0x%04X", $_; (my $a = $body) =~ s/\@SR\@/$b/g; $a} $start..$end;
return $res;
}
sub generateTest {
my $type = shift;
my $header = shift;
my $body = shift;
if ($type eq "srfull") {
return generateSRFull($header, $body);
}
}
sub calculateLines {
my $text = shift;
my $lines = 0;
my $incdir = "./";
my $file = shift;
my @lines = `dsptool -s $file`;
$lines[0] =~ /:\s*(.*)/;
my $lnum = $1;
foreach my $line (split /\n/, $text) {
next if ($line =~ /^\S*$/);
next if ($line =~ /^\S*;/);
next if ($line =~ /:/);
if ($line =~ /incdir\s*\"(.*)\"/) {
$incdir = $1;
} elsif ($line =~ /include\s*\"(.*)\"/) {
my $incname = "$incdir/$1";
open(INCLUDE, "<$incname") ||
die("Can't open include file $incname: $!\n");
my $include = join "", <INCLUDE>;
$lines += calculateLines($include);
} else {
$lines++;
}
}
return $lines;
return $lnum;
}
my ($cmds,$input,$output);
@ -83,18 +58,38 @@ foreach my $cmd (split(/,/, $cmds)) {
my $desc = parseString($xtest->{'description'}, $cmd);
my $header = parseString($xtest->{'header'}, $cmd);
my $hsize = calculateLines($header);
open(OUTPUT, ">$name.tmp");
print OUTPUT $header;
close(OUTPUT);
my $hsize = calculateLines("$name.tmp");
my $body = parseString($xtest->{'body'}, $cmd);
my $bsize = calculateLines($body);
open(OUTPUT, ">$name.tmp");
print OUTPUT generateSRFull($header, $body, 1, 1);
close(OUTPUT);
open(OUTPUT, ">$name.ds") ||
die("Can't open file $name for writing: $!\n");
my $bsize = calculateLines("$name.tmp") - $hsize;
unlink("$name.tmp");
print OUTPUT "; $name\n";
print OUTPUT "; $desc\n";
my $test = generateTest($type, $header, $body);
print OUTPUT $test . "\n";
# how many tests we can fit in a ucode.
my $ucodes = int((0x1000 - $hsize) / $bsize);
open(NAMES, ">$name.lst");
# print NAMES "; $name\n";
# print NAMES "; $desc\n";
for(my $j = 1; $j < int((0xFFFF / $ucodes)+1); $j++) {
open(OUTPUT, ">$name$j.tst");
print OUTPUT generateSRFull($header, $body, $j*$ucodes, $j*($ucodes+1));
close(OUTPUT);
print NAMES "$name$j.tst\n";
}
close(NAMES);
# my $test = generateTest($type, $header, $body);
# print OUTPUT $test . "\n";
}

View File

@ -214,6 +214,7 @@ int main(int argc, const char *argv[])
printf("-? / --help: Prints this message\n");
printf("-d: Disassemble\n");
printf("-m: Input file contains a list of files (Header assembly only)\n");
printf("-s: Print the final size in bytes (only)\n");
printf("-o <OUTPUT FILE>: Results from stdout redirected to a file\n");
printf("-h <HEADER FILE>: Output assembly results to a header\n");
return 0;
@ -229,7 +230,7 @@ int main(int argc, const char *argv[])
std::string output_header_name;
std::string output_name;
bool disassemble = false, compare = false, multiple = false;
bool disassemble = false, compare = false, multiple = false, outputSize = false;
for (int i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-d"))
@ -240,6 +241,8 @@ int main(int argc, const char *argv[])
output_header_name = argv[++i];
else if (!strcmp(argv[i], "-c"))
compare = true;
else if (!strcmp(argv[i], "-s"))
outputSize = true;
else if (!strcmp(argv[i], "-m"))
multiple = true;
else
@ -258,7 +261,7 @@ int main(int argc, const char *argv[])
}
}
if(multiple && (compare || disassemble || output_header_name.empty() ||
if(multiple && (compare || disassemble || !output_name.empty() ||
input_name.empty())) {
printf("ERROR: Multiple files can only be used with assembly "
"and must compile a header file.\n");
@ -352,6 +355,8 @@ int main(int argc, const char *argv[])
files[i].c_str());
lines--;
}
if(outputSize)
printf("%s: %d\n", files[i].c_str(), codes[i].size());
}
}
@ -370,6 +375,9 @@ int main(int argc, const char *argv[])
return 1;
}
if(outputSize)
printf("%s: %d\n", input_name.c_str(), code.size());
if (!output_name.empty())
{
std::string binary_code;
@ -387,7 +395,8 @@ int main(int argc, const char *argv[])
source.clear();
}
printf("Assembly completed successfully!\n");
if(!outputSize)
printf("Assembly completed successfully!\n");
return 0;
}