Merge pull request #12 from lroathe/master

ASC psuedo opcode is working
This commit is contained in:
Lane Roathe 2019-11-17 17:45:09 -08:00 committed by GitHub
commit c4096ee19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 7 deletions

View File

@ -780,7 +780,7 @@ void CLASS::insertOpcodes(void)
pushopcode("TTL", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("SKP", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("TR", P_TR, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("ASC", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("ASC", P_ASC, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("DCI", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("INV", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));
pushopcode("FLS", 0x00, OP_PSUEDO, OPHANDLER(&CLASS::doPSEUDO));

View File

@ -480,8 +480,8 @@ int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
{
continue;
}
c = hexVal(c);
if( c < 0 )
char hv = hexVal(c);
if( hv < 0 )
{
line.setError(errIllegalCharOperand);
bytect = 0;
@ -492,10 +492,10 @@ int CLASS::doHEX(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
switch (ct)
{
case 0:
b = (c << 4);
b = (hv << 4);
break;
case 1:
b |= c;
b |= hv;
break;
}
ct = (ct + 1) & 0x01;
@ -520,6 +520,97 @@ out:
return bytect;
}
int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
{
UNUSED(opinfo);
std::string os = line.operand;
uint32_t bytect = 0;
uint8_t b = 0;
uint8_t ct = 0;
char delimiter = 0;
uint32_t ss = 0;
for ( uint32_t i = 0; i < os.length(); ++i )
{
char c = os[i];
// are we inside a delimited string?
if( delimiter )
{
if( c == delimiter )
{
bytect += (i - ss);
if( a.pass > 0 )
{
for( ; ss < i; ++ss )
{
c = os[ss];
if( delimiter >= '\'' )
c |= 0x80;
line.outbytes.push_back(c);
}
}
delimiter = 0;
ss = 0;
continue;
}
}
else
{
// No, check for seperator characters
if( c == ',' || c == ' ' )
{
continue;
}
// Is this a hex char?
char hv = hexVal(c);
if( hv < 0 )
{
// if not a hex value, then consider the character to be the string delimiter
delimiter = c;
ss = i + 1;
continue;
}
// Got a hex char, append to hex string and see if we've got a byte
switch (ct)
{
case 0:
b = (hv << 4);
break;
case 1:
b |= hv;
break;
}
ct = (ct + 1) & 0x01;
if (!ct)
{
if (a.pass > 0)
{
line.outbytes.push_back(b);
}
b = 0;
bytect++;
}
}
}
if( delimiter || (ct & 0x01) ) // error w/unterminated string or we got an odd number of nibbles in hex value
{
line.setError(errBadOperand);
bytect = 0;
}
out:
line.outbytect = bytect;
return bytect;
}
int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
{
int res = 0;
@ -579,7 +670,9 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
case P_TR:
res = doTR(a, line, opinfo);
break;
case P_ASC:
res = doASC(a, line, opinfo);
break;
}
return (res);
}

View File

@ -18,6 +18,7 @@ enum
P_LUP,
P_DO,
P_TR,
P_ASC,
P_MAX
};
@ -36,6 +37,7 @@ public:
int doLUP(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
int doDO(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
int doTR(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
int doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo);
};
#undef CLASS
#undef CLASS

View File

@ -393,6 +393,28 @@ L00BC bit L00BC
db ^$01A55A,^$011234
db |$01A55A,|$011234
asc 02,15,"123456"
asc 02,15,z123456z
asc 0215,"123456"
asc 02,15,'123456'
asc 02,15,!123456!
asc 02,15,@123456@
asc 02,15,#123456#
asc 02,15,$123456$
asc 02,15,%123456%
asc 02,15,^123456^
asc 02,15,&123456&
asc 02,15,*123456*
asc 02,15,(123456(
asc 02,15,)123456)
asc 02,15,/123456/
asc 02,15,?123456?
asc 02,15,>123456>
asc 02,15,<123456<
asc 02,15,5,"123456"
asc 02,15,"123456
asc 0215"1234"1502
lst
lup_start: