more fixes on operand handling, tests back to passing (not all, but many)

This commit is contained in:
Shawn Quick 2023-02-08 15:46:38 -08:00
parent 4380f4e8ca
commit 20f78d128b
8 changed files with 132 additions and 64 deletions

74
asm.cpp
View File

@ -149,6 +149,17 @@ void CLASS::print(uint32_t lineno)
{
pcol += printf(" ");
}
string addrmode=options->addrModeEnglish(addressmode).c_str();
pcol+=printf("%s ",addrmode.c_str());
while(pcol<50)
{
pcol+=printf(" ");
}
pcol+=printf("|");
}
if (isDebug() > 1)
@ -1810,7 +1821,7 @@ void CLASS::initpass(void)
s=PAL::getString("option.instruction","");
if (s!="")
{
printf("CPU command line %s\n",s.c_str());
//printf("CPU command line %s\n",s.c_str());
cpumode = MODE_65816;
mx = 0x03;
@ -1904,7 +1915,8 @@ void CLASS::complete(void)
printf("saving to file: %s\n", savepath.c_str());
}
std::ofstream f(savepath, std::ios::out|std::ios::trunc);
//std::ofstream f(savepath, std::ios::out|std::ios::trunc);
std::ofstream f(savepath, std::ios::out);
if (f.is_open())
{
@ -2050,9 +2062,17 @@ int CLASS::getAddrMode(MerlinLine & line)
oper = line.operand;
int l=oper.length();
if ((line.opcode.length() == 0) || (l <= 0))
int ol=line.opcode.length();
if ((ol == 0) || (l <= 0))
{
return (syn_none);
if (ol>0)
{
return (syn_implied);
}
else
{
return(syn_none);
}
}
bool supportbar=false;
@ -2093,13 +2113,13 @@ int CLASS::getAddrMode(MerlinLine & line)
}
}
if ((shiftchar=='^') || (shiftchar=='<') || (shiftchar=='>') || (supportbar && shiftchar=='|'))
if ((shiftchar=='^') || (shiftchar=='<') || (shiftchar=='>') || (supportbar && (shiftchar=='|')))
{
modified=true;
}
if (supportbar)
if (supportbar && shiftchar=='|')
{
line.flags|=FLAG_FORCELONG;
}
if (modified)
{
@ -2115,7 +2135,10 @@ int CLASS::getAddrMode(MerlinLine & line)
oper=oper.substr(1);
l=oper.length();
}
printf("old: |%s| new: |%s|\n",line.operand.c_str(),oper.c_str());
if (isDebug()>1)
{
printf("old: |%s| new: |%s|\n",line.operand.c_str(),oper.c_str());
}
line.strippedoperand=oper;
}
@ -2246,34 +2269,13 @@ int CLASS::parseOperand(MerlinLine & line)
{
//errorOut(errBadAddressMode);
}
printf("addressmode=%d %s\n",res,addrModeEnglish(res).c_str());
if (isDebug()>1)
{
printf("addressmode=%d %s\n",res,options.addrModeEnglish(res).c_str());
}
return (res);
}
string CLASS::addrModeEnglish(int mode)
{
string res="<none>";
switch(mode)
{
case syn_err: res="addrmode_error";break;
case syn_none: res="addrmode_none";break;
case syn_implied: res="implied";break;
case syn_s: res="dp,s";break;
case syn_sy: res="(dp,s),y";break;
case syn_imm: res="#immediate";break;
case syn_diix: res="(dp,x)";break;
case syn_diiy: res="(dp),y";break;
case syn_di: res="(dp)";break;
case syn_iyl: res="[expr],y";break;
case syn_dil: res="[expr]";break;
case syn_absx: res="abs,x";break;
case syn_absy: res="abs,y";break;
case syn_bm: res="block move";break;
case syn_abs: res="absolute";break;
default: res="addr_mode bad";break;
}
return(res);
}
int CLASS::substituteVariables(MerlinLine & line, std::string &outop)
{
@ -2592,10 +2594,10 @@ void CLASS::process(void)
line.operand = outop;
}
x = parseOperand(line);
if (x >= 0)
{
//if (x >= 0)
//{
line.addressmode = x;
}
//}
int64_t value = -1;
x = evaluate(line, line.operand_expr, value);

21
asm.h
View File

