mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-14 00:58:51 +02:00
dsptool: add -f option (errors are not critical)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3847 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -26,14 +26,15 @@
|
|||||||
#include "disassemble.h"
|
#include "disassemble.h"
|
||||||
|
|
||||||
|
|
||||||
bool Assemble(const char *text, std::vector<u16> &code)
|
bool Assemble(const char *text, std::vector<u16> &code, bool force)
|
||||||
{
|
{
|
||||||
AssemblerSettings settings;
|
AssemblerSettings settings;
|
||||||
settings.pc = 0;
|
// settings.pc = 0;
|
||||||
// settings.decode_registers = false;
|
// settings.decode_registers = false;
|
||||||
// settings.decode_names = false;
|
// settings.decode_names = false;
|
||||||
settings.print_tabs = false;
|
settings.force = force;
|
||||||
settings.ext_separator = '\'';
|
// settings.print_tabs = false;
|
||||||
|
// settings.ext_separator = '\'';
|
||||||
|
|
||||||
// TODO: fix the terrible api of the assembler.
|
// TODO: fix the terrible api of the assembler.
|
||||||
DSPAssembler assembler(settings);
|
DSPAssembler assembler(settings);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
bool Assemble(const char *text, std::vector<u16> &code);
|
bool Assemble(const char *text, std::vector<u16> &code, bool force = false);
|
||||||
bool Disassemble(const std::vector<u16> &code, bool line_numbers, std::string &text);
|
bool Disassemble(const std::vector<u16> &code, bool line_numbers, std::string &text);
|
||||||
bool Compare(const std::vector<u16> &code1, const std::vector<u16> &code2);
|
bool Compare(const std::vector<u16> &code1, const std::vector<u16> &code2);
|
||||||
void GenRandomCode(int size, std::vector<u16> &code);
|
void GenRandomCode(int size, std::vector<u16> &code);
|
||||||
|
@ -79,11 +79,12 @@ static const char *err_string[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
DSPAssembler::DSPAssembler(const AssemblerSettings &settings) :
|
DSPAssembler::DSPAssembler(const AssemblerSettings &settings) :
|
||||||
|
gdg_buffer(NULL),
|
||||||
m_cur_addr(0),
|
m_cur_addr(0),
|
||||||
m_cur_pass(0),
|
m_cur_pass(0),
|
||||||
m_current_param(0),
|
m_current_param(0),
|
||||||
settings_(settings),
|
settings_(settings)
|
||||||
gdg_buffer(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +138,10 @@ bool DSPAssembler::Assemble(const char *text, std::vector<u16> &code, std::vecto
|
|||||||
|
|
||||||
void DSPAssembler::ShowError(err_t err_code, const char *extra_info)
|
void DSPAssembler::ShowError(err_t err_code, const char *extra_info)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!settings_.force)
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
||||||
char error_buffer[1024];
|
char error_buffer[1024];
|
||||||
char *buf_ptr = error_buffer;
|
char *buf_ptr = error_buffer;
|
||||||
buf_ptr += sprintf(buf_ptr, "%i : %s ", code_line, cur_line.c_str());
|
buf_ptr += sprintf(buf_ptr, "%i : %s ", code_line, cur_line.c_str());
|
||||||
|
@ -38,6 +38,7 @@ struct AssemblerSettings
|
|||||||
: print_tabs(false),
|
: print_tabs(false),
|
||||||
show_hex(false),
|
show_hex(false),
|
||||||
show_pc(false),
|
show_pc(false),
|
||||||
|
force(false),
|
||||||
decode_names(true),
|
decode_names(true),
|
||||||
decode_registers(true),
|
decode_registers(true),
|
||||||
ext_separator('\''),
|
ext_separator('\''),
|
||||||
@ -49,6 +50,7 @@ struct AssemblerSettings
|
|||||||
bool print_tabs;
|
bool print_tabs;
|
||||||
bool show_hex;
|
bool show_hex;
|
||||||
bool show_pc;
|
bool show_pc;
|
||||||
|
bool force;
|
||||||
bool decode_names;
|
bool decode_names;
|
||||||
bool decode_registers;
|
bool decode_registers;
|
||||||
char ext_separator;
|
char ext_separator;
|
||||||
|
@ -205,7 +205,7 @@ void RunAsmTests()
|
|||||||
// dsptool -o asdf.bin asdf.txt
|
// dsptool -o asdf.bin asdf.txt
|
||||||
// Assemble a file, output header:
|
// Assemble a file, output header:
|
||||||
// dsptool -h asdf.h asdf.txt
|
// dsptool -h asdf.h asdf.txt
|
||||||
|
// dsptool -f errors are not critical
|
||||||
// So far, all this binary can do is test partially that itself works correctly.
|
// So far, all this binary can do is test partially that itself works correctly.
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
@ -218,6 +218,7 @@ int main(int argc, const char *argv[])
|
|||||||
printf("-s: Print the final size in bytes (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");
|
||||||
|
printf("-f: Errors are not critical\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +232,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, outputSize = false;
|
bool disassemble = false, compare = false, multiple = false, outputSize = false, force = 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"))
|
||||||
@ -246,6 +247,8 @@ int main(int argc, const char *argv[])
|
|||||||
outputSize = true;
|
outputSize = true;
|
||||||
else if (!strcmp(argv[i], "-m"))
|
else if (!strcmp(argv[i], "-m"))
|
||||||
multiple = true;
|
multiple = true;
|
||||||
|
else if (!strcmp(argv[i], "-f"))
|
||||||
|
force = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!input_name.empty())
|
if (!input_name.empty())
|
||||||
@ -371,7 +374,7 @@ int main(int argc, const char *argv[])
|
|||||||
{
|
{
|
||||||
std::vector<u16> code;
|
std::vector<u16> code;
|
||||||
|
|
||||||
if(!Assemble(source.c_str(), code)) {
|
if(!Assemble(source.c_str(), code, force)) {
|
||||||
printf("Assemble: Assembly failed due to errors\n");
|
printf("Assemble: Assembly failed due to errors\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user