diff --git a/compiler/scasm/amx_compiler.cpp b/compiler/scasm/amx_compiler.cpp index fa6a6905..effff0de 100755 --- a/compiler/scasm/amx_compiler.cpp +++ b/compiler/scasm/amx_compiler.cpp @@ -111,7 +111,7 @@ int Compiler::CipCount() return cipc; } -bool Compiler::Compile() +bool Compiler::Compile(std::string &out) { if (CodeList.size() < 1 || !CError || CError->GetStatus() >= Err_Error) { @@ -204,7 +204,7 @@ bool Compiler::Compile() fileSize = hea; std::string amxname; - amxname.assign(filename); + amxname.assign(out); int pos = (int)amxname.find(".asm"); if (pos != std::string::npos) { diff --git a/compiler/scasm/amxasm.cpp b/compiler/scasm/amxasm.cpp index de82b872..cbff392a 100755 --- a/compiler/scasm/amxasm.cpp +++ b/compiler/scasm/amxasm.cpp @@ -23,6 +23,7 @@ #include "amxasm.h" std::string filename; +std::string output_name; int main(int argc, char **argv) { @@ -33,13 +34,15 @@ int main(int argc, char **argv) if (filename.size() < 1) { print_version(); + print_options(); exit(0); } Program.Load(filename); if (Program.Parse()) { - if (Program.Compile()) + + if (Program.Compile(output_name.size() ? output_name : filename)) printf("Done.\n"); else printf("Compile build failed.\n"); @@ -53,8 +56,9 @@ int main(int argc, char **argv) void get_options(int argc, char **argv, Compiler &Prog) { int i = 0; /* index */ - int opt_flag = 0; /* flag for option detection */ + char opt_flag = 0; /* flag for option detection */ char *option = 0; /* option pointer */ + char c = 0; /* option marker */ for (i=1; i 2) + { + output_name.assign(&(argv[i][2])); + } else { + opt_flag = 'o'; + } + break; + } case 'v': { opt_flag = 0; /* no options expected */ print_version(); + exit(0); break; } /* case */ case 'd': @@ -81,7 +96,14 @@ void get_options(int argc, char **argv, Compiler &Prog) { filename.assign(argv[i]); } else { - /* TODO */ + switch (opt_flag) + { + case 'o': + { + output_name.assign(argv[i]); + break; + } + } } } /* if */ } @@ -91,5 +113,13 @@ void print_version() { printf("Small/AMX Assembler 1.00\n"); printf("(C)2004 David 'BAILOPAN' Anderson\n"); - exit(0); +} + +void print_options() +{ + printf("\nOptions:\n"); + printf("\t-d\t\t- Add debug opcodes (will double file size)\n"); + printf("\t-v\t\t- Output version and exit\n"); + printf("\t-o\t\t- Specify file to write\n"); + printf("\n"); } \ No newline at end of file diff --git a/compiler/scasm/amxasm.h b/compiler/scasm/amxasm.h index 387f08d7..3ebd094d 100755 --- a/compiler/scasm/amxasm.h +++ b/compiler/scasm/amxasm.h @@ -220,5 +220,6 @@ void get_options(int argc, char **argv, Compiler &Prog); void InitOpcodes(); void DestroyArgList(std::vector &List); void print_version(); +void print_options(); #endif //_INCLUDE_AMXASM_H diff --git a/compiler/scasm/sasm.exe b/compiler/scasm/sasm.exe index ea218114..09c132d2 100755 Binary files a/compiler/scasm/sasm.exe and b/compiler/scasm/sasm.exe differ