This commit is contained in:
marketideas 2019-11-22 09:33:24 -08:00
parent 279de5caa5
commit 476a46d7db
4 changed files with 49 additions and 14 deletions

37
asm.cpp
View File

@ -1239,6 +1239,11 @@ TSymbol * CLASS::findVariable(std::string symname, TVariable &vars)
{
TSymbol *res = NULL;
if (!casesen)
{
symname = Poco::toUpper(symname);
}
if ((expand_macrostack.size() > 0) && (vars.id != expand_macro.variables.id))
{
res = findVariable(symname, expand_macro.variables);
@ -1978,7 +1983,7 @@ restart:
off = mVec[0].offset;
len = mVec[0].length;
s = oper.substr(off, len);
slen = s.length();
sym = NULL;
if (expand_macrostack.size() > 0)
{
@ -1995,6 +2000,7 @@ restart:
if (sym->var_text != "")
{
oper = oper.replace(off, len, sym->var_text);
slen = oper.length();
ct++;
if (pass > 0)
{
@ -2201,7 +2207,11 @@ void CLASS::process(void)
std::string outop;
line.printoperand = line.operand;
x = substituteVariables(line, outop);
x = 0;
if (macrostack.size() == 0)
{
x = substituteVariables(line, outop);
}
if (x > 0)
{
line.printoperand = outop;
@ -2243,20 +2253,23 @@ void CLASS::process(void)
{
TMacro *mac = NULL;
bool inoperand = false;
mac = findMacro(realop);
if (mac == NULL)
if (macrostack.size() == 0)
{
if (op == ">>>") // specal merlin way of calling a macro
mac = findMacro(realop);
if (mac == NULL)
{
Poco::StringTokenizer tok(operand, ", ", Poco::StringTokenizer::TOK_TRIM |
Poco::StringTokenizer::TOK_IGNORE_EMPTY);
std::string s = "";
if (tok.count() > 0)
if (op == ">>>") // specal merlin way of calling a macro
{
s = tok[0];
Poco::StringTokenizer tok(operand, ", ", Poco::StringTokenizer::TOK_TRIM |
Poco::StringTokenizer::TOK_IGNORE_EMPTY);
std::string s = "";
if (tok.count() > 0)
{
s = tok[0];
}
mac = findMacro(s);
inoperand = true;
}
mac = findMacro(s);
inoperand = true;
}
}
if (mac == NULL)

View File

@ -846,6 +846,7 @@ void CLASS::insertOpcodes(void)
pushopcode("DUM", P_DUM, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("DEND", P_DEND, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("AST", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("CAS", P_CAS, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("CYC", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("DAT", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("EXP", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));

View File

@ -36,7 +36,7 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
UNUSED(opinfo);
TEvaluator eval(a);
eval.allowMX=true; // allow the built in MX symbol
eval.allowMX = true; // allow the built in MX symbol
int64_t eval_value = 0;
uint8_t shift;
@ -141,8 +141,9 @@ int CLASS::doMAC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
std::string op = Poco::toUpper(line.opcode);
if (op == "MAC")
{
if (a.expand_macrostack.size()>0)
if (a.expand_macrostack.size() > 0)
{
line.flags |= FLAG_NOLINEPRINT;
goto out;
}
if (line.lable.length() == 0)
@ -157,6 +158,12 @@ int CLASS::doMAC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
a.currentmacro.lcname = Poco::toLower(line.lable);
a.currentmacro.start = line.lineno;
a.currentmacro.running = true;
if (!a.casesen)
{
a.currentmacro.name = Poco::toUpper(a.currentmacro.name);
}
if (a.pass == 0)
{
}
@ -899,6 +906,7 @@ int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
{
int res = 0;
std::string s;
switch (opinfo.opcode)
{
@ -949,6 +957,18 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
case P_SAV:
a.savepath = a.processFilename(line.operand, Poco::Path::current(), 0);
break;
case P_CAS:
s = Poco::toUpper(line.operand);
if (s == "SE")
{
a.casesen = true;
}
if (s=="IN")
{
a.casesen=false;
}
res = 0;
break;
case P_MAC:
res = doMAC(a, line, opinfo);
break;

View File

@ -21,6 +21,7 @@ enum
P_ASC,
P_ERR,
P_MAC,
P_CAS,
P_MAX
};