From 7534c45defa84ad29076d10af997e6c34ec42aa5 Mon Sep 17 00:00:00 2001 From: marketideas Date: Tue, 19 Nov 2019 12:06:08 -0800 Subject: [PATCH] ]var EQU does an eval first and updates the variable to the resulting hex value --- asm.cpp | 43 +++++++++++++++++++++++++------------------ asm.h | 2 ++ opcodes.cpp | 15 +++++++++++++-- psuedo.cpp | 11 +++++++++++ psuedo.h | 1 + 5 files changed, 52 insertions(+), 20 deletions(-) diff --git a/asm.cpp b/asm.cpp index 71e0bf9..9a010b5 100644 --- a/asm.cpp +++ b/asm.cpp @@ -205,7 +205,14 @@ void CLASS::print(uint32_t lineno) { pcol += printf(" "); } - pcol += printf("%s ", printoperand.c_str()); + if (isDebug() > 2) + { + pcol += printf("%s ", operand.c_str()); + } + else + { + pcol += printf("%s ", printoperand.c_str()); + } //pcol += printf("%-12s %-8s %-10s ", printlable.c_str(), opcode.c_str(), operand.c_str()); } if ((errorcode > 0) && (!merlinerrors)) @@ -290,7 +297,7 @@ void CLASS::clear() opcode = ""; opcodelower = ""; operand = ""; - printoperand=""; + printoperand = ""; comment = ""; operand_expr = ""; operand_expr2 = ""; @@ -1327,20 +1334,20 @@ int CLASS::callOpCode(std::string op, MerlinLine &line) case '>': line.expr_value >>= 8; line.expr_value &= 0xFFFF; - if ((line.syntax&SYNTAX_MERLIN32)==SYNTAX_MERLIN32) + if ((line.syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32) { line.flags |= FLAG_FORCEABS; } break; case '^': line.expr_value = (line.expr_value >> 16) & 0xFFFF; - if ((line.syntax&SYNTAX_MERLIN32)==SYNTAX_MERLIN32) + if ((line.syntax & SYNTAX_MERLIN32) == SYNTAX_MERLIN32) { line.flags |= FLAG_FORCEABS; } break; case '|': - if ((line.syntax&SYNTAX_MERLIN32)!=SYNTAX_MERLIN32) + if ((line.syntax & SYNTAX_MERLIN32) != SYNTAX_MERLIN32) { line.flags |= FLAG_FORCELONG; } @@ -1820,8 +1827,8 @@ int CLASS::substituteVariables(MerlinLine & line, std::string &outop) uint32_t len, off, ct; bool done = false; - operin=oper; - ct=0; + operin = oper; + ct = 0; restart: while (!done) { @@ -1873,28 +1880,28 @@ restart: } else { - done=true; + done = true; } offset += len; } else { offset = slen; - done=true; + done = true; } } } else { - done=true; + done = true; } } //printf("inoper=|%s| outoper=|%s|\n",operin.c_str(),oper.c_str()); - if (ct>0) + if (ct > 0) { - outop=oper; - res=ct; + outop = oper; + res = ct; } return (res); } @@ -1996,14 +2003,14 @@ void CLASS::process(void) } } std::string outop; - if (pass==0) + if (pass == 0) { - line.printoperand=line.operand; + line.printoperand = line.operand; } - x = substituteVariables(line,outop); - if (x>0) + x = substituteVariables(line, outop); + if (x > 0) { - line.operand=outop; + line.operand = outop; } x = parseOperand(line); if (x >= 0) diff --git a/asm.h b/asm.h index 842ffa4..aa0e88e 100644 --- a/asm.h +++ b/asm.h @@ -78,6 +78,7 @@ enum asmErrors errBadLUPOperand, errBadLabel, errBadOperand, + errErrOpcode, errMAX }; @@ -112,6 +113,7 @@ const std::string errStrings[errMAX + 1] = "LUP value must be 0 < VAL <= $8000", "Unknown label", "Bad operand", + "Break", "" }; diff --git a/opcodes.cpp b/opcodes.cpp index 58afdbd..d603a99 100644 --- a/opcodes.cpp +++ b/opcodes.cpp @@ -94,7 +94,18 @@ int CLASS::doEQU(MerlinLine &line, TSymbol &sym) else if (isvar) { res = -1; - s = addVariable(line.lable, line.operand, true); + + if (syntax==SYNTAX_MERLIN) + { + char buff[32]; + sprintf(buff,"$%08X",line.expr_value); + std::string s1=buff; + s = addVariable(line.lable, s1, true); + } + else + { + s = addVariable(line.lable, line.operand, true); + } if (s != NULL) { res = 0; @@ -849,7 +860,7 @@ void CLASS::insertOpcodes(void) pushopcode("IF", P_DO, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("FIN", P_DO, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("CHK", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); - pushopcode("ERR", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); + pushopcode("ERR", P_ERR, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("KBD", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("LUP", P_LUP, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("--^", P_LUP, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); diff --git a/psuedo.cpp b/psuedo.cpp index fdfa6a8..d42e7a8 100644 --- a/psuedo.cpp +++ b/psuedo.cpp @@ -844,6 +844,17 @@ 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_ERR: + if (a.pass>0) + { + if ((line.expr_value!=0) || (line.eval_result<0)) + { + line.setError(errErrOpcode); + //a.passcomplete=true; // terminate assembly + } + } + res=0; + break; case P_LST: res = doLST(a, line, opinfo); break; diff --git a/psuedo.h b/psuedo.h index 7251ca9..94edb92 100644 --- a/psuedo.h +++ b/psuedo.h @@ -19,6 +19,7 @@ enum P_DO, P_TR, P_ASC, + P_ERR, P_MAX };