mirror of https://github.com/marketideas/qasm.git
might be broken, work on addressing modes and shift operators < > | ^
This commit is contained in:
parent
88e0251a16
commit
4380f4e8ca
|
@ -9,8 +9,8 @@
|
|||
"program": "${workspaceFolder}/build/qasm",
|
||||
"args": [
|
||||
"${workspaceFolder}/test.s",
|
||||
"-s",
|
||||
"-d"
|
||||
"-d",
|
||||
"-l"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
|
270
asm.cpp
270
asm.cpp
|
@ -11,12 +11,12 @@
|
|||
#define CLASS MerlinLine
|
||||
|
||||
|
||||
CLASS::CLASS(ConfigOptions &opt) //: options(opt)
|
||||
CLASS::CLASS(ConfigOptions &opt) : options(&opt)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
CLASS::CLASS(std::string line, ConfigOptions &opt) //: options(opt)
|
||||
CLASS::CLASS(std::string line, ConfigOptions &opt) : options(&opt)
|
||||
{
|
||||
clear();
|
||||
set(line);
|
||||
|
@ -68,11 +68,17 @@ void CLASS::print(uint32_t lineno)
|
|||
|
||||
bool np=(flags & FLAG_NOLINEPRINT)?true:false;
|
||||
if (options->isQuiet())
|
||||
{
|
||||
np=true;
|
||||
}
|
||||
if (options->isList())
|
||||
np=false;
|
||||
if (force)
|
||||
{
|
||||
np=false;
|
||||
}
|
||||
if (force)
|
||||
{
|
||||
np=false;
|
||||
}
|
||||
if (np)
|
||||
{
|
||||
return;
|
||||
|
@ -221,6 +227,8 @@ void CLASS::print(uint32_t lineno)
|
|||
}
|
||||
//pcol += printf("%-12s %-8s %-10s ", printlable.c_str(), opcode.c_str(), operand.c_str());
|
||||
}
|
||||
//printf("merlinerrors=%d\n",merlinerrors);
|
||||
//merlinerrors=false;
|
||||
if ((errorcode > 0) && (!merlinerrors))
|
||||
{
|
||||
while (pcol < commentcol)
|
||||
|
@ -245,7 +253,7 @@ void CLASS::print(uint32_t lineno)
|
|||
|
||||
if ((options->useColor()) && (errorcode > 0))
|
||||
{
|
||||
SetColor(CL_NORMAL | BG_NORMAL);
|
||||
SetColor(CL_NORMAL);
|
||||
}
|
||||
|
||||
uint32_t obc = datafillct;
|
||||
|
@ -297,6 +305,7 @@ void CLASS::print(uint32_t lineno)
|
|||
|
||||
void CLASS::clear()
|
||||
{
|
||||
shiftchar=0;
|
||||
wholetext = "";
|
||||
lable = "";
|
||||
printlable = "";
|
||||
|
@ -305,6 +314,7 @@ void CLASS::clear()
|
|||
operand = "";
|
||||
printoperand = "";
|
||||
orig_operand="";
|
||||
strippedoperand="";
|
||||
comment = "";
|
||||
operand_expr = "";
|
||||
operand_expr2 = "";
|
||||
|
@ -317,16 +327,15 @@ void CLASS::clear()
|
|||
startpc = 0;
|
||||
errorcode = 0;
|
||||
errorText = "";
|
||||
outbytect = 0;
|
||||
datafillct = 0;
|
||||
datafillbyte = 0;
|
||||
lineno = 0;
|
||||
outbytes.clear();
|
||||
addressmode = 0;
|
||||
expr_value = 0;
|
||||
eval_result = 0;
|
||||
flags = 0;
|
||||
outbytes.clear();
|
||||
outbytect = 0;
|
||||
}
|
||||
|
||||
std::string operEx[] =
|
||||
|
@ -556,9 +565,9 @@ CLASS::~CLASS()
|
|||
{
|
||||
}
|
||||
|
||||
void CLASS::setLanguage(string lang)
|
||||
void CLASS::setLanguage(string lang,bool force)
|
||||
{
|
||||
options.setLanguage(lang);
|
||||
options.setLanguage(lang,force);
|
||||
}
|
||||
|
||||
void CLASS::errorOut(uint16_t code)
|
||||
|
@ -614,7 +623,7 @@ void CLASS::complete(void)
|
|||
//cout << "Processing Time: " << n - starttime << "ms" << endl;
|
||||
uint64_t x = n - starttime;
|
||||
uint32_t x1 = x & 0xFFFFFFFF;
|
||||
if ((!getBool("option.quiet",false)) && (isDebug()>0))
|
||||
//if ((!getBool("option.quiet",false)) && (isDebug()>0))
|
||||
{
|
||||
printf("Elapsed time: %u ms\n", x1);
|
||||
}
|
||||
|
@ -1639,7 +1648,7 @@ int CLASS::callOpCode(std::string op, MerlinLine &line)
|
|||
break;
|
||||
case '>':
|
||||
#if 0
|
||||
if ((syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32)
|
||||
if (options.isMerlin32())
|
||||
{
|
||||
// bug in M32 or not, do what it does
|
||||
line.flags |= FLAG_FORCEABS;
|
||||
|
@ -1768,16 +1777,17 @@ void CLASS::initpass(void)
|
|||
showmx = getBool("asm.showmx", true);
|
||||
merlinerrors = getBool("asm.merlinerrors", true);
|
||||
|
||||
outputbytes.clear();
|
||||
trackrep = getBool("asm.trackrep", false);
|
||||
if (syntax == SYNTAX_MERLIN32)
|
||||
if (options.isMerlin32())
|
||||
{
|
||||
trackrep = true; // can't turn this off in M32
|
||||
}
|
||||
else if (syntax == SYNTAX_MERLIN)
|
||||
else if (options.isMerlin())
|
||||
{
|
||||
trackrep = false; // can't turn this ON in M16
|
||||
}
|
||||
else if (syntax == SYNTAX_QASM)
|
||||
else if (options.isQASM())
|
||||
{
|
||||
// we will allow this to be settable default off
|
||||
trackrep = false;
|
||||
|
@ -1797,28 +1807,33 @@ void CLASS::initpass(void)
|
|||
s = getConfig("asm.cpu", "M6502");
|
||||
s = Poco::trim(Poco::toUpper(s));
|
||||
|
||||
cpumode = MODE_65816;
|
||||
mx = 0x03;
|
||||
|
||||
if (s == "M65816")
|
||||
s=PAL::getString("option.instruction","");
|
||||
if (s!="")
|
||||
{
|
||||
printf("CPU command line %s\n",s.c_str());
|
||||
cpumode = MODE_65816;
|
||||
mx = 0x03;
|
||||
}
|
||||
else if (s == "M65C02")
|
||||
{
|
||||
cpumode = MODE_65C02;
|
||||
mx = 0x03;
|
||||
}
|
||||
else if (s == "M6502")
|
||||
{
|
||||
cpumode = MODE_6502;
|
||||
mx = 0x03;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown CPU type in .ini\n");
|
||||
mx = 0x03;
|
||||
|
||||
if (s == "M65816")
|
||||
{
|
||||
cpumode = MODE_65816;
|
||||
mx = 0x03;
|
||||
}
|
||||
else if (s == "M65C02")
|
||||
{
|
||||
cpumode = MODE_65C02;
|
||||
mx = 0x03;
|
||||
}
|
||||
else if (s == "M6502")
|
||||
{
|
||||
cpumode = MODE_6502;
|
||||
mx = 0x03;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown CPU type in .ini\n");
|
||||
mx = 0x03;
|
||||
}
|
||||
}
|
||||
mx = getInt("asm.startmx", mx);;
|
||||
|
||||
|
@ -1829,7 +1844,7 @@ void CLASS::initpass(void)
|
|||
lastcarry = false;
|
||||
relocatable = false;
|
||||
currentsym = NULL;
|
||||
if ((syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32)
|
||||
if (options.isMerlin32())
|
||||
{
|
||||
// M32 allows locals that don't have a global above. this is the catchall for that
|
||||
currentsym = &topSymbol; // this is the default symbol for :locals without a global above;
|
||||
|
@ -1875,46 +1890,76 @@ void CLASS::initpass(void)
|
|||
|
||||
void CLASS::complete(void)
|
||||
{
|
||||
bool writeerr=false;
|
||||
if (savepath != "")
|
||||
{
|
||||
if (errorct == 0)
|
||||
{
|
||||
std::string currentdir = Poco::Path::current();
|
||||
|
||||
savepath = processFilename(savepath, currentdir, 0);
|
||||
//savepath = processFilename(savepath, currentdir, 0);
|
||||
savepath=options.formatPath(savepath);
|
||||
if (!options.isQuiet())
|
||||
{
|
||||
printf("saving to file: %s\n", savepath.c_str());
|
||||
}
|
||||
|
||||
std::ofstream f(savepath);
|
||||
std::ofstream f(savepath, std::ios::out|std::ios::trunc);
|
||||
|
||||
uint32_t lineno = 0;
|
||||
uint32_t l = (uint32_t)lines.size();
|
||||
while (lineno < l)
|
||||
if (f.is_open())
|
||||
{
|
||||
MerlinLine &line = lines.at(lineno++);
|
||||
if ((line.outbytect > 0) && ((line.flags & FLAG_INDUM) == 0))
|
||||
#if 0
|
||||
uint32_t lineno = 0;
|
||||
uint32_t l = (uint32_t)lines.size();
|
||||
while (lineno < l)
|
||||
{
|
||||
for (uint32_t i = 0; i < line.outbytect; i++)
|
||||
MerlinLine &line = lines.at(lineno++);
|
||||
if ((line.outbytect > 0) && ((line.flags & FLAG_INDUM) == 0))
|
||||
{
|
||||
f.put(line.outbytes[i]);
|
||||
for (uint32_t i = 0; i < line.outbytect; i++)
|
||||
{
|
||||
f.put(line.outbytes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((line.datafillct > 0) && ((line.flags & FLAG_INDUM) == 0))
|
||||
{
|
||||
for (uint32_t i = 0; i < line.datafillct; i++)
|
||||
if ((line.datafillct > 0) && ((line.flags & FLAG_INDUM) == 0))
|
||||
{
|
||||
f.put(line.datafillbyte & 0xFF);
|
||||
}
|
||||
for (uint32_t i = 0; i < line.datafillct; i++)
|
||||
{
|
||||
f.put(line.datafillbyte & 0xFF);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
for (unsigned int i=0; i<outputbytes.size(); i++)
|
||||
{
|
||||
f.put(outputbytes[i]);
|
||||
}
|
||||
f.flush();
|
||||
//printf("outbytect=%ld\n",outputbytes.size());
|
||||
|
||||
if (f.fail())
|
||||
{
|
||||
writeerr=true;
|
||||
}
|
||||
f.close();
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
writeerr=true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nErrors in assembly. Output not SAVED.\n\n");
|
||||
}
|
||||
if (writeerr)
|
||||
{
|
||||
printf("unable to save file.\n"); // TODO SGQ need to push error up the so exit code is non-zero
|
||||
}
|
||||
}
|
||||
if ((!options.isQuiet()) || (options.isList()))
|
||||
{
|
||||
|
@ -2001,12 +2046,77 @@ int CLASS::getAddrMode(MerlinLine & line)
|
|||
int idx, x;
|
||||
std::string s, oper;
|
||||
std::vector<std::string> groups;
|
||||
char shiftchar;
|
||||
|
||||
oper = line.operand;
|
||||
|
||||
if ((line.opcode.length() == 0) || (line.operand.length() == 0))
|
||||
int l=oper.length();
|
||||
if ((line.opcode.length() == 0) || (l <= 0))
|
||||
{
|
||||
return (syn_implied);
|
||||
return (syn_none);
|
||||
}
|
||||
|
||||
bool supportbar=false;
|
||||
bool modified=false;
|
||||
|
||||
shiftchar=oper[0];
|
||||
if (shiftchar=='#')
|
||||
{
|
||||
shiftchar=0;
|
||||
if (l>1)
|
||||
{
|
||||
shiftchar=oper[1];
|
||||
|
||||
//oper=oper.substr(1);
|
||||
//oper="#"+oper;
|
||||
}
|
||||
}
|
||||
if (shiftchar=='^')
|
||||
{
|
||||
if (options.isMerlin())
|
||||
{
|
||||
return(syn_err);
|
||||
//shiftchar=0x00; // merlin8 does not support the bank addr
|
||||
}
|
||||
}
|
||||
if (shiftchar=='|')
|
||||
{
|
||||
if (options.isMerlinCompat())
|
||||
{
|
||||
if ((options.isMerlin() || options.isMerlin16())) // merlin8 and merlin16 do not support the bar
|
||||
{
|
||||
return(syn_err);
|
||||
}
|
||||
else
|
||||
{
|
||||
supportbar=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((shiftchar=='^') || (shiftchar=='<') || (shiftchar=='>') || (supportbar && shiftchar=='|'))
|
||||
{
|
||||
modified=true;
|
||||
}
|
||||
if (supportbar)
|
||||
{
|
||||
|
||||
}
|
||||
if (modified)
|
||||
{
|
||||
line.shiftchar=shiftchar;
|
||||
if (oper[0]=='#')
|
||||
{
|
||||
oper=oper.substr(2);
|
||||
oper="#"+oper;
|
||||
l=oper.length();
|
||||
}
|
||||
else if (shiftchar!=0)
|
||||
{
|
||||
oper=oper.substr(1);
|
||||
l=oper.length();
|
||||
}
|
||||
printf("old: |%s| new: |%s|\n",line.operand.c_str(),oper.c_str());
|
||||
line.strippedoperand=oper;
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
|
@ -2136,9 +2246,35 @@ int CLASS::parseOperand(MerlinLine & line)
|
|||
{
|
||||
//errorOut(errBadAddressMode);
|
||||
}
|
||||
printf("addressmode=%d %s\n",res,addrModeEnglish(res).c_str());
|
||||
return (res);
|
||||
}
|
||||
|
||||
string CLASS::addrModeEnglish(int mode)
|
||||
{
|
||||
string res="<none>";
|
||||
switch(mode)
|
||||
{
|
||||
case syn_err: res="addrmode_error";break;
|
||||
case syn_none: res="addrmode_none";break;
|
||||
case syn_implied: res="implied";break;
|
||||
case syn_s: res="dp,s";break;
|
||||
case syn_sy: res="(dp,s),y";break;
|
||||
case syn_imm: res="#immediate";break;
|
||||
case syn_diix: res="(dp,x)";break;
|
||||
case syn_diiy: res="(dp),y";break;
|
||||
case syn_di: res="(dp)";break;
|
||||
case syn_iyl: res="[expr],y";break;
|
||||
case syn_dil: res="[expr]";break;
|
||||
case syn_absx: res="abs,x";break;
|
||||
case syn_absy: res="abs,y";break;
|
||||
case syn_bm: res="block move";break;
|
||||
case syn_abs: res="absolute";break;
|
||||
default: res="addr_mode bad";break;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
int CLASS::substituteVariables(MerlinLine & line, std::string &outop)
|
||||
{
|
||||
int res = 0;
|
||||
|
@ -2580,6 +2716,24 @@ void CLASS::process(void)
|
|||
line.errorText = line.operand_expr;
|
||||
}
|
||||
line.bytect = x;
|
||||
if (pass>0)
|
||||
{
|
||||
if ((line.flags & FLAG_INDUM) == 0) // don't write bytes if inside DUM section
|
||||
{
|
||||
for (unsigned int i=0; i<line.outbytes.size(); i++)
|
||||
{
|
||||
outputbytes.push_back(line.outbytes[i]);
|
||||
}
|
||||
if (line.datafillct>0)
|
||||
{
|
||||
for (int i=0; i<line.datafillct; i++)
|
||||
{
|
||||
outputbytes.push_back(line.datafillbyte);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PC.currentpc += x;
|
||||
PC.totalbytes += x;
|
||||
}
|
||||
|
@ -2623,6 +2777,9 @@ void CLASS::process(void)
|
|||
line.print(lineno);
|
||||
}
|
||||
skiplist = false;
|
||||
line.outbytes.clear(); // clear the outbytes on the line so LUP works correctly
|
||||
line.outbytect=0;
|
||||
|
||||
}
|
||||
lineno++;
|
||||
}
|
||||
|
@ -2654,15 +2811,6 @@ int CLASS::doline(int lineno, std::string line)
|
|||
MerlinLine l(line,options);
|
||||
|
||||
op = Poco::toLower(l.opcode);
|
||||
if (op == "merlin")
|
||||
{
|
||||
syntax = SYNTAX_MERLIN;
|
||||
}
|
||||
else if (op == "orca")
|
||||
{
|
||||
syntax = SYNTAX_ORCA;
|
||||
}
|
||||
//l.syntax = syntax;
|
||||
lines.push_back(l);
|
||||
|
||||
if ((op == "use") || (op == "put"))
|
||||
|
|
12
asm.h
12
asm.h
|
@ -37,6 +37,7 @@ enum asmErrors
|
|||
{
|
||||
errNone,
|
||||
errWarn,
|
||||
errDebug,
|
||||
errIncomplete,
|
||||
errUnimplemented,
|
||||
errFatal,
|
||||
|
@ -72,6 +73,7 @@ const std::string errStrings[errMAX + 1] =
|
|||
{
|
||||
"No Error",
|
||||
"Warning",
|
||||
"Debug Error",
|
||||
"Unfinished Opcode",
|
||||
"Unimplemented Instruction",
|
||||
"Fatal",
|
||||
|
@ -181,6 +183,7 @@ public:
|
|||
std::string lable;
|
||||
std::string printlable;
|
||||
std::string printoperand;
|
||||
std::string strippedoperand;
|
||||
std::string opcode;
|
||||
std::string opcodelower;
|
||||
std::string orig_operand;
|
||||
|
@ -189,6 +192,7 @@ public:
|
|||
std::string operand_expr2;
|
||||
std::string comment;
|
||||
std::string addrtext;
|
||||
char shiftchar;
|
||||
uint8_t linemx;
|
||||
uint8_t tabs[16];
|
||||
bool showmx;
|
||||
|
@ -228,7 +232,7 @@ protected:
|
|||
int win_rows;
|
||||
std::string initialdir;
|
||||
std::vector<std::string> filenames;
|
||||
uint32_t syntax;
|
||||
//uint32_t syntax;
|
||||
uint64_t starttime;
|
||||
uint8_t tabs[16];
|
||||
|
||||
|
@ -249,7 +253,7 @@ public:
|
|||
virtual void process(void);
|
||||
virtual void complete(void);
|
||||
virtual void errorOut(uint16_t code);
|
||||
virtual void setLanguage(string lang);
|
||||
virtual void setLanguage(string lang,bool force);
|
||||
};
|
||||
|
||||
|
||||
|
@ -403,6 +407,9 @@ class TPsuedoOp;
|
|||
|
||||
class T65816Asm : public TFileProcessor
|
||||
{
|
||||
protected:
|
||||
std::vector<uint8_t> outputbytes;
|
||||
|
||||
public:
|
||||
// options
|
||||
bool casesen;
|
||||
|
@ -486,6 +493,7 @@ public:
|
|||
|
||||
int parseOperand(MerlinLine &line);
|
||||
int getAddrMode(MerlinLine &line);
|
||||
string addrModeEnglish(int mode);
|
||||
void setOpcode(MerlinLine &line, uint8_t op);
|
||||
|
||||
|
||||
|
|
2
eval.cpp
2
eval.cpp
|
@ -607,7 +607,7 @@ int CLASS::evaluate(std::string & e, int64_t &res, uint8_t &_shiftmode)
|
|||
std::string expr = Poco::trim(e);
|
||||
expr += " "; // add a space at end to make parsing easier
|
||||
|
||||
if (isDebug() >= 1)
|
||||
if (isDebug() >= 3)
|
||||
{
|
||||
printf("eval: expression: |%s|\n", expr.c_str());
|
||||
}
|
||||
|
|
289
opcodes.cpp
289
opcodes.cpp
|
@ -7,6 +7,7 @@ void CLASS::setOpcode(MerlinLine &line, uint8_t op)
|
|||
{
|
||||
if (pass > 0)
|
||||
{
|
||||
//printf("cpumode=%d\n",cpumode);
|
||||
if (cpumode < MODE_65816) // instructions are valid if we are in 65816
|
||||
{
|
||||
uint8_t m = opCodeCompatibility[op];
|
||||
|
@ -40,6 +41,15 @@ int CLASS::doXC(MerlinLine &line, TSymbol &sym)
|
|||
std::string s;
|
||||
int res = 0;
|
||||
|
||||
if (options.isMerlin()) // in merlin8 mode we don't support XC psuedoop
|
||||
{
|
||||
if (line.errorcode == 0) // don't replace other errors
|
||||
{
|
||||
line.setError(errIncompatibleOpcode);
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
if (cpumode < MODE_65816)
|
||||
{
|
||||
cpumode++;
|
||||
|
@ -203,7 +213,7 @@ int CLASS::doMVN(MerlinLine &line, TSymbol &sym)
|
|||
// these bytes are the two bank registers
|
||||
|
||||
if (options.isMerlin32() && (v<256))
|
||||
//if (((line.syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32) && (v<256))
|
||||
//if (((line.syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32) && (v<256))
|
||||
{
|
||||
// merlin32 uses the low byte of the two operands
|
||||
line.outbytes.push_back((v) & 0xFF);
|
||||
|
@ -248,40 +258,40 @@ int CLASS::doNoPattern(MerlinLine &line, TSymbol &sym)
|
|||
|
||||
switch (sym.opcode)
|
||||
{
|
||||
case 1: // STZ
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x64 : op);
|
||||
op = (m == syn_absx ? 0x74 : op);
|
||||
case 1: // STZ
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x64 : op);
|
||||
op = (m == syn_absx ? 0x74 : op);
|
||||
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags & FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = (op == 0x64) ? 0x9C : op;
|
||||
op = (op == 0x74) ? 0x9E : op;
|
||||
}
|
||||
break;
|
||||
case 2: // TSB
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags & FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x04 : op);
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags & FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = 0x0C;
|
||||
}
|
||||
break;
|
||||
case 3: // TRB
|
||||
op = (op == 0x64) ? 0x9C : op;
|
||||
op = (op == 0x74) ? 0x9E : op;
|
||||
}
|
||||
break;
|
||||
case 2: // TSB
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x04 : op);
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags & FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x14 : op);
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags & FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = 0x1C;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
op = 0;
|
||||
err = errBadOpcode;
|
||||
break;
|
||||
op = 0x0C;
|
||||
}
|
||||
break;
|
||||
case 3: // TRB
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x14 : op);
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags & FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = 0x1C;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
op = 0;
|
||||
err = errBadOpcode;
|
||||
break;
|
||||
}
|
||||
|
||||
if (op == 0x00)
|
||||
|
@ -316,15 +326,15 @@ int CLASS::doAddress(MerlinLine &line, TSymbol &sym)
|
|||
//}
|
||||
switch(line.expr_shift)
|
||||
{
|
||||
case '^':
|
||||
line.expr_value=(line.expr_value>>16)&0xFFFF;
|
||||
break;
|
||||
case '<':
|
||||
line.expr_value=(line.expr_value)&0xFF;
|
||||
break;
|
||||
case '>':
|
||||
line.expr_value=(line.expr_value>>8)&0xFFFF;
|
||||
break;
|
||||
case '^':
|
||||
line.expr_value=(line.expr_value>>16)&0xFFFF;
|
||||
break;
|
||||
case '<':
|
||||
line.expr_value=(line.expr_value)&0xFF;
|
||||
break;
|
||||
case '>':
|
||||
line.expr_value=(line.expr_value>>8)&0xFFFF;
|
||||
break;
|
||||
}
|
||||
|
||||
//line.setError(errIncomplete);
|
||||
|
@ -347,12 +357,12 @@ int CLASS::doAddress(MerlinLine &line, TSymbol &sym)
|
|||
uint8_t newmx = (line.expr_value & 0x30) >> 4;
|
||||
switch (sym.opcode)
|
||||
{
|
||||
case 0xC2: // REP
|
||||
mx &= ~newmx;
|
||||
break;
|
||||
case 0xE2: // SEP
|
||||
mx |= newmx;
|
||||
break;
|
||||
case 0xC2: // REP
|
||||
mx &= ~newmx;
|
||||
break;
|
||||
case 0xE2: // SEP
|
||||
mx |= newmx;
|
||||
break;
|
||||
}
|
||||
line.linemx = mx;
|
||||
}
|
||||
|
@ -544,21 +554,21 @@ int CLASS::doBase6502(MerlinLine & line, TSymbol & sym)
|
|||
int add = 0;
|
||||
switch (sym.opcode)
|
||||
{
|
||||
case 7: // CPX
|
||||
case 6: // CPY
|
||||
case 5: // LDY
|
||||
case 4: // STY
|
||||
if ((mx & 0x01) == 0)
|
||||
{
|
||||
add = 1;
|
||||
}
|
||||
break;
|
||||
case 1: // BIT
|
||||
if ((mx & 0x02) == 0)
|
||||
{
|
||||
add = 1;
|
||||
}
|
||||
break;
|
||||
case 7: // CPX
|
||||
case 6: // CPY
|
||||
case 5: // LDY
|
||||
case 4: // STY
|
||||
if ((mx & 0x01) == 0)
|
||||
{
|
||||
add = 1;
|
||||
}
|
||||
break;
|
||||
case 1: // BIT
|
||||
if ((mx & 0x02) == 0)
|
||||
{
|
||||
add = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
bytelen += add;
|
||||
|
@ -571,34 +581,55 @@ int CLASS::doBase6502(MerlinLine & line, TSymbol & sym)
|
|||
{
|
||||
switch (m)
|
||||
{
|
||||
case syn_diix: amode = 0; break;
|
||||
case syn_abs: amode = 1; break;
|
||||
case syn_imm: amode = 2; break;
|
||||
case syn_diiy: amode = 4; break;
|
||||
case syn_absx: amode = 5; break;
|
||||
case syn_absy: amode = 6; break;
|
||||
default:
|
||||
err = true;
|
||||
break;
|
||||
case syn_diix:
|
||||
amode = 0;
|
||||
break;
|
||||
case syn_abs:
|
||||
amode = 1;
|
||||
break;
|
||||
case syn_imm:
|
||||
amode = 2;
|
||||
break;
|
||||
case syn_diiy:
|
||||
amode = 4;
|
||||
break;
|
||||
case syn_absx:
|
||||
amode = 5;
|
||||
break;
|
||||
case syn_absy:
|
||||
amode = 6;
|
||||
break;
|
||||
default:
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (cc == 0x02)
|
||||
{
|
||||
switch (m)
|
||||
{
|
||||
case syn_imm: amode = 0; break;
|
||||
case syn_abs: amode = 1; break;
|
||||
case syn_implied: amode = 2; bytelen = 0; break;
|
||||
case syn_absy:
|
||||
if ((opflags & OP_STX) == OP_STX)
|
||||
{
|
||||
amode = 5;
|
||||
}
|
||||
break;
|
||||
case syn_absx: amode = 5; break; // this is actually Y addressing because X register is used
|
||||
default:
|
||||
err = true;
|
||||
break;
|
||||
case syn_imm:
|
||||
amode = 0;
|
||||
break;
|
||||
case syn_abs:
|
||||
amode = 1;
|
||||
break;
|
||||
case syn_implied:
|
||||
amode = 2;
|
||||
bytelen = 0;
|
||||
break;
|
||||
case syn_absy:
|
||||
if ((opflags & OP_STX) == OP_STX)
|
||||
{
|
||||
amode = 5;
|
||||
}
|
||||
break;
|
||||
case syn_absx:
|
||||
amode = 5;
|
||||
break; // this is actually Y addressing because X register is used
|
||||
default:
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((opflags & OP_STX) == OP_STX)
|
||||
|
@ -715,17 +746,32 @@ int CLASS::doBase6502(MerlinLine & line, TSymbol & sym)
|
|||
err = false;
|
||||
switch (m)
|
||||
{
|
||||
case syn_s: amode = 0; break;
|
||||
case syn_sy: amode = 4; break;
|
||||
case syn_di: cc = 0x02; amode = 4; break;
|
||||
case syn_iyl: amode = 5; break;
|
||||
case syn_dil: amode = 1; break;
|
||||
case syn_absx: amode = 7; break;
|
||||
case syn_abs: amode = 3; break;
|
||||
default:
|
||||
//printf("bad syn_mode=%d\n", m);
|
||||
err = true;
|
||||
break;
|
||||
case syn_s:
|
||||
amode = 0;
|
||||
break;
|
||||
case syn_sy:
|
||||
amode = 4;
|
||||
break;
|
||||
case syn_di:
|
||||
cc = 0x02;
|
||||
amode = 4;
|
||||
break;
|
||||
case syn_iyl:
|
||||
amode = 5;
|
||||
break;
|
||||
case syn_dil:
|
||||
amode = 1;
|
||||
break;
|
||||
case syn_absx:
|
||||
amode = 7;
|
||||
break;
|
||||
case syn_abs:
|
||||
amode = 3;
|
||||
break;
|
||||
default:
|
||||
//printf("bad syn_mode=%d\n", m);
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
if (!err)
|
||||
{
|
||||
|
@ -750,15 +796,29 @@ out:
|
|||
if (err)
|
||||
{
|
||||
line.setError(errBadAddressMode);
|
||||
//printf("bad address mode %d\n",line.addressmode);
|
||||
printf("bad address mode %d\n",line.addressmode);
|
||||
op = 0x00;
|
||||
res = 0;
|
||||
bytelen = 0;
|
||||
}
|
||||
|
||||
res += bytelen;
|
||||
//if (options.isMerlin32())
|
||||
{
|
||||
if ((op==0xB9) || (op==0x79) || (op==0xF9) || (op==0x99))
|
||||
{
|
||||
// there are 4 instructions that don't have (dp),y addressing so convert to (abs),
|
||||
if (bytelen<2)
|
||||
{
|
||||
res++;
|
||||
bytelen++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((pass > 0) && (res > 0))
|
||||
{
|
||||
|
||||
setOpcode(line, op);
|
||||
for (i = 0; i < (res - 1); i++)
|
||||
{
|
||||
|
@ -794,23 +854,26 @@ int CLASS::doBYTE(MerlinLine & line, TSymbol & sym)
|
|||
}
|
||||
|
||||
// SGQ merlin32 apparently tracks XCE instructions when tracking MX status
|
||||
// who know how they determine this. I am assuming the NEXT instruction
|
||||
// who knows how they determine this. I am assuming the NEXT instruction
|
||||
// after a SEC/CLC instruction must be an XCE
|
||||
if (sym.opcode == 0x38) // SEC
|
||||
if (options.isMerlin32())
|
||||
{
|
||||
lastcarry = true;
|
||||
}
|
||||
else if (sym.opcode == 0x18) // CLC
|
||||
{
|
||||
lastcarry = false;
|
||||
}
|
||||
else if (sym.opcode == 0xFB) // XCE
|
||||
{
|
||||
if (trackrep)
|
||||
if (sym.opcode == 0x38) // SEC
|
||||
{
|
||||
if (lastcarry)
|
||||
lastcarry = true;
|
||||
}
|
||||
else if (sym.opcode == 0x18) // CLC
|
||||
{
|
||||
lastcarry = false;
|
||||
}
|
||||
else if (sym.opcode == 0xFB) // XCE
|
||||
{
|
||||
if (trackrep)
|
||||
{
|
||||
mx = 0x03;
|
||||
if (lastcarry)
|
||||
{
|
||||
mx = 0x03;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -847,11 +910,11 @@ void CLASS::insertOpcodes(void)
|
|||
{
|
||||
pushopcode("=", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doEQU));
|
||||
pushopcode("EQU", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doEQU));
|
||||
pushopcode("END", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doEND));
|
||||
pushopcode("MX", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doMX));
|
||||
pushopcode("XC", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doXC));
|
||||
pushopcode("END", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doEND));
|
||||
pushopcode("MX", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doMX));
|
||||
pushopcode("XC", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doXC));
|
||||
|
||||
pushopcode("EXT", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("EXT", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("ENT", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("ORG", P_ORG, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DSK", P_SAV, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
|
|
16
parms.json
16
parms.json
|
@ -7,20 +7,26 @@
|
|||
"0": "${PWD}"
|
||||
},
|
||||
{
|
||||
"1": "0/source"
|
||||
"1": "${QASM_BASE}"
|
||||
},
|
||||
{
|
||||
"2": "0/object"
|
||||
},
|
||||
{
|
||||
"3": "0/macros"
|
||||
"3": "1/macros"
|
||||
},
|
||||
{
|
||||
"4": "1/toolmacs"
|
||||
},
|
||||
{
|
||||
"5": "../backup"
|
||||
}
|
||||
]
|
||||
},
|
||||
"language": "qasm",
|
||||
"asm": {
|
||||
"language": "merlin16plus",
|
||||
"cpu": "M6502",
|
||||
"start_mx": 2,
|
||||
"cpu": "M65816",
|
||||
"start_mx": 0,
|
||||
"listmode": "on",
|
||||
"casesen": true,
|
||||
"start_lst": false,
|
||||
|
|
58
psuedo.cpp
58
psuedo.cpp
|
@ -793,6 +793,7 @@ int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
uint8_t delimiter = 0;
|
||||
uint32_t ss = 0;
|
||||
uint32_t lastdelimidx = 0;
|
||||
bool dci = false;
|
||||
|
||||
std::vector<uint8_t> bytes;
|
||||
|
||||
|
@ -890,7 +891,6 @@ int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
{
|
||||
uint32_t i;
|
||||
bool reverse = false;
|
||||
bool dci = false;
|
||||
uint8_t andval = 0xFF;
|
||||
uint8_t orval = 0x00;
|
||||
uint8_t addlen = 0;
|
||||
|
@ -956,28 +956,42 @@ int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
b |= orval;
|
||||
}
|
||||
|
||||
if (dci && (i == lastdelimidx))
|
||||
if ((line.options->isMerlin32()) || (line.options->isMerlin16plus()))
|
||||
{
|
||||
// SGQ BUG - Merlin16+ does it like Merlin32 and now does the last
|
||||
// byte not the way merlin816 and earlier do it documented below.
|
||||
// use OPTION_M16_PLUS when implemented.
|
||||
// invert last byte of total bytes out
|
||||
|
||||
//lr - Merlin only toggles the high bit of string chars, not hex values
|
||||
// 8D,'Hello',8D,'there',8D becomes 8D 48 65 6C 6C 6F 8D 74 68 65 72 E5
|
||||
//
|
||||
// The DCI instruction is documented to work like this on page 108
|
||||
// (regardless of how this effects the desired lda, (bpl/bmi) functionality)
|
||||
//
|
||||
// I am now checking the delimiter character to determine hi/lo toggle (reversed)
|
||||
// and am tracking the index to the last delimited character put into 'bytes'.
|
||||
// This produces the same results as Merlin 16+ in my testing.
|
||||
if ( firstdelim >= '\'' )
|
||||
if ((dci) && ((i+1)>=truebytect))
|
||||
{
|
||||
b |= 0x80;
|
||||
b^=0x80;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("bug\n");
|
||||
// invert last byte of last string (old merlin way (pre-merlin16+))
|
||||
if (dci && (i == lastdelimidx))
|
||||
{
|
||||
b &= 0x7F;
|
||||
// SGQ BUG - Merlin16+ does it like Merlin32 and now does the last
|
||||
// byte not the way merlin816 and earlier do it documented below.
|
||||
// use OPTION_M16_PLUS when implemented.
|
||||
|
||||
//lr - Merlin only toggles the high bit of string chars, not hex values
|
||||
// 8D,'Hello',8D,'there',8D becomes 8D 48 65 6C 6C 6F 8D 74 68 65 72 E5
|
||||
//
|
||||
// The DCI instruction is documented to work like this on page 108
|
||||
// (regardless of how this effects the desired lda, (bpl/bmi) functionality)
|
||||
//
|
||||
// I am now checking the delimiter character to determine hi/lo toggle (reversed)
|
||||
// and am tracking the index to the last delimited character put into 'bytes'.
|
||||
// This produces the same results as Merlin 16+ in my testing.
|
||||
if ( firstdelim >= '\'' )
|
||||
{
|
||||
b |= 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
b &= 0x7F;
|
||||
}
|
||||
}
|
||||
}
|
||||
line.outbytes.push_back(b);
|
||||
|
@ -986,7 +1000,7 @@ int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
bytect = bytect + addlen;
|
||||
|
||||
}
|
||||
//printf("XXX bytect=%d bytes.size()=%zu\n",bytect,bytes.size());
|
||||
//printf("XXX bytect=%d bytes.size()=%zu\n",bytect,bytes.size());
|
||||
|
||||
line.outbytect = bytect;
|
||||
return bytect;
|
||||
|
@ -1033,7 +1047,8 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
|
||||
#if 0
|
||||
// Merlin32 seems to have a bug where ORG seems like it can only be 16 bits
|
||||
if ((line.syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32)
|
||||
//if ((line.syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32)
|
||||
if (options.isMerlin32())
|
||||
{
|
||||
// so clear the bank word in all variables
|
||||
a.PC.orgsave &= 0xFFFF;
|
||||
|
@ -1048,7 +1063,8 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
sp = getConfig("option.objfile", "");
|
||||
if (sp=="")
|
||||
{
|
||||
a.savepath = a.processFilename(line.operand, Poco::Path::current(), 0);
|
||||
//a.savepath = a.processFilename(line.operand, Poco::Path::current(), 0);
|
||||
a.savepath=line.operand;
|
||||
}
|
||||
else // if they specified an output name on the command line, use it.
|
||||
{
|
||||
|
|
16
qasm.cpp
16
qasm.cpp
|
@ -115,10 +115,11 @@ int CLASS::runCommandLineApp(void)
|
|||
return (res);
|
||||
}
|
||||
|
||||
options.ReadFile(Poco::Path::config()+"/parms.json");
|
||||
options.ReadFile(appPath+"/parms.json");
|
||||
options.ReadFile(Poco::Path::configHome()+"/parms.json");
|
||||
options.ReadFile(Poco::Path::current()+"/parms.json");
|
||||
//printf("apppath: |%s|\n",appPath.c_str());
|
||||
options.ReadFile(Poco::Path::config()+"/parms.json",false);
|
||||
options.ReadFile(appPath+"/parms.json",true);
|
||||
options.ReadFile(Poco::Path::configHome()+"/parms.json",false);
|
||||
options.ReadFile(Poco::Path::current()+"/parms.json",false);
|
||||
|
||||
syn="QASM";
|
||||
|
||||
|
@ -145,6 +146,7 @@ int CLASS::runCommandLineApp(void)
|
|||
}
|
||||
|
||||
language=syn;
|
||||
options.setLanguage(syn,true);
|
||||
|
||||
if (isDebug()>0)
|
||||
{
|
||||
|
@ -237,7 +239,7 @@ int CLASS::runCommandLineApp(void)
|
|||
try
|
||||
{
|
||||
t->init();
|
||||
t->setLanguage(language);
|
||||
t->setLanguage(language,true);
|
||||
t->format_flags=format_flags;
|
||||
|
||||
std::string f = path.toString();
|
||||
|
@ -271,7 +273,7 @@ int CLASS::runCommandLineApp(void)
|
|||
try
|
||||
{
|
||||
t->init();
|
||||
t->setLanguage(language);
|
||||
t->setLanguage(language,true);
|
||||
|
||||
|
||||
std::string f = path.toString();
|
||||
|
@ -308,7 +310,7 @@ int CLASS::runCommandLineApp(void)
|
|||
try
|
||||
{
|
||||
t->init();
|
||||
t->setLanguage(language);
|
||||
t->setLanguage(language,true);
|
||||
|
||||
std::string f = path.toString();
|
||||
t->filename = f;
|
||||
|
|
385
qoptions.h
385
qoptions.h
|
@ -3,6 +3,8 @@
|
|||
|
||||
using namespace Poco;
|
||||
|
||||
#define ENV_QASM "QASM_BASE"
|
||||
|
||||
#define MAX_PREFIX 32
|
||||
|
||||
#define MODE_6502 0
|
||||
|
@ -10,13 +12,15 @@ using namespace Poco;
|
|||
#define MODE_65816 2
|
||||
|
||||
#define SYNTAX_MERLIN 0x01
|
||||
#define SYNTAX_MERLIN32 0x02
|
||||
#define SYNTAX_APW 0x04
|
||||
#define SYNTAX_MPW 0x08
|
||||
#define SYNTAX_ORCA 0x10
|
||||
#define SYNTAX_CC65 0x20
|
||||
#define SYNTAX_LISA 0x40
|
||||
#define SYNTAX_QASM (0x80 | SYNTAX_MERLIN)
|
||||
#define SYNTAX_MERLIN16 0x02
|
||||
#define SYNTAX_MERLIN16PLUS 0x04
|
||||
#define SYNTAX_MERLIN32 0x08
|
||||
#define SYNTAX_APW 0x10
|
||||
#define SYNTAX_MPW 0x20
|
||||
#define SYNTAX_ORCA 0x40
|
||||
#define SYNTAX_CC65 0x80
|
||||
#define SYNTAX_LISA 0x100
|
||||
#define SYNTAX_QASM (0x200 | SYNTAX_MERLIN)
|
||||
|
||||
#define OPTION_ALLOW_A_OPERAND 0x0100
|
||||
#define OPTION_ALLOW_LOCAL 0x0200
|
||||
|
@ -41,11 +45,11 @@ class CLASS
|
|||
{
|
||||
protected:
|
||||
//vector<shared_ptr<JSONConfiguration>> configs;
|
||||
|
||||
vector<std::string> valid_files;
|
||||
public:
|
||||
Poco::JSON::Parser parser;
|
||||
string jsonin;
|
||||
Dynamic::Var jsonobj=NULL;
|
||||
//Poco::JSON::Parser parser;
|
||||
//string jsonin;
|
||||
//Dynamic::Var jsonobj=NULL;
|
||||
uint16_t format_flags;
|
||||
|
||||
uint16_t cpu_mode;
|
||||
|
@ -70,23 +74,34 @@ public:
|
|||
int16_t linebytes;
|
||||
int16_t overflowbytes;
|
||||
|
||||
myLayeredConfiguration config;
|
||||
myLayeredConfiguration *config=NULL;
|
||||
|
||||
bool usecolor;
|
||||
|
||||
CLASS()
|
||||
{
|
||||
language="";
|
||||
setEnvironment();
|
||||
clear();
|
||||
setDefaults();
|
||||
setLanguage("QASM");
|
||||
setLanguage("QASM",true);
|
||||
setCurrent();
|
||||
}
|
||||
~CLASS()
|
||||
{
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
//configs.clear();
|
||||
if (config!=NULL)
|
||||
{
|
||||
delete config;
|
||||
config=NULL;
|
||||
}
|
||||
config=new myLayeredConfiguration();
|
||||
valid_files.clear();
|
||||
|
||||
}
|
||||
|
||||
bool useColor(void)
|
||||
|
@ -125,6 +140,8 @@ public:
|
|||
int printDefaults(string lang)
|
||||
{
|
||||
int res=-1;
|
||||
string s;
|
||||
int i;
|
||||
string l=Poco::toUpper(lang);
|
||||
if (l=="")
|
||||
{
|
||||
|
@ -132,24 +149,46 @@ public:
|
|||
}
|
||||
if (l!="")
|
||||
{
|
||||
setLanguage(l);
|
||||
setLanguage(l,false);
|
||||
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\tLanguage:\t\t\t%s\n",language.c_str());
|
||||
printf("\t\tlanguageLevel:\t\t\t%d\n",langlevel);
|
||||
s="<unknown>";
|
||||
switch(cpu_mode)
|
||||
{
|
||||
case 0:
|
||||
s="M6502";
|
||||
break;
|
||||
case 1:
|
||||
s="M65C02";
|
||||
break;
|
||||
case 2:
|
||||
s="M65816";
|
||||
break;
|
||||
}
|
||||
printf("\t\tcpu_mode:\t\t\t%s\n",s.c_str());
|
||||
printf("\t\tstart_mx:\t\t\t%%%d%d\n",start_mx&0x02?1:0,start_mx&0x01?1:0);
|
||||
//printf("\t\tstart_mx:\t\t\t%d\n",start_mx);
|
||||
printf("\t\tPrefixes:\n");
|
||||
|
||||
for (int i=0; i<MAX_PREFIX; i++)
|
||||
for (i=0; i<MAX_PREFIX; i++)
|
||||
{
|
||||
if (prefixes[i].length()>0)
|
||||
{
|
||||
printf("\t\t\t%02d:\t\t\t%s\n",i,prefixes[i].c_str());
|
||||
printf("\t\t\t%2d:\t%s\n",i,prefixes[i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
for (unsigned long ii=0; ii<valid_files.size(); ii++)
|
||||
{
|
||||
if (prefixes[ii].length()>0)
|
||||
{
|
||||
printf("\t\tSettings files read: \t%s\n",valid_files[ii].c_str());
|
||||
}
|
||||
}
|
||||
//uint16_t format_flags;
|
||||
|
||||
|
||||
|
@ -160,68 +199,292 @@ public:
|
|||
return(res);
|
||||
}
|
||||
|
||||
int ReadFile(string path)
|
||||
string getAppPath()
|
||||
{
|
||||
char buff[PATH_MAX+1];
|
||||
char *x;
|
||||
|
||||
string res="";
|
||||
res=Poco::Util::Application::instance().commandPath();
|
||||
x=realpath(res.c_str(),buff);
|
||||
if (x!=NULL)
|
||||
{
|
||||
res=buff;
|
||||
}
|
||||
else
|
||||
{
|
||||
res="";
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
int ReadFile(string path, bool backtrack)
|
||||
{
|
||||
//int levels=0;
|
||||
bool done=false;
|
||||
int ret=-1;
|
||||
unsigned long ii;
|
||||
Poco::Util::JSONConfiguration *jc;
|
||||
|
||||
Poco::Path pp(path);
|
||||
//pp=pp.expand();
|
||||
Poco::File pf(pp);
|
||||
if (isDebug()>1)
|
||||
while(!done)
|
||||
{
|
||||
printf("parmsfile: %s\n",pp.toString().c_str());
|
||||
}
|
||||
if ((pf.exists()) && (pf.canRead()) && ((pf.isFile()) || (pf.isLink())))
|
||||
{
|
||||
//printf("OK: %s\n",pp.toString().c_str());
|
||||
Poco::Path pp(path);
|
||||
//pp=pp.absolute(Poco::Path("/"));
|
||||
pp=pp.absolute();
|
||||
|
||||
jc=new Poco::Util::JSONConfiguration();
|
||||
//Poco::FileInputStream fs(path);
|
||||
//Poco::StreamCopier::copyToString(fs,jsonin);
|
||||
//parser.reset();
|
||||
//parser.setAllowComments(true);
|
||||
//jsonobj=parser.parse(jsonin);
|
||||
if (jc!=NULL)
|
||||
std::string basename=pp.getFileName();
|
||||
|
||||
Poco::File pf(pp);
|
||||
if (isDebug()>1)
|
||||
{
|
||||
bool success=false;
|
||||
try
|
||||
//pf.
|
||||
printf(" %d parmsfile: %s ",backtrack,pf.path().c_str());
|
||||
}
|
||||
if ((pf.exists()) && (pf.canRead()) && ((pf.isFile()) || (pf.isLink())))
|
||||
{
|
||||
if (isDebug()>1)
|
||||
{
|
||||
jc->load(pp.toString());
|
||||
success=true;
|
||||
printf("...found!\n");
|
||||
}
|
||||
catch(...)
|
||||
//printf("OK: %s\n",pp.toString().c_str());
|
||||
done=false;
|
||||