@ -110,26 +110,6 @@ extern uint8_t opCodeCompatibility[256];
#endif
enum
{
syn_err = -1, // error - not recognized
syn_none = 0, // should never be returned 0
syn_implied, // no operand 1
syn_s, // expr,s 2
syn_sy, // (expr,s),y 3
syn_imm, // #expr 4
syn_diix, // (expr,x) 5
syn_diiy, // (expr),y 6
syn_di, // (expr) 7
syn_iyl, // [expr],y 8
syn_dil, // [expr] 9
syn_absx, // expr,x 10
syn_absy, // expr,y 11
syn_bm, // block move 12
syn_abs, // expr 13
syn_MAX
};
class TOriginSection
@ -493,7 +473,6 @@ public:
int parseOperand(MerlinLine &line);
int getAddrMode(MerlinLine &line);
string addrModeEnglish(int mode);
void setOpcode(MerlinLine &line, uint8_t op);

View File

@ -599,6 +599,9 @@ int CLASS::doBase6502(MerlinLine & line, TSymbol & sym)
case syn_absy:
amode = 6;
break;
//case syn_none:
// printf("syn_none on ROR OP_A\n");
// break;
default:
err = true;
break;

View File

@ -967,7 +967,7 @@ int CLASS::doASC(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
}
else
{
printf("bug\n");
//printf("bug\n"); // SGQ BUG - still not working right
// invert last byte of last string (old merlin way (pre-merlin16+))
if (dci && (i == lastdelimidx))
{

View File

@ -72,6 +72,11 @@ void CLASS::showerror(int ecode, std::string fname)
}
}
void CLASS::displayHelp()
{
PAL_BASEAPP::displayHelp();
printf("\n\t\t...remembering Glen Bredon\n\n");
}
// int main(int argc, char *argv[])
// this is where libpal calls to run a command line program
int CLASS::runCommandLineApp(void)

1
qasm.h
View File

@ -26,6 +26,7 @@ protected:
virtual int runServerApp(PAL_EVENTMANAGER *em);
#endif
virtual void displayVersion();
virtual void displayHelp();
public:

View File

@ -31,6 +31,27 @@ using namespace Poco;
#define OPTION_M32_VARS 0x4000
#define OPTION_M16_PLUS 0x8000
enum
{
syn_err = -1, // error - not recognized
syn_none = 0, // should never be returned 0
syn_implied, // no operand 1
syn_s, // expr,s 2
syn_sy, // (expr,s),y 3
syn_imm, // #expr 4
syn_diix, // (expr,x) 5
syn_diiy, // (expr),y 6
syn_di, // (expr) 7
syn_iyl, // [expr],y 8
syn_dil, // [expr] 9
syn_absx, // expr,x 10
syn_absy, // expr,y 11
syn_bm, // block move 12
syn_abs, // expr 13
syn_MAX
};
class myLayeredConfiguration : public Poco::Util::LayeredConfiguration
{
@ -522,7 +543,7 @@ public:
string pn=Poco::toUpper(lang);
if ((old!=pn) || (force))
{
printf("setting language options to %s\n",pn.c_str());
//printf("setting language options to %s\n",pn.c_str());
language=pn;
setCurrent();
if (pn=="QASM")
@ -657,6 +678,63 @@ public:
return(res);
}
string addrModeEnglish(int mode)
{
string res="<none>";
switch(mode)
{
case syn_err:
res="error";
break;
case syn_none:
res="<none>";
break;
case syn_implied:
res="impl";
break;
case syn_s:
res="dp,s";
break;
case syn_sy:
res="(dp,s),y";
break;
case syn_imm:
res="#imme";
break;
case syn_diix:
res="(dp,x)";
break;
case syn_diiy:
res="(dp),y";
break;
case syn_di:
res="(dp)";
break;
case syn_iyl:
res="[expr],y";
break;
case syn_dil:
res="[expr]";
break;
case syn_absx:
res="abs,x";
break;
case syn_absy:
res="abs,y";
break;
case syn_bm:
res="blkmv";
break;
case syn_abs:
res="abs";
break;
default:
res="unknown";
break;
}
return(res);
}
};

View File

@ -29,9 +29,9 @@ for S in $SRC ; do
BASE=${BASE/.s/}
#./qasm -o 0/$OUTDIR/$S1 ./testdata/$S
./qasm -l -t merlin32 -i M65816 -o 0/$OUTDIR/$S1 ./testdata/$S >> $TMPFILE
X="./qasm -q -c -t merlin32 -i M65816 -o 0/$OUTDIR/$S1 ./testdata/$S"
X="./qasm -l -t merlin32 -i M65816 -o 0/$OUTDIR/$S1 ./testdata/$S"
$X >$TMPFILE
#echo $X
R=?$
@ -71,9 +71,9 @@ for S in $SRC ; do
echo " $S"
FAILCT=$(($FAILCT+1))
cat $TMPFILE
echo $X
exit 255
#cat $TMPFILE
#echo $X
#exit 255
else
printf "PASS: "
fi