mirror of
https://github.com/marketideas/qasm.git
synced 2024-12-26 23:29:22 +00:00
commit
b7bbeab8d1
9
asm.cpp
9
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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
72
psuedo.cpp
72
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<std::string> 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);
|
||||
}
|
||||
|
5
psuedo.h
5
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
|
||||
|
@ -177,6 +177,7 @@
|
||||
2F5E56C4237CC2700091163D /* time */ = {isa = PBXFileReference; lastKnownFileType = file; path = time; sourceTree = "<group>"; };
|
||||
2F5E56C5237CC2700091163D /* edit */ = {isa = PBXFileReference; lastKnownFileType = text; path = edit; sourceTree = "<group>"; };
|
||||
2F5E56C6237CC2700091163D /* qlinkgs */ = {isa = PBXFileReference; lastKnownFileType = file; path = qlinkgs; sourceTree = "<group>"; };
|
||||
2F5E571B237CDF0A0091163D /* testdata */ = {isa = PBXFileReference; lastKnownFileType = folder; path = testdata; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -316,6 +317,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2F5E5664237CC26F0091163D /* src */,
|
||||
2F5E571B237CDF0A0091163D /* testdata */,
|
||||
);
|
||||
name = Test;
|
||||
sourceTree = "<group>";
|
||||
|
12
src/main.s
12
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user