diff --git a/asm.cpp b/asm.cpp index 125352f..9d28d19 100644 --- a/asm.cpp +++ b/asm.cpp @@ -208,7 +208,7 @@ void CLASS::print(uint32_t lineno) } uint32_t ct = 1; - if (obc > b) + if ((obc > b) && ((truncdata&0x01)==0)) { ct = 0; uint8_t db; @@ -1293,7 +1293,7 @@ void CLASS::initpass(void) passcomplete = false; dumstartaddr = 0; dumstart = 0; - + truncdata=0; variables.clear(); // clear the variables for each pass while (!PCstack.empty()) @@ -1308,6 +1308,10 @@ void CLASS::initpass(void) { DOstack.pop(); } + while (!LSTstack.empty()) + { + LSTstack.pop(); + } curLUP.clear(); curDO.clear(); savepath = ""; @@ -1622,6 +1626,7 @@ void CLASS::process(void) line.eval_result = 0; line.lineno = lineno + 1; + line.truncdata=truncdata; //printf("lineno: %d %d |%s|\n",lineno,l,line.operand.c_str()); op = Poco::toLower(line.opcode); diff --git a/asm.h b/asm.h index 1ccab1c..a8f3b7b 100644 --- a/asm.h +++ b/asm.h @@ -189,6 +189,7 @@ public: uint8_t linemx; uint16_t commentcol; bool showmx; + uint8_t truncdata; uint32_t lineno; uint32_t flags; uint16_t opflags; @@ -330,7 +331,6 @@ class T65816Asm : public TFileProcessor public: // options bool casesen; - bool listing; bool showmx; bool trackrep; bool merlincompat; @@ -356,10 +356,13 @@ public: TOriginSection PC; TLUPstruct curLUP; TDOstruct curDO; + bool listing; + uint8_t truncdata; // for the TR opcode std::stack PCstack; std::stack LUPstack; std::stack DOstack; + std::stack LSTstack; TPsuedoOp *psuedoops; diff --git a/opcodes.cpp b/opcodes.cpp index f4f8b20..b1f60a3 100644 --- a/opcodes.cpp +++ b/opcodes.cpp @@ -738,7 +738,7 @@ void CLASS::insertOpcodes(void) pushopcode("PAG", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("TTL", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("SKP", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); - pushopcode("TR", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); + pushopcode("TR", P_TR, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("ASC", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("DCI", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("INV", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); diff --git a/psuedo.cpp b/psuedo.cpp index 0cdde64..ff7f736 100644 --- a/psuedo.cpp +++ b/psuedo.cpp @@ -27,8 +27,8 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) int err = 0; std::string op = Poco::toUpper(line.opcode); - std::string oper = Poco::toUpper(line.operand_expr); - result32=0xFFFFFFFF; + std::string oper = line.operand_expr; + result32 = 0xFFFFFFFF; if (op == "IF") { @@ -46,7 +46,7 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) if (oper == "") { err = errIllegalCharOperand; - a.curDO.doskip=false; + a.curDO.doskip = false; goto out; } @@ -66,7 +66,7 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) } result32 = eval_result & 0xFFFFFFFF; - a.curDO.doskip = (result32!=0) ? false : true; + a.curDO.doskip = (result32 != 0) ? false : true; goto out; } @@ -98,7 +98,7 @@ int CLASS::doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) { // kind of a silent error here, just make sure we reinitialize err = errUnexpectedOp; - a.curDO.doskip=false; + a.curDO.doskip = false; } goto out; } @@ -375,7 +375,15 @@ int CLASS::doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) if (a.pass > 0) { s = Poco::toUpper(Poco::trim(line.operand_expr)); - if ((s == "") || (s == "ON") || (line.expr_value > 0)) + if (s == "RTN") + { + if (a.LSTstack.size()) + { + a.listing = a.LSTstack.top(); + a.LSTstack.pop(); + } + } + else if ((s == "ON") || (line.expr_value > 0)) { //printf("ON\n"); a.skiplist = true; @@ -391,6 +399,29 @@ int CLASS::doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) return (0); } +int CLASS::doTR(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) +{ + UNUSED(opinfo); + + std::string s; + if (a.pass > 0) + { + s = Poco::toUpper(Poco::trim(line.operand_expr)); + if (s == "ADR") + { + a.truncdata |= 0x03; + } + else if ((s == "ON") || (line.expr_value > 0)) + { + a.truncdata |= 0x01;; + } + else if ((s == "OFF") || (line.expr_value == 0)) + { + a.truncdata = 0x00; + } + } + return (0); +} int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) { UNUSED(opinfo); @@ -523,6 +554,9 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) case P_DO: res = doDO(a, line, opinfo); break; + case P_TR: + res=doTR(a,line,opinfo); + break; } return (res); diff --git a/psuedo.h b/psuedo.h index 00b1613..d59a38f 100644 --- a/psuedo.h +++ b/psuedo.h @@ -17,6 +17,7 @@ enum P_DATA, P_LUP, P_DO, + P_TR, P_MAX }; @@ -33,9 +34,8 @@ public: int doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); int doDATA(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); int doLUP(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); - int doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);; - - + int doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); + int doTR(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); }; #undef CLASS \ No newline at end of file