mirror of
https://github.com/marketideas/qasm.git
synced 2026-04-26 09:19:10 +00:00
test
This commit is contained in:
@@ -35,6 +35,9 @@ install:
|
||||
reformat:
|
||||
qasm -x REFORMAT src/main.s
|
||||
|
||||
compare:
|
||||
-bcompare . ../lane_hex &
|
||||
|
||||
asm:
|
||||
|
||||
test1:
|
||||
|
||||
@@ -26,7 +26,7 @@ void CLASS::setError(uint32_t ecode)
|
||||
void CLASS::print(uint32_t lineno)
|
||||
{
|
||||
int pcol;
|
||||
uint32_t l,i;
|
||||
uint32_t l, i;
|
||||
int commentcol = 40;
|
||||
static bool checked = false;
|
||||
static bool nc1 = false;
|
||||
@@ -34,8 +34,14 @@ void CLASS::print(uint32_t lineno)
|
||||
|
||||
uint32_t b = 4; // how many bytes show on the first line
|
||||
|
||||
|
||||
l = outbytect;
|
||||
if (datafillct > 0)
|
||||
{
|
||||
l = datafillct;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = outbytect;
|
||||
}
|
||||
if (l > b)
|
||||
{
|
||||
l = b;
|
||||
@@ -92,16 +98,24 @@ void CLASS::print(uint32_t lineno)
|
||||
|
||||
for (i = 0; i < l; i++)
|
||||
{
|
||||
pcol += printf("%02X ", outbytes[i]);
|
||||
uint8_t a = datafillbyte;
|
||||
if (datafillct == 0)
|
||||
{
|
||||
a = outbytes[i];
|
||||
}
|
||||
|
||||
pcol += printf("%02X ", a);
|
||||
}
|
||||
for (i = l; i < b; i++)
|
||||
{
|
||||
pcol += printf(" ");
|
||||
}
|
||||
|
||||
pcol += printf("%6d ", lineno + 1);
|
||||
|
||||
if (showmx)
|
||||
{
|
||||
if (outbytect > 0)
|
||||
if ((outbytect + datafillct) > 0)
|
||||
{
|
||||
pcol += printf("%%%c%c ", linemx & 02 ? '1' : '0', linemx & 01 ? '1' : '0');
|
||||
}
|
||||
@@ -115,7 +129,6 @@ void CLASS::print(uint32_t lineno)
|
||||
{
|
||||
pcol += printf("%02X ", addressmode & 0xFF);
|
||||
}
|
||||
pcol += printf("%6d ", lineno + 1);
|
||||
|
||||
pcol = 0; // reset pcol here because this is where source code starts
|
||||
|
||||
@@ -159,30 +172,50 @@ void CLASS::print(uint32_t lineno)
|
||||
SetColor(CL_NORMAL | BG_NORMAL);
|
||||
}
|
||||
|
||||
if (outbytect>b)
|
||||
uint32_t obc = datafillct;
|
||||
if (obc == 0)
|
||||
{
|
||||
uint32_t t=b;
|
||||
uint32_t ct=0;
|
||||
//char *s=(char *)"--------";
|
||||
char *s=(char *)" ";
|
||||
obc = outbytect;
|
||||
}
|
||||
|
||||
uint32_t ct = 1;
|
||||
if (obc > b)
|
||||
{
|
||||
ct = 0;
|
||||
uint8_t db;
|
||||
uint32_t t = b;
|
||||
char *s = (char *)" ";
|
||||
|
||||
b = 8;
|
||||
|
||||
//printf("t=%d ct=%d\n",t,outbytect);
|
||||
printf("\n%s",s);
|
||||
while(t<outbytect)
|
||||
printf("\n");
|
||||
while (t < obc)
|
||||
{
|
||||
printf("%02X ",outbytes[t]);
|
||||
db = datafillbyte;
|
||||
if (datafillct == 0)
|
||||
{
|
||||
db = outbytes[t];
|
||||
}
|
||||
if (ct == 0)
|
||||
{
|
||||
printf("%s", s);
|
||||
}
|
||||
|
||||
printf("%02X ", db);
|
||||
t++;
|
||||
ct++;
|
||||
if (ct>=b)
|
||||
if (ct >= b)
|
||||
{
|
||||
printf("\n");
|
||||
printf("%s",s);
|
||||
ct=0;
|
||||
ct = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
if (ct > 0)
|
||||
{
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -206,6 +239,8 @@ void CLASS::clear()
|
||||
errorcode = 0;
|
||||
errorText = "";
|
||||
outbytect = 0;
|
||||
datafillct = 0;
|
||||
datafillbyte = 0;
|
||||
lineno = 0;
|
||||
outbytes.clear();
|
||||
addressmode = 0;
|
||||
@@ -393,7 +428,9 @@ void CLASS::complete(void)
|
||||
if (isDebug())
|
||||
{
|
||||
//cout << "Processing Time: " << n - starttime << "ms" << endl;
|
||||
printf("Processing Time: %" PRIu64 " ms\n",n-starttime);
|
||||
uint64_t x = n - starttime;
|
||||
uint32_t x1 = x & 0xFFFFFFFF;
|
||||
printf("Processing Time: %u ms\n", x1);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -962,7 +999,7 @@ void CLASS::showSymbolTable(bool alpha)
|
||||
std::map<std::string, uint32_t> alphamap;
|
||||
std::map<uint32_t, std::string> nummap;
|
||||
|
||||
int columns = getInt("asm.symcolumns",3);
|
||||
int columns = getInt("asm.symcolumns", 3);
|
||||
int column = columns;
|
||||
|
||||
for (auto itr = symbols.begin(); itr != symbols.end(); itr++)
|
||||
@@ -999,7 +1036,7 @@ void CLASS::showSymbolTable(bool alpha)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (column>0)
|
||||
if (column > 0)
|
||||
{
|
||||
printf("\n");
|
||||
}
|
||||
@@ -1282,9 +1319,8 @@ int CLASS::evaluate(MerlinLine &line, std::string expr, int64_t &value)
|
||||
if (isDebug() > 2)
|
||||
{
|
||||
int c = SetColor(CL_RED);
|
||||
cout << "eval Error=" << res << "0x" << std::hex << result << std::dec << eval.badsymbol << endl;
|
||||
|
||||
//printf("eval Error=%d %08lX |%s|\n", res, result, eval.badsymbol.c_str());
|
||||
uint32_t rr = result & 0xFFFFFFFF;
|
||||
printf("eval Error=%d %08X |%s|\n", res, rr, eval.badsymbol.c_str());
|
||||
SetColor(c);
|
||||
}
|
||||
}
|
||||
@@ -1294,8 +1330,8 @@ int CLASS::evaluate(MerlinLine &line, std::string expr, int64_t &value)
|
||||
value = result;
|
||||
if ((listing) && (pass > 0) && (isDebug() > 2))
|
||||
{
|
||||
cout << "EV1=0x" << std::hex << v1 << " '" << std::dec << line.expr_shift << ";" << endl;
|
||||
//printf("EV1=%08lX '%c'\n", v1, line.expr_shift);
|
||||
uint32_t rr = v1 & 0xFFFFFFFF;
|
||||
printf("EV1=%08X '%c'\n", rr, line.expr_shift);
|
||||
}
|
||||
if (v1 >= 0x10000)
|
||||
{
|
||||
@@ -1314,8 +1350,8 @@ int CLASS::evaluate(MerlinLine &line, std::string expr, int64_t &value)
|
||||
}
|
||||
if (isDebug() >= 3)
|
||||
{
|
||||
cout << "Eval Result: 0x" << std::hex << value << std::dec << "(status=" << res << ")" << endl;
|
||||
//printf("Eval Result: %08lX (status=%d)\n", value, res);
|
||||
uint32_t rr = value & 0xFFFFFFFF;
|
||||
printf("Eval Result: %08X (status=%d)\n", rr, res);
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
|
||||
@@ -185,6 +185,8 @@ public:
|
||||
|
||||
uint16_t pass0bytect;
|
||||
uint16_t bytect;
|
||||
uint16_t datafillct;
|
||||
uint8_t datafillbyte;
|
||||
uint16_t outbytect;
|
||||
std::vector<uint8_t> outbytes;
|
||||
|
||||
|
||||
+7
-7
@@ -729,13 +729,13 @@ void CLASS::insertOpcodes(void)
|
||||
pushopcode("FLS", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("REV", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("STR", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DA", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DW", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DDB", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DFB", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
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("DA", P_DATA, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DW", P_DATA, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DDB", P_DATA, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DFB", P_DATA, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("DB", P_DATA, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("ADR", P_DATA, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
|
||||
pushopcode("ADRL",P_DATA, 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));
|
||||
|
||||
+87
-17
@@ -12,6 +12,69 @@ CLASS::~CLASS()
|
||||
|
||||
}
|
||||
|
||||
constexpr unsigned int strhash(const char *str, int h = 0)
|
||||
{
|
||||
return !str[h] ? 5381 : (strhash(str, h + 1) * 33) ^ str[h];
|
||||
}
|
||||
|
||||
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 op = Poco::toUpper(Poco::trim(line.opcode));
|
||||
Poco::StringTokenizer tok(oper, ",", Poco::StringTokenizer::TOK_TRIM |
|
||||
Poco::StringTokenizer::TOK_IGNORE_EMPTY);
|
||||
|
||||
|
||||
const char *ptr = (const char *)op.c_str();
|
||||
switch (strhash(ptr) )
|
||||
{
|
||||
case strhash((const char *)"DA"):
|
||||
case strhash((const char *)"DW"):
|
||||
wordsize = 2;
|
||||
break;
|
||||
case strhash((const char *)"DDB"):
|
||||
wordsize = 2;
|
||||
endian = 1;
|
||||
break;
|
||||
case strhash((const char *)"DFB"):
|
||||
case strhash((const char *)"DB"):
|
||||
wordsize = 1;
|
||||
break;
|
||||
case strhash((const char *)"ADR"):
|
||||
wordsize = 3;
|
||||
break;
|
||||
case strhash((const char *)"ADRL"):
|
||||
wordsize = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto itr = tok.begin(); itr != tok.end(); ++itr)
|
||||
{
|
||||
//printf("%s\n",(*itr).c_str());
|
||||
//evaluate each of these strings, check for errors on pass 2
|
||||
|
||||
outct += wordsize;
|
||||
if (a.pass > 0)
|
||||
{
|
||||
if (!endian) // little endian
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
// big endian
|
||||
}
|
||||
}
|
||||
}
|
||||
// SGQ - remove when complete
|
||||
line.datafillct=outct;
|
||||
line.datafillbyte=0xCA;
|
||||
// ===============
|
||||
|
||||
return (outct);
|
||||
}
|
||||
|
||||
int CLASS::doDS(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
{
|
||||
@@ -29,6 +92,9 @@ int CLASS::doDS(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
{
|
||||
res = v;
|
||||
|
||||
line.datafillbyte = line.eval_result & 0xFF;
|
||||
line.datafillct = v;
|
||||
#if 0
|
||||
if (a.pass > 0)
|
||||
{
|
||||
for (int i = 0; i < v; i++)
|
||||
@@ -37,6 +103,7 @@ int CLASS::doDS(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
}
|
||||
line.outbytect = v;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return (res);
|
||||
@@ -91,26 +158,26 @@ int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
{
|
||||
std::string os = Poco::toUpper(Poco::trim(line.operand));
|
||||
|
||||
uint32_t bytect=0;
|
||||
uint8_t b=0;
|
||||
uint8_t ct=0;
|
||||
uint32_t bytect = 0;
|
||||
uint8_t b = 0;
|
||||
uint8_t ct = 0;
|
||||
for ( uint32_t i = 0; i < os.length(); ++i )
|
||||
{
|
||||
char c = os[i];
|
||||
|
||||
if ((c>='0') && (c<='9'))
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
{
|
||||
c=c-'0';
|
||||
c = c - '0';
|
||||
}
|
||||
else if ((c>='a') && (c<='f'))
|
||||
else if ((c >= 'a') && (c <= 'f'))
|
||||
{
|
||||
c=c-'a'+10;
|
||||
c = c - 'a' + 10;
|
||||
}
|
||||
else if ((c>='A') && (c<='F'))
|
||||
else if ((c >= 'A') && (c <= 'F'))
|
||||
{
|
||||
c=c-'A'+10;
|
||||
c = c - 'A' + 10;
|
||||
}
|
||||
else if (c==',')
|
||||
else if (c == ',')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -121,28 +188,28 @@ int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
}
|
||||
|
||||
// Got a good char, append to hex string and see if we've got a byte
|
||||
switch(ct)
|
||||
switch (ct)
|
||||
{
|
||||
case 0:
|
||||
b=(c<<4);
|
||||
b = (c << 4);
|
||||
break;
|
||||
case 1:
|
||||
b|=c;
|
||||
b |= c;
|
||||
break;
|
||||
}
|
||||
ct=(ct+1)&0x01;
|
||||
ct = (ct + 1) & 0x01;
|
||||
if (!ct)
|
||||
{
|
||||
if (a.pass>0)
|
||||
if (a.pass > 0)
|
||||
{
|
||||
line.outbytes.push_back(b);
|
||||
}
|
||||
b=0;
|
||||
b = 0;
|
||||
bytect++;
|
||||
}
|
||||
|
||||
}
|
||||
line.outbytect=bytect;
|
||||
line.outbytect = bytect;
|
||||
//printf("bytect=%d\n",bytect);
|
||||
return bytect;
|
||||
}
|
||||
@@ -192,6 +259,9 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
||||
case P_HEX:
|
||||
res = doHEX(a, line, opinfo);
|
||||
break;
|
||||
case P_DATA:
|
||||
res = doDATA(a, line, opinfo);
|
||||
break;
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ enum
|
||||
P_PUT,
|
||||
P_USE,
|
||||
P_HEX,
|
||||
P_DATA,
|
||||
|
||||
P_MAX
|
||||
};
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
int doDUM(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
|
||||
int doDS(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
|
||||
int doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
|
||||
int doDATA(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
|
||||
};
|
||||
|
||||
#undef CLASS
|
||||
+19
-1
@@ -364,7 +364,25 @@ L00BC bit L00BC
|
||||
|
||||
hex 11,22,33,44,55,66,77,88,99
|
||||
hex 112233445566778899
|
||||
hex aabb,cc,ddee,ff
|
||||
hex aabb,CC,0123456789ABCDEFabcdef,ff
|
||||
|
||||
ds 36
|
||||
da $A55A
|
||||
da $A55A,$1234
|
||||
dw $A55A
|
||||
dw $A55A,$1234
|
||||
ddb $A55A
|
||||
ddb $A55A,$1234
|
||||
dfb $A55A
|
||||
dfb $A55A,$1234
|
||||
db $A55A
|
||||
db $A55A,$1234
|
||||
adr $01A55A
|
||||
adr $01A55A,$011234
|
||||
adrl $01A55A
|
||||
adrl $01A55A,$011234
|
||||
|
||||
|
||||
|
||||
//]XCODEEND ; Keep this at the end and put your code above this
|
||||
;lst off
|
||||
|
||||
Reference in New Issue
Block a user