mirror of
https://github.com/marketideas/qasm.git
synced 2025-01-13 20:32:14 +00:00
added --syntax option
This commit is contained in:
parent
572bdd5879
commit
4fa1c51549
78
asm.cpp
78
asm.cpp
@ -416,9 +416,9 @@ void CLASS::set(std::string line)
|
||||
restofline = Poco::trim(tline.substr(i, tline.length())) + " ";
|
||||
//printf("ROL: |%s|\n",restofline.c_str());
|
||||
|
||||
if (restofline=="")
|
||||
if (restofline == "")
|
||||
{
|
||||
i=l;
|
||||
i = l;
|
||||
break;
|
||||
}
|
||||
strs.clear();
|
||||
@ -493,15 +493,16 @@ void CLASS::set(std::string line)
|
||||
x = lable.length();
|
||||
if (x > 1)
|
||||
{
|
||||
// SGQ M32 syntax
|
||||
#if 1
|
||||
while ((x > 1) && (lable[x - 1] == ':'))
|
||||
// M32 syntax allows a colon after lable, and it is not part of the lable
|
||||
if ((syntax & SYNTAX_MERLIN32)==SYNTAX_MERLIN32)
|
||||
{
|
||||
lable = lable.substr(0, x - 1);
|
||||
x--;
|
||||
while ((x > 1) && (lable[x - 1] == ':'))
|
||||
{
|
||||
lable = lable.substr(0, x - 1);
|
||||
x--;
|
||||
}
|
||||
//printf("linelable: |%s|\n", lable.c_str());
|
||||
}
|
||||
//printf("linelable: |%s|\n", lable.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
opcodelower = Poco::toLower(opcode);
|
||||
@ -532,9 +533,24 @@ void CLASS::init(void)
|
||||
filenames.clear();
|
||||
starttime = GetTickCount();
|
||||
initialdir = Poco::Path::current();
|
||||
syntax = 0;
|
||||
syntax = SYNTAX_MERLIN;
|
||||
filecount = 0;
|
||||
|
||||
s = getConfig("option.syntax", "merlin16");
|
||||
s = Poco::toUpper(Poco::trim(s));
|
||||
if ((s == "MERLIN") || (s == "MERLIN16"))
|
||||
{
|
||||
syntax = SYNTAX_MERLIN;
|
||||
}
|
||||
else if (s == "MERLIN32")
|
||||
{
|
||||
syntax = SYNTAX_MERLIN32;
|
||||
}
|
||||
else if (s == "QASM")
|
||||
{
|
||||
syntax = SYNTAX_QASM;
|
||||
}
|
||||
|
||||
std::string tabstr = getConfig("reformat.tabs", "8,16,32");
|
||||
tabstr = Poco::trim(tabstr);
|
||||
|
||||
@ -1422,6 +1438,21 @@ void CLASS::initpass(void)
|
||||
merlinerrors = getBool("asm.merlinerrors", true);
|
||||
|
||||
trackrep = getBool("asm.trackrep", false);
|
||||
if (syntax == SYNTAX_MERLIN32)
|
||||
{
|
||||
trackrep = true; // can't turn this off in M32
|
||||
}
|
||||
else if (syntax == SYNTAX_MERLIN)
|
||||
{
|
||||
trackrep = false; // can't turn this ON in M16
|
||||
}
|
||||
else if (syntax == SYNTAX_QASM)
|
||||
{
|
||||
// we will allow this to be settable default off
|
||||
trackrep = false;
|
||||
trackrep = getBool("asm.trackrep", trackrep);
|
||||
|
||||
}
|
||||
//merlincompat = getBool("asm.merlincompatible", true);
|
||||
allowdup = getBool("asm.allowduplicate", true);
|
||||
|
||||
@ -1464,7 +1495,12 @@ void CLASS::initpass(void)
|
||||
|
||||
lastcarry = false;
|
||||
relocatable = false;
|
||||
currentsym = &topSymbol; // this is the default symbol for :locals without a global above;
|
||||
currentsym = NULL;
|
||||
if ((syntax & SYNTAX_MERLIN32)==SYNTAX_MERLIN32)
|
||||
{
|
||||
// M32 allows locals that don't have a global above. this is the catchall for that
|
||||
currentsym = &topSymbol; // this is the default symbol for :locals without a global above;
|
||||
}
|
||||
currentsymstr = "";
|
||||
lineno = 0;
|
||||
errorct = 0;
|
||||
@ -1668,18 +1704,17 @@ int CLASS::getAddrMode(MerlinLine & line)
|
||||
// symbol is defined later, we will generate different
|
||||
// bytes on the next pass
|
||||
|
||||
if (Poco::toUpper(oper) == "A") // check the whole operand, not just the expression
|
||||
if ((line.syntax&SYNTAX_MERLIN32) == SYNTAX_MERLIN32)
|
||||
{
|
||||
// SGQ
|
||||
// Merlin32 supports the 'A" operand for immediate
|
||||
// mode for opcodes like "ROR A". Problem is, Merlin16
|
||||
// does not, and 'A' could be a lable.
|
||||
TSymbol *sym = findSymbol("A");
|
||||
if (sym == NULL)
|
||||
if (Poco::toUpper(oper) == "A") // check the whole operand, not just the expression
|
||||
{
|
||||
line.flags |= FLAG_FORCEIMPLIED;
|
||||
mode = syn_implied; // if the label hasn't been defined yet, assume Immediate addressing
|
||||
goto out;
|
||||
TSymbol *sym = findSymbol("A");
|
||||
if (sym == NULL)
|
||||
{
|
||||
line.flags |= FLAG_FORCEIMPLIED;
|
||||
mode = syn_implied; // if the label hasn't been defined yet, assume Immediate addressing
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1861,6 +1896,7 @@ void CLASS::process(void)
|
||||
line.linemx = mx;
|
||||
line.bytect = 0;
|
||||
line.showmx = showmx;
|
||||
line.syntax = syntax;
|
||||
line.merlinerrors = merlinerrors;
|
||||
|
||||
if ((line.lable != ""))
|
||||
|
18
asm.h
18
asm.h
@ -8,8 +8,17 @@
|
||||
#define MODE_65816 2
|
||||
|
||||
#define SYNTAX_MERLIN 0
|
||||
#define SYNTAX_APW 1
|
||||
#define SYNTAX_ORCA 2
|
||||
#define SYNTAX_MERLIN32 0x01
|
||||
#define SYNTAX_APW 0x02
|
||||
#define SYNTAX_ORCA 0x04
|
||||
#define SYNTAX_QASM (0x08 | SYNTAX_MERLIN32)
|
||||
#define OPTION_ALLOW_A_OPERAND 0x0100
|
||||
#define OPTION_ALLOW_LOCAL 0x0200
|
||||
#define OPTION_ALLOW_COLON 0x0400
|
||||
#define OPTION_FORCE_REPSEP 0x0800
|
||||
#define OPTION_NO_REPSEP 0x1000
|
||||
#define OPTION_CFG_REPSEP 0x2000
|
||||
|
||||
|
||||
#define FLAG_FORCELONG 0x01
|
||||
#define FLAG_FORCEABS 0x02
|
||||
@ -177,7 +186,7 @@ class MerlinLine
|
||||
{
|
||||
public:
|
||||
|
||||
uint8_t syntax;
|
||||
uint32_t syntax;
|
||||
std::string lable;
|
||||
std::string printlable;
|
||||
std::string opcode;
|
||||
@ -224,7 +233,7 @@ class TFileProcessor
|
||||
protected:
|
||||
std::string initialdir;
|
||||
std::vector<std::string> filenames;
|
||||
uint8_t syntax;
|
||||
uint32_t syntax;
|
||||
uint64_t starttime;
|
||||
uint8_t tabs[16];
|
||||
|
||||
@ -335,7 +344,6 @@ public:
|
||||
bool casesen;
|
||||
bool showmx;
|
||||
bool trackrep;
|
||||
//bool merlincompat;
|
||||
bool merlinerrors;
|
||||
bool allowdup;
|
||||
uint8_t mx;
|
||||
|
8
qasm.cpp
8
qasm.cpp
@ -18,9 +18,11 @@ programOption PAL::appOptions[] =
|
||||
#ifdef DEBUG
|
||||
{ "debug", "d", "enable debug info (repeat for more verbosity)", "", false, true},
|
||||
#endif
|
||||
//{ "config", "f", "load configuration data from a <file>", " <file>", false, false},
|
||||
{ "exec", "x", "execute a command [asm, link, reformat] default=asm", " <command>", false, false},
|
||||
{ "objfile", "o", "write output to file", " <file>", false, false},
|
||||
//{ "config", "f", "load configuration data from a <file>", "<file>", false, false},
|
||||
{ "exec", "x", "execute a command [asm, link, reformat] default=asm", "<command>", false, false},
|
||||
{ "objfile", "o", "write output to file", "<file>", false, false},
|
||||
{ "syntax", "s", "enforce syntax of other assembler [merlin16, merlin32]", "<syntax>", false, false},
|
||||
|
||||
|
||||
{ "", "", "", "", false, false}
|
||||
};
|
||||
|
4
qasm.ini
4
qasm.ini
@ -6,7 +6,7 @@ logfile=mylog.log
|
||||
[option]
|
||||
debug=1
|
||||
nocolor=false
|
||||
syntax=merlin
|
||||
;syntax=merlin32
|
||||
;debug must be an integer. Code can use this as a level
|
||||
|
||||
[application]
|
||||
@ -27,7 +27,7 @@ startmx=3
|
||||
lst=true
|
||||
; can be M6502, M65C02, M65816
|
||||
cpu=M65816
|
||||
trackrep=false
|
||||
trackrep=true
|
||||
allowduplicate=true
|
||||
merlinerrors=true
|
||||
symcolumns=3
|
||||
|
@ -29,7 +29,7 @@ for S in $SRC ; do
|
||||
BASE=${BASE/.s/}
|
||||
#./qasm -o 0/$OUTDIR/$S1 ./testdata/$S
|
||||
|
||||
./qasm -o 0/$OUTDIR/$S1 ./testdata/$S >> $TMPFILE
|
||||
./qasm --syntax merlin32 -o 0/$OUTDIR/$S1 ./testdata/$S >> $TMPFILE
|
||||
|
||||
R=?$
|
||||
#echo $S " " $S1
|
||||
|
Loading…
x
Reference in New Issue
Block a user