mirror of
https://github.com/marketideas/qasm.git
synced 2025-01-14 11:29:46 +00:00
test
This commit is contained in:
parent
568c09b91e
commit
022eaa0438
23
asm.cpp
23
asm.cpp
@ -34,7 +34,7 @@ void CLASS::print(uint32_t lineno)
|
||||
|
||||
uint32_t b = 4; // how many bytes show on the first line
|
||||
|
||||
bool merlinstyle=true;
|
||||
bool merlinstyle = true;
|
||||
|
||||
if (datafillct > 0)
|
||||
{
|
||||
@ -53,7 +53,7 @@ void CLASS::print(uint32_t lineno)
|
||||
if (merlinstyle)
|
||||
{
|
||||
//printf("errorcode=%d\n",errorcode);
|
||||
printf("%s in line: %d", errStrings[errorcode].c_str(), lineno+1);
|
||||
printf("%s in line: %d", errStrings[errorcode].c_str(), lineno + 1);
|
||||
if (errorText != "")
|
||||
{
|
||||
printf("%s", errorText.c_str());
|
||||
@ -1086,6 +1086,7 @@ int CLASS::callOpCode(std::string op, MerlinLine &line)
|
||||
{
|
||||
int res = -1;
|
||||
char c;
|
||||
std::string s;
|
||||
|
||||
if (op.length() == 4) // check for 4 digit 'L' opcodes
|
||||
{
|
||||
@ -1101,7 +1102,12 @@ int CLASS::callOpCode(std::string op, MerlinLine &line)
|
||||
line.flags |= FLAG_FORCELONG; // 3 byte address
|
||||
break;
|
||||
default: // any char but 'L' as in Merlin 16+
|
||||
if ((c != 'D') || (Poco::toUpper(op) != "DEND"))
|
||||
s = Poco::toUpper(op);
|
||||
if ((s == "ELSE") || (s == "DEND"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (c != 'D')
|
||||
{
|
||||
op = op.substr(0, 3);
|
||||
line.flags |= FLAG_FORCEABS; // 2 byte address
|
||||
@ -1249,7 +1255,6 @@ void CLASS::initpass(void)
|
||||
allowdup = getBool("asm.allowduplicate", true);
|
||||
|
||||
skiplist = false;
|
||||
generateCode = true;
|
||||
|
||||
PC.origin = 0x8000;
|
||||
PC.currentpc = PC.origin;
|
||||
@ -1583,14 +1588,15 @@ int CLASS::substituteVariables(MerlinLine & line)
|
||||
return (res);
|
||||
}
|
||||
|
||||
// this function determines if code generation is turned off (IF,DO,LUP,MAC, etc
|
||||
bool CLASS::codeSkipped(void)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
if (curLUP.lupskip)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
res = (curLUP.lupskip) ? true : res;
|
||||
res = (curDO.doskip) ? true : res;
|
||||
|
||||
//printf("codeskip: %d\n",res);
|
||||
|
||||
return (res);
|
||||
}
|
||||
@ -1690,6 +1696,7 @@ void CLASS::process(void)
|
||||
if ((x > 0) && (codeSkipped())) // has a psuedo-op turned off code generation? (LUP, IF, etc)
|
||||
{
|
||||
x = 0;
|
||||
line.outbytect=0;
|
||||
}
|
||||
|
||||
if (x > 0)
|
||||
|
8
asm.h
8
asm.h
@ -79,7 +79,7 @@ const std::string errStrings[errMAX + 1] =
|
||||
"Unimplemented Instruction",
|
||||
"Fatal",
|
||||
"Unsupported Addressing Mode",
|
||||
"Unknown Opcode",
|
||||
"Bad opcode",
|
||||
"Opcode not available under CPU mode",
|
||||
"Byte output differs between passes",
|
||||
"Relative branch offset too large",
|
||||
@ -282,11 +282,11 @@ public:
|
||||
clear();
|
||||
}
|
||||
void clear(void) {
|
||||
dooff=false;
|
||||
doskip=false;
|
||||
value=0;
|
||||
}
|
||||
uint32_t value;
|
||||
bool dooff;
|
||||
bool doskip;
|
||||
};
|
||||
|
||||
class TSymbol;
|
||||
@ -345,8 +345,6 @@ public:
|
||||
bool skiplist; // used if lst is on, but LST opcode turns it off
|
||||
uint32_t lineno;
|
||||
|
||||
bool generateCode;
|
||||
|
||||
std::string savepath;
|
||||
TSymbol *currentsym;
|
||||
std::vector<MerlinLine> lines;
|
||||
|
58
psuedo.cpp
58
psuedo.cpp
@ -22,12 +22,13 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
|
||||
int64_t eval_result = 0;
|
||||
uint8_t shift;
|
||||
uint32_t result32;
|
||||
int res = 0;
|
||||
int err = 0;
|
||||
|
||||
std::string op = Poco::toUpper(line.opcode);
|
||||
std::string oper = Poco::toUpper(line.operand);
|
||||
|
||||
std::string oper = Poco::toUpper(line.operand_expr);
|
||||
result32=0xFFFFFFFF;
|
||||
|
||||
if (op == "IF")
|
||||
{
|
||||
@ -40,37 +41,47 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
if (op == "DO")
|
||||
{
|
||||
|
||||
a.DOstack.push(a.curDO);
|
||||
|
||||
if (oper == "")
|
||||
{
|
||||
err = errIllegalCharOperand;
|
||||
a.curDO.doskip=false;
|
||||
goto out;
|
||||
}
|
||||
|
||||
//line.flags |= FLAG_NOLINEPRINT;
|
||||
|
||||
shift = 0;
|
||||
eval_result = 0;
|
||||
int x = eval.evaluate(line.operand, eval_result, shift);
|
||||
a.curDO.dooff = (eval_result & 0xFFFFFF); // evaluate here
|
||||
int x = eval.evaluate(line.operand_expr, eval_result, shift);
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
a.curDO.dooff = false;
|
||||
a.curDO.doskip = false;
|
||||
err = errBadLabel;
|
||||
if (a.pass == 0)
|
||||
{
|
||||
err = errForwardRef;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
a.DOstack.push(a.curDO);
|
||||
result32 = eval_result & 0xFFFFFFFF;
|
||||
a.curDO.doskip = (result32!=0) ? false : true;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (op == "ELSE")
|
||||
{
|
||||
//line.flags |= FLAG_NOLINEPRINT;
|
||||
a.curDO.dooff = !a.curDO.dooff;
|
||||
if (a.DOstack.size() > 0)
|
||||
{
|
||||
//line.flags |= FLAG_NOLINEPRINT;
|
||||
a.curDO.doskip = !a.curDO.doskip;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = errUnexpectedOp;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -80,20 +91,21 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
|
||||
if (a.DOstack.size() > 0)
|
||||
{
|
||||
// kind of a silent error here, just make sure we reinitialize
|
||||
a.curDO.dooff = false;
|
||||
a.curDO = a.DOstack.top();
|
||||
a.DOstack.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// kind of a silent error here, just make sure we reinitialize
|
||||
a.curDO.dooff = false;
|
||||
err = errUnexpectedOp;
|
||||
a.curDO.doskip=false;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
//printf("DO eval: %08X %s\n", result32, a.curDO.doskip ? "true" : "false");
|
||||
|
||||
if (err > 0)
|
||||
{
|
||||
line.setError(err);
|
||||
@ -124,7 +136,7 @@ int CLASS::doLUP(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
|
||||
shift = 0;
|
||||
eval_result = 0;
|
||||
int x = eval.evaluate(line.operand, eval_result, shift);
|
||||
int x = eval.evaluate(line.operand_expr, eval_result, shift);
|
||||
|
||||
a.LUPstack.push(a.curLUP);
|
||||
|
||||
@ -209,7 +221,7 @@ int CLASS::doDATA(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
int outct = 0;
|
||||
int wordsize = 2;
|
||||
int endian = 0;
|
||||
std::string oper = line.operand;
|
||||
std::string oper = line.operand_expr;
|
||||
std::string op = Poco::toUpper(Poco::trim(line.opcode));
|
||||
Poco::StringTokenizer tok(oper, ",", Poco::StringTokenizer::TOK_TRIM |
|
||||
Poco::StringTokenizer::TOK_IGNORE_EMPTY);
|
||||
@ -325,16 +337,6 @@ int CLASS::doDS(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
|
||||
line.datafillbyte = line.eval_result & 0xFF;
|
||||
line.datafillct = v;
|
||||
#if 0
|
||||
if (a.pass > 0)
|
||||
{
|
||||
for (int i = 0; i < v; i++)
|
||||
{
|
||||
line.outbytes.push_back(0x00);
|
||||
}
|
||||
line.outbytect = v;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return (res);
|
||||
@ -372,7 +374,7 @@ int CLASS::doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
std::string s;
|
||||
if (a.pass > 0)
|
||||
{
|
||||
s = Poco::toUpper(Poco::trim(line.operand));
|
||||
s = Poco::toUpper(Poco::trim(line.operand_expr));
|
||||
if ((s == "") || (s == "ON") || (line.expr_value > 0))
|
||||
{
|
||||
//printf("ON\n");
|
||||
@ -393,7 +395,7 @@ int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
{
|
||||
UNUSED(opinfo);
|
||||
|
||||
std::string os = Poco::toUpper(Poco::trim(line.operand));
|
||||
std::string os = Poco::toUpper(Poco::trim(line.operand_expr));
|
||||
|
||||
uint32_t bytect = 0;
|
||||
uint8_t b = 0;
|
||||
@ -490,7 +492,7 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
|
||||
break;
|
||||
case P_ORG:
|
||||
if (line.operand.length() > 0)
|
||||
if (line.operand_expr.length() > 0)
|
||||
{
|
||||
a.PC.orgsave = a.PC.currentpc;
|
||||
a.PC.currentpc = line.expr_value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user