diff --git a/asm.cpp b/asm.cpp index 3f31b39..e2a4249 100644 --- a/asm.cpp +++ b/asm.cpp @@ -379,8 +379,6 @@ int CLASS::processfile(std::string &p) Poco::Path tp(p); Poco::Path path = tp.makeAbsolute(); - - valid = true; p1 = tp.toString(); Poco::File fn(p1); @@ -404,9 +402,6 @@ int CLASS::processfile(std::string &p) if (valid) { - - - std::ifstream f(p1); if (f.is_open()) { @@ -1063,7 +1058,7 @@ int CLASS::evaluate(MerlinLine &line, std::string expr, int64_t &value) value = result; if ((listing) && (pass > 0) && (isDebug() > 2)) { - printf("EV1=%08lX '%c'\n", v1, line.expr_shift); + printf("EV1=%08llX '%c'\n", v1, line.expr_shift); } if (v1 >= 0x10000) { @@ -1082,7 +1077,7 @@ int CLASS::evaluate(MerlinLine &line, std::string expr, int64_t &value) } if (isDebug() >= 3) { - printf("Eval Result: %08lX (status=%d)\n", value, res); + printf("Eval Result: %08llX (status=%d)\n", value, res); } return (res); } diff --git a/opcodes.cpp b/opcodes.cpp index 53cb5de..f1dabc5 100644 --- a/opcodes.cpp +++ b/opcodes.cpp @@ -731,7 +731,7 @@ void CLASS::insertOpcodes(void) pushopcode("DB", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("ADR", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("ADRL", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); - pushopcode("HEX", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); + pushopcode("HEX", p_HEX, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("DS", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("DO", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); pushopcode("ELSE", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO)); diff --git a/psuedo.cpp b/psuedo.cpp index 6cc0a06..7c139d5 100644 --- a/psuedo.cpp +++ b/psuedo.cpp @@ -67,10 +67,9 @@ int CLASS::doDUM(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) int CLASS::doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) { - std::string s; if (a.pass > 0) { - s = Poco::toUpper(Poco::trim(line.operand)); + std::string s = Poco::toUpper(Poco::trim(line.operand)); if ((s == "") || (s == "ON") || (line.expr_value > 0)) { //printf("ON\n"); @@ -87,6 +86,71 @@ int CLASS::doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) return (0); } +int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) +{ + int res = 0; + std::vector values; + values.clear(); + + std::string os = Poco::toUpper(Poco::trim(line.operand)); + std::string vs = "0123456789ABCDEF"; + std::string hex = ""; + + for( int i = 0; i < os.length(); ++i ) + { + char c = os[i]; + + // Check for a comma if needed, and continue to next char if found + if( hex.length() == 0 && c == ',' ) + continue; + + if( vs.find(c) == std::string::npos ) + { + line.setError(errBadOperand); + return -1; + } + + // Got a good char, append to hex string and see if we've got a byte + hex.append(1, c); + if( hex.length() == 2 ) + { + // Got 2 chars (1 byte), so store in values array + values.push_back(hex); + hex.clear(); + } + } + + // We can't have an odd character dangling around! + if( hex.size() != 0 ) + { + line.setError(errOverflow); + return -1; + } + + int byteCnt = (int)values.size(); + a.PC.currentpc += byteCnt; + + if (a.pass > 0) + { + for( int i = 0; i < values.size(); ++i ) + { + std::string s = "$"; + s.append(values[i]); + int64_t v; + if( 0 == a.evaluate(line, s, v) ) + { + line.outbytes.push_back((uint8_t)v); + } + } + line.outbytect = byteCnt; + } + else + { + line.pass0bytect = byteCnt; + } + return res; +} + int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) { int res = 0; @@ -97,6 +161,7 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) res = -1; // undefined p-op line.setError(errUnimplemented); break; + case P_DS: res = doDS(a, line, opinfo); break; @@ -131,6 +196,9 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo) res = doLST(a, line, opinfo); break; +] case p_HEX: + res = doHEX(a, line, opinfo); + break; } return (res); } diff --git a/psuedo.h b/psuedo.h index 92759ef..160abb6 100644 --- a/psuedo.h +++ b/psuedo.h @@ -13,6 +13,7 @@ enum P_DS, P_PUT, P_USE, + p_HEX, P_MAX }; @@ -26,9 +27,7 @@ public: int doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); int doDUM(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); int doDS(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); - - - + int doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo); }; #undef CLASS diff --git a/qasm.xcodeproj/project.pbxproj b/qasm.xcodeproj/project.pbxproj index 432d9fe..6a2e1a7 100644 --- a/qasm.xcodeproj/project.pbxproj +++ b/qasm.xcodeproj/project.pbxproj @@ -177,6 +177,7 @@ 2F5E56C4237CC2700091163D /* time */ = {isa = PBXFileReference; lastKnownFileType = file; path = time; sourceTree = ""; }; 2F5E56C5237CC2700091163D /* edit */ = {isa = PBXFileReference; lastKnownFileType = text; path = edit; sourceTree = ""; }; 2F5E56C6237CC2700091163D /* qlinkgs */ = {isa = PBXFileReference; lastKnownFileType = file; path = qlinkgs; sourceTree = ""; }; + 2F5E571B237CDF0A0091163D /* testdata */ = {isa = PBXFileReference; lastKnownFileType = folder; path = testdata; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -316,6 +317,7 @@ isa = PBXGroup; children = ( 2F5E5664237CC26F0091163D /* src */, + 2F5E571B237CDF0A0091163D /* testdata */, ); name = Test; sourceTree = ""; diff --git a/src/main.s b/src/main.s index af825d9..1e86316 100644 --- a/src/main.s +++ b/src/main.s @@ -80,13 +80,9 @@ START ; --- Test all instructions in all their modes, with as many variants as possible --- - - - ;adc (ZP,x) adc (0,x) - adc ($80,x) adc (_tmp,x) adc (_tmp+0,x) @@ -239,6 +235,14 @@ L00BC bit L00BC ldx L00BC,y stx L00BC,y + +* Data Storage Tests + + hex 11,22,33,44,55,66,77,88,99 + hex 112233445566778899 + hex aabb,cc,ddee,ff + + //]XCODEEND ; Keep this at the end and put your code above this lst off