mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
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:
parent
ae463c4ac4
commit
cac04c958b
@ -758,7 +758,7 @@ bool DSPAssembler::AssembleFile(const char *fname, int pass)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s: Pass %d\n", fname, pass);
|
//printf("%s: Pass %d\n", fname, pass);
|
||||||
code_line = 0;
|
code_line = 0;
|
||||||
m_cur_pass = pass;
|
m_cur_pass = pass;
|
||||||
|
|
||||||
|
@ -20,47 +20,22 @@ sub parseString {
|
|||||||
sub generateSRFull {
|
sub generateSRFull {
|
||||||
my $res = shift;
|
my $res = shift;
|
||||||
my $body = 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;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub generateTest {
|
|
||||||
my $type = shift;
|
|
||||||
my $header = shift;
|
|
||||||
my $body = shift;
|
|
||||||
|
|
||||||
if ($type eq "srfull") {
|
|
||||||
return generateSRFull($header, $body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub calculateLines {
|
sub calculateLines {
|
||||||
my $text = shift;
|
my $file = shift;
|
||||||
my $lines = 0;
|
|
||||||
my $incdir = "./";
|
|
||||||
|
|
||||||
foreach my $line (split /\n/, $text) {
|
my @lines = `dsptool -s $file`;
|
||||||
next if ($line =~ /^\S*$/);
|
$lines[0] =~ /:\s*(.*)/;
|
||||||
next if ($line =~ /^\S*;/);
|
my $lnum = $1;
|
||||||
next if ($line =~ /:/);
|
|
||||||
|
|
||||||
if ($line =~ /incdir\s*\"(.*)\"/) {
|
return $lnum;
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($cmds,$input,$output);
|
my ($cmds,$input,$output);
|
||||||
@ -83,18 +58,38 @@ foreach my $cmd (split(/,/, $cmds)) {
|
|||||||
my $desc = parseString($xtest->{'description'}, $cmd);
|
my $desc = parseString($xtest->{'description'}, $cmd);
|
||||||
|
|
||||||
my $header = parseString($xtest->{'header'}, $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 $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") ||
|
my $bsize = calculateLines("$name.tmp") - $hsize;
|
||||||
die("Can't open file $name for writing: $!\n");
|
unlink("$name.tmp");
|
||||||
|
|
||||||
print OUTPUT "; $name\n";
|
# how many tests we can fit in a ucode.
|
||||||
print OUTPUT "; $desc\n";
|
my $ucodes = int((0x1000 - $hsize) / $bsize);
|
||||||
my $test = generateTest($type, $header, $body);
|
|
||||||
print OUTPUT $test . "\n";
|
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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +214,7 @@ int main(int argc, const char *argv[])
|
|||||||
printf("-? / --help: Prints this message\n");
|
printf("-? / --help: Prints this message\n");
|
||||||
printf("-d: Disassemble\n");
|
printf("-d: Disassemble\n");
|
||||||
printf("-m: Input file contains a list of files (Header assembly only)\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("-o <OUTPUT FILE>: Results from stdout redirected to a file\n");
|
||||||
printf("-h <HEADER FILE>: Output assembly results to a header\n");
|
printf("-h <HEADER FILE>: Output assembly results to a header\n");
|
||||||
return 0;
|
return 0;
|
||||||
@ -229,7 +230,7 @@ int main(int argc, const char *argv[])
|
|||||||
std::string output_header_name;
|
std::string output_header_name;
|
||||||
std::string output_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++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (!strcmp(argv[i], "-d"))
|
if (!strcmp(argv[i], "-d"))
|
||||||
@ -240,6 +241,8 @@ int main(int argc, const char *argv[])
|
|||||||
output_header_name = argv[++i];
|
output_header_name = argv[++i];
|
||||||
else if (!strcmp(argv[i], "-c"))
|
else if (!strcmp(argv[i], "-c"))
|
||||||
compare = true;
|
compare = true;
|
||||||
|
else if (!strcmp(argv[i], "-s"))
|
||||||
|
outputSize = true;
|
||||||
else if (!strcmp(argv[i], "-m"))
|
else if (!strcmp(argv[i], "-m"))
|
||||||
multiple = true;
|
multiple = true;
|
||||||
else
|
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())) {
|
input_name.empty())) {
|
||||||
printf("ERROR: Multiple files can only be used with assembly "
|
printf("ERROR: Multiple files can only be used with assembly "
|
||||||
"and must compile a header file.\n");
|
"and must compile a header file.\n");
|
||||||
@ -352,6 +355,8 @@ int main(int argc, const char *argv[])
|
|||||||
files[i].c_str());
|
files[i].c_str());
|
||||||
lines--;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(outputSize)
|
||||||
|
printf("%s: %d\n", input_name.c_str(), code.size());
|
||||||
|
|
||||||
if (!output_name.empty())
|
if (!output_name.empty())
|
||||||
{
|
{
|
||||||
std::string binary_code;
|
std::string binary_code;
|
||||||
@ -387,6 +395,7 @@ int main(int argc, const char *argv[])
|
|||||||
source.clear();
|
source.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!outputSize)
|
||||||
printf("Assembly completed successfully!\n");
|
printf("Assembly completed successfully!\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user