mirror of
https://github.com/marketideas/qasm.git
synced 2024-06-13 03:29:33 +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())) + " ";
|
restofline = Poco::trim(tline.substr(i, tline.length())) + " ";
|
||||||
//printf("ROL: |%s|\n",restofline.c_str());
|
//printf("ROL: |%s|\n",restofline.c_str());
|
||||||
|
|
||||||
if (restofline=="")
|
if (restofline == "")
|
||||||
{
|
{
|
||||||
i=l;
|
i = l;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strs.clear();
|
strs.clear();
|
||||||
|
@ -493,15 +493,16 @@ void CLASS::set(std::string line)
|
||||||
x = lable.length();
|
x = lable.length();
|
||||||
if (x > 1)
|
if (x > 1)
|
||||||
{
|
{
|
||||||
// SGQ M32 syntax
|
// M32 syntax allows a colon after lable, and it is not part of the lable
|
||||||
#if 1
|
if ((syntax & SYNTAX_MERLIN32)==SYNTAX_MERLIN32)
|
||||||
while ((x > 1) && (lable[x - 1] == ':'))
|
|
||||||
{
|
{
|
||||||
lable = lable.substr(0, x - 1);
|
while ((x > 1) && (lable[x - 1] == ':'))
|
||||||
x--;
|
{
|
||||||
|
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);
|
opcodelower = Poco::toLower(opcode);
|
||||||
|
@ -532,9 +533,24 @@ void CLASS::init(void)
|
||||||
filenames.clear();
|
filenames.clear();
|
||||||
starttime = GetTickCount();
|
starttime = GetTickCount();
|
||||||
initialdir = Poco::Path::current();
|
initialdir = Poco::Path::current();
|
||||||
syntax = 0;
|
syntax = SYNTAX_MERLIN;
|
||||||
filecount = 0;
|
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");
|
std::string tabstr = getConfig("reformat.tabs", "8,16,32");
|
||||||
tabstr = Poco::trim(tabstr);
|
tabstr = Poco::trim(tabstr);
|
||||||
|
|
||||||
|
@ -1422,6 +1438,21 @@ void CLASS::initpass(void)
|
||||||
merlinerrors = getBool("asm.merlinerrors", true);
|
merlinerrors = getBool("asm.merlinerrors", true);
|
||||||
|
|
||||||
trackrep = getBool("asm.trackrep", false);
|
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);
|
//merlincompat = getBool("asm.merlincompatible", true);
|
||||||
allowdup = getBool("asm.allowduplicate", true);
|
allowdup = getBool("asm.allowduplicate", true);
|
||||||
|
|
||||||
|
@ -1464,7 +1495,12 @@ void CLASS::initpass(void)
|
||||||
|
|
||||||
lastcarry = false;
|
lastcarry = false;
|
||||||
relocatable = 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 = "";
|
currentsymstr = "";
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
errorct = 0;
|
errorct = 0;
|
||||||
|
@ -1668,18 +1704,17 @@ int CLASS::getAddrMode(MerlinLine & line)
|
||||||
// symbol is defined later, we will generate different
|
// symbol is defined later, we will generate different
|
||||||
// bytes on the next pass
|
// 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
|
if (Poco::toUpper(oper) == "A") // check the whole operand, not just the expression
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
line.flags |= FLAG_FORCEIMPLIED;
|
TSymbol *sym = findSymbol("A");
|
||||||
mode = syn_implied; // if the label hasn't been defined yet, assume Immediate addressing
|
if (sym == NULL)
|
||||||
goto out;
|
{
|
||||||
|
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.linemx = mx;
|
||||||
line.bytect = 0;
|
line.bytect = 0;
|
||||||
line.showmx = showmx;
|
line.showmx = showmx;
|
||||||
|
line.syntax = syntax;
|
||||||
line.merlinerrors = merlinerrors;
|
line.merlinerrors = merlinerrors;
|
||||||
|
|
||||||
if ((line.lable != ""))
|
if ((line.lable != ""))
|
||||||
|
|
18
asm.h
18
asm.h
|
@ -8,8 +8,17 @@
|
||||||
#define MODE_65816 2
|
#define MODE_65816 2
|
||||||
|
|
||||||
#define SYNTAX_MERLIN 0
|
#define SYNTAX_MERLIN 0
|
||||||
#define SYNTAX_APW 1
|
#define SYNTAX_MERLIN32 0x01
|
||||||
#define SYNTAX_ORCA 2
|
#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_FORCELONG 0x01
|
||||||
#define FLAG_FORCEABS 0x02
|
#define FLAG_FORCEABS 0x02
|
||||||
|
@ -177,7 +186,7 @@ class MerlinLine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
uint8_t syntax;
|
uint32_t syntax;
|
||||||
std::string lable;
|
std::string lable;
|
||||||
std::string printlable;
|
std::string printlable;
|
||||||
std::string opcode;
|
std::string opcode;
|
||||||
|
@ -224,7 +233,7 @@ class TFileProcessor
|
||||||
protected:
|
protected:
|
||||||
std::string initialdir;
|
std::string initialdir;
|
||||||
std::vector<std::string> filenames;
|
std::vector<std::string> filenames;
|
||||||
uint8_t syntax;
|
uint32_t syntax;
|
||||||
uint64_t starttime;
|
uint64_t starttime;
|
||||||
uint8_t tabs[16];
|
uint8_t tabs[16];
|
||||||
|
|
||||||
|
@ -335,7 +344,6 @@ public:
|
||||||
bool casesen;
|
bool casesen;
|
||||||
bool showmx;
|
bool showmx;
|
||||||
bool trackrep;
|
bool trackrep;
|
||||||
//bool merlincompat;
|
|
||||||
bool merlinerrors;
|
bool merlinerrors;
|
||||||
bool allowdup;
|
bool allowdup;
|
||||||
uint8_t mx;
|
uint8_t mx;
|
||||||
|
|
8
qasm.cpp
8
qasm.cpp
|
@ -18,9 +18,11 @@ programOption PAL::appOptions[] =
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{ "debug", "d", "enable debug info (repeat for more verbosity)", "", false, true},
|
{ "debug", "d", "enable debug info (repeat for more verbosity)", "", false, true},
|
||||||
#endif
|
#endif
|
||||||
//{ "config", "f", "load configuration data from a <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},
|
{ "exec", "x", "execute a command [asm, link, reformat] default=asm", "<command>", false, false},
|
||||||
{ "objfile", "o", "write output to file", " <file>", 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}
|
{ "", "", "", "", false, false}
|
||||||
};
|
};
|
||||||
|
|
4
qasm.ini
4
qasm.ini
|
@ -6,7 +6,7 @@ logfile=mylog.log
|
||||||
[option]
|
[option]
|
||||||
debug=1
|
debug=1
|
||||||
nocolor=false
|
nocolor=false
|
||||||
syntax=merlin
|
;syntax=merlin32
|
||||||
;debug must be an integer. Code can use this as a level
|
;debug must be an integer. Code can use this as a level
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
@ -27,7 +27,7 @@ startmx=3
|
||||||
lst=true
|
lst=true
|
||||||
; can be M6502, M65C02, M65816
|
; can be M6502, M65C02, M65816
|
||||||
cpu=M65816
|
cpu=M65816
|
||||||
trackrep=false
|
trackrep=true
|
||||||
allowduplicate=true
|
allowduplicate=true
|
||||||
merlinerrors=true
|
merlinerrors=true
|
||||||
symcolumns=3
|
symcolumns=3
|
||||||
|
|
|
@ -29,7 +29,7 @@ for S in $SRC ; do
|
||||||
BASE=${BASE/.s/}
|
BASE=${BASE/.s/}
|
||||||
#./qasm -o 0/$OUTDIR/$S1 ./testdata/$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=?$
|
R=?$
|
||||||
#echo $S " " $S1
|
#echo $S " " $S1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user