diff --git a/.vscode/launch.json b/.vscode/launch.json index 0dc37ee..71c4a0e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,24 +2,25 @@ "version": "0.2.0", "configurations": [ { - "name": "(gdb) Launch", + "name": "Debug", "type": "cppdbg", "request": "launch", // Resolved by CMake Tools: - "program": "${command:cmake.launchTargetPath}", + "program": "${workspaceFolder}/build/qasm", "args": [ - " -d -d -d", - "${workspaceFolder}/test.s" + "${workspaceFolder}/test.s", + "-s", + "-d" ], "stopAtEntry": false, "cwd": "${workspaceFolder}", - "externalConsole": true, + //"externalConsole": true, "environment": [ { // add the directory where our target was built to the PATHs // it gets resolved by CMake Tools: "name": "PATH", - "value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}" + "value": "${env:PATH}:${workspaceFolder}/build" }, { "name": "OTHER_VALUE", diff --git a/asm.cpp b/asm.cpp index d2adc05..15068a9 100644 --- a/asm.cpp +++ b/asm.cpp @@ -34,6 +34,7 @@ void CLASS::print(uint32_t lineno) uint32_t l, i, savpcol, pcol; bool commentprinted = false; uint8_t commentcol = tabs[2]; + bool force=false; uint32_t b = 4; // how many bytes show on the first line @@ -61,15 +62,17 @@ void CLASS::print(uint32_t lineno) } printf("\n"); } + force=true; flags &= (~FLAG_NOLINEPRINT); } - bool np=(flags & FLAG_NOLINEPRINT); + bool np=(flags & FLAG_NOLINEPRINT)?true:false; if (options->isQuiet()) np=true; if (options->isList()) np=false; - + if (force) + np=false; if (np) { return; @@ -553,9 +556,9 @@ CLASS::~CLASS() { } -void CLASS::setProduct(string product) +void CLASS::setLanguage(string lang) { - options.setProduct(product); + options.setLanguage(lang); } void CLASS::errorOut(uint16_t code) @@ -2615,7 +2618,7 @@ void CLASS::process(void) { errorct++; } - if (((!skiplist) && (listing) && (pass == 1)) || (line.errorcode != 0)) + if (((!skiplist) && (listing) && (pass == 1)) || (line.errorcode != 0) || (options.isList())) { line.print(lineno); } diff --git a/asm.h b/asm.h index 36f78e7..0602139 100644 --- a/asm.h +++ b/asm.h @@ -249,7 +249,7 @@ public: virtual void process(void); virtual void complete(void); virtual void errorOut(uint16_t code); - virtual void setProduct(string product); + virtual void setLanguage(string lang); }; diff --git a/parms.json b/parms.json index 8d8c0ef..5cb1877 100644 --- a/parms.json +++ b/parms.json @@ -18,9 +18,9 @@ ] }, "asm": { - "syntax": "merlin16plus", + "language": "merlin16plus", "cpu": "M6502", - "startmx": 3, + "start_mx": 2, "listmode": "on", "casesen": true, "start_lst": false, diff --git a/qasm.cpp b/qasm.cpp index b23d399..ba84677 100644 --- a/qasm.cpp +++ b/qasm.cpp @@ -21,16 +21,13 @@ programOption PAL::appOptions[] = //{ "config", "f", "load configuration data from a ", "", false, false}, { "exec", "x", "execute a command [asm, link, format, script] default=asm", "", false, false}, { "objfile", "o", "write output to ", "", false, false}, - { "instruction", "i", "force the CPU instruction set ('xc' ingored) [6502, 65C02, 65816]", "", false, false}, + { "instruction", "i", "force the CPU instruction set ('xc' ignored) [6502, 65C02, 65816]", "", false, false}, { "type", "t", "enforce syntax/features/bugs of other assembler [qasm, merlin8, merlin16, merlin16plus, merlin32, orca, apw, mpw, lisa, ca65]", "", false, false}, { "quiet", "q", "print as little as possible, equivalent to lst off in the assembler ('lst' opcodes will be ignored)", "", false, true}, { "list", "l", "force assembly listing ('lst' opcodes will be ignored)", "", false, true}, - { "color", "c", "colorize the output", "", false, true}, - { "parms", "p", "show the working parameters/options", "", false, true}, - - + { "settings", "s", "show the working settings/options", "", false, true}, { "", "", "", "", false, false} }; @@ -85,20 +82,34 @@ int CLASS::runCommandLineApp(void) std::string appPath; std::string fname; //uint32_t syntax; - string product=""; + string language=""; string syn; + bool settings; int res = -1; ConfigOptions options; -//Poco::Util::Application::instance().config() - utils=new QUtils(); - //LOG_NOTE << "this is it!" << endl; - startdirectory = Poco::Path::current(); appPath=utils->getAppPath(); - if (commandargs.size() == 0) + settings=getBool("option.settings",false); + if (isDebug()>0) + { + printf("num args: %ld\n",commandargs.size()); + for (unsigned long i=0; i0) { - printf("SYNTAX: |%s|\n",syn.c_str()); + printf("SYNTAX: |%s|\n",language.c_str()); } try @@ -143,12 +168,18 @@ int CLASS::runCommandLineApp(void) for (ArgVec::const_iterator it = commandargs.begin(); it != commandargs.end(); ++it) { int32_t format_flags=CONVERT_LINUX; - Poco::File fn(*it); + + string arg=*it; + Poco::File fn(arg); int x; std::string p = fn.path(); Poco::Path path(p); //logger().information(path.toString()); + if (!fn.exists()) + { + break; + } std::string e = toUpper(path.getExtension()); std::string cmd = Poco::toUpper(getConfig("option.exec", "asm")); @@ -206,7 +237,7 @@ int CLASS::runCommandLineApp(void) try { t->init(); - t->setProduct(product); + t->setLanguage(language); t->format_flags=format_flags; std::string f = path.toString(); @@ -240,7 +271,7 @@ int CLASS::runCommandLineApp(void) try { t->init(); - t->setProduct(product); + t->setLanguage(language); std::string f = path.toString(); @@ -277,7 +308,7 @@ int CLASS::runCommandLineApp(void) try { t->init(); - t->setProduct(product); + t->setLanguage(language); std::string f = path.toString(); t->filename = f; diff --git a/qasm.h b/qasm.h index 96a0eba..4377bd8 100644 --- a/qasm.h +++ b/qasm.h @@ -28,7 +28,6 @@ protected: virtual void displayVersion(); public: - QOptions options; }; diff --git a/qoptions.cpp b/qoptions.cpp index 4c4851b..139597f 100644 --- a/qoptions.cpp +++ b/qoptions.cpp @@ -1,87 +1,2 @@ -#include - -#undef CLASS -#define CLASS QOptions - -CLASS::CLASS() -{ - jsonin=""; - jsonobj=NULL; - parser.reset(); - parser.setAllowComments(true); -} - -int CLASS::ReadFile(string path) -{ - int ret=-1; - - Poco::FileInputStream fs(path); - Poco::StreamCopier::copyToString(fs,jsonin); - parser.reset(); - parser.setAllowComments(true); - jsonobj=parser.parse(jsonin); - - config.load(path); - //config.enumerate(key,range); - return(ret); -} - -Dynamic::Var CLASS::GetObject(string name) -{ - JSON::Query q(jsonobj); - Dynamic::Var jresult=q.find(name); - return(jresult); -} - -bool CLASS::GetBool(string name, bool def) -{ - bool res=def; - try - { - Dynamic::Var jresult=GetObject(name); - if (!jresult.isEmpty()) - { - if (jresult.isArray()) - { - - } - else if (jresult.isBoolean()) - { - res=jresult; - } - } - } - catch(...) - { - res=def; - } - return(res); -} - -string CLASS::GetString(string name, string def) -{ - string res=def; - try - { - Dynamic::Var jresult=GetObject(name); - if (!jresult.isEmpty()) - { - if (jresult.isArray()) - { - - } - else if (jresult.isString()) - { - res=jresult.toString(); - } - } - } - catch(...) - { - res=def; - } - return(res); -} - diff --git a/qoptions.h b/qoptions.h index 36a91ab..0ed1a50 100644 --- a/qoptions.h +++ b/qoptions.h @@ -1,6 +1,8 @@ #pragma once #include "qasm.h" +using namespace Poco; + #define MAX_PREFIX 32 #define MODE_6502 0 @@ -26,12 +28,19 @@ #define OPTION_M16_PLUS 0x8000 +class myLayeredConfiguration : public Poco::Util::LayeredConfiguration +{ +public: + myLayeredConfiguration() : Poco::Util::LayeredConfiguration() {}; + ~myLayeredConfiguration() {}; +}; + #undef CLASS #define CLASS ConfigOptions class CLASS { protected: - vector> configs; + //vector> configs; public: Poco::JSON::Parser parser; @@ -40,8 +49,8 @@ public: uint16_t format_flags; uint16_t cpu_mode; - string product; - uint16_t productlevel; + string language; + uint16_t langlevel; string prefixes[MAX_PREFIX]; uint8_t start_mx; @@ -61,14 +70,14 @@ public: int16_t linebytes; int16_t overflowbytes; - //Poco::Util::LayeredConfiguration config; + myLayeredConfiguration config; bool usecolor; CLASS() { setDefaults(); - setProduct("QASM"); + setLanguage("QASM"); } ~CLASS() { @@ -83,7 +92,7 @@ public: bool useColor(void) { bool res=false; - if (getBool("option.color",false)) + if (PAL::getBool("option.color",false)) { res=true; } @@ -97,17 +106,57 @@ public: bool isQuiet(void) { bool res; - res=getBool("option.quiet",false); + res=PAL::getBool("option.quiet",false); if (isDebug()>0) { res=false; } return(res); } + bool isList(void) { bool res; - res=getBool("option.list",false); + res=PAL::getBool("option.list",false); + //printf("list: %d\n",res); + return(res); + } + + int printDefaults(string lang) + { + int res=-1; + string l=Poco::toUpper(lang); + if (l=="") + { + l=Poco::toUpper(language); + } + if (l!="") + { + setLanguage(l); + setCurrent(); + printf("Defaults for language (%s)\n",language.c_str()); + printf("\tLanguage:\t\t\t\t\t%s\n",language.c_str()); + printf("\t\tlanguageLevel:\t\t\t\t%d\n",langlevel); + printf("\t\tcpu_mode:\t\t\t\t%d\n",cpu_mode); + printf("\t\tstart_mx:\t\t\t\t%d\n",start_mx); + printf("\t\tPrefixes:\n"); + + for (int i=0; i0) + { + printf("\t\t\t%02d:\t\t\t%s\n",i,prefixes[i].c_str()); + } + } + + + //uint16_t format_flags; + + + //bool start_listmode; + //bool listmode; + + } return(res); } @@ -148,6 +197,7 @@ public: if (success) { //configs.push_back(shared_ptr(jc)); + config.add(jc); ret=0; } else @@ -159,13 +209,6 @@ public: return(ret); } - void printCurrentOptions(void) - { - printf("Current Options:"); - printf(" product: %s\n",product.c_str()); - //printf(" start_mx: \%%02d\n",start_mx); - } - bool isMerlin32(void) { return(true); @@ -176,11 +219,15 @@ public: return(false); } + void setCurrent(void) + { + start_mx=GetInteger("asm.start_mx",3); + } void setDefaults(void) { cpu_mode=MODE_6502; - product="QASM"; - productlevel=0; + language="QASM"; + langlevel=0; for (int i=0; i keys; + config.keys(keys); + for (unsigned int i=0;i