mirror of
https://github.com/marketideas/qasm.git
synced 2024-06-11 21:29:29 +00:00
Merge branch 'sgq_qasm_main' of https://github.com/marketideas/qasm
This commit is contained in:
commit
8ae6f0ba3c
23
asm.cpp
23
asm.cpp
|
@ -56,7 +56,7 @@ void CLASS::print(uint32_t lineno)
|
|||
printf("\n%s in line: %d", errStrings[errorcode].c_str(), lineno + 1);
|
||||
if (errorText != "")
|
||||
{
|
||||
printf("%s", errorText.c_str());
|
||||
printf(" (%s)", errorText.c_str());
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -213,7 +213,11 @@ void CLASS::print(uint32_t lineno)
|
|||
{
|
||||
pcol += printf(" ");
|
||||
}
|
||||
pcol += printf(":[Error] %s %s", errStrings[errorcode].c_str(), errorText.c_str());
|
||||
pcol += printf(":[Error] %s", errStrings[errorcode].c_str());
|
||||
if (errorText.length() > 0)
|
||||
{
|
||||
pcol += printf(" (%s)",errorText.c_str());
|
||||
}
|
||||
}
|
||||
else if (!commentprinted)
|
||||
{
|
||||
|
@ -1357,7 +1361,6 @@ void CLASS::initpass(void)
|
|||
s = Poco::trim(Poco::toUpper(s));
|
||||
|
||||
cpumode = MODE_65816;
|
||||
mx = 0x00;
|
||||
|
||||
if (s == "M65816")
|
||||
{
|
||||
|
@ -1377,10 +1380,15 @@ void CLASS::initpass(void)
|
|||
else
|
||||
{
|
||||
printf("Unknown CPU type in .ini\n");
|
||||
mx = 0x00;
|
||||
}
|
||||
mx = getInt("asm.startmx", mx);;
|
||||
|
||||
savepath = getConfig("option.objfile", "");
|
||||
|
||||
relocatable = false;
|
||||
currentsym = NULL;
|
||||
currentsymstr="";
|
||||
currentsymstr = "";
|
||||
lineno = 0;
|
||||
errorct = 0;
|
||||
passcomplete = false;
|
||||
|
@ -1407,7 +1415,6 @@ void CLASS::initpass(void)
|
|||
}
|
||||
curLUP.clear();
|
||||
curDO.clear();
|
||||
savepath = "";
|
||||
}
|
||||
|
||||
void CLASS::complete(void)
|
||||
|
@ -1419,10 +1426,6 @@ void CLASS::complete(void)
|
|||
std::string currentdir = Poco::Path::current();
|
||||
|
||||
savepath = processFilename(savepath, currentdir, 0);
|
||||
if (isDebug() >= 1)
|
||||
{
|
||||
savepath += "1"; // append this to the end to help with testing against other assemblers
|
||||
}
|
||||
printf("saving to file: %s\n", savepath.c_str());
|
||||
|
||||
std::ofstream f(savepath);
|
||||
|
@ -1763,7 +1766,7 @@ void CLASS::process(void)
|
|||
if (c != ':')
|
||||
{
|
||||
currentsym = findSymbol(line.lable);
|
||||
currentsymstr=line.lable;
|
||||
currentsymstr = line.lable;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
21
opcodes.cpp
21
opcodes.cpp
|
@ -182,7 +182,7 @@ int CLASS::doMVN(MerlinLine &line, TSymbol &sym)
|
|||
{
|
||||
value = 0xFFFFFFFF;
|
||||
line.setError(errBadOperand);
|
||||
line.errorText = line.operand_expr2;
|
||||
//line.errorText = line.operand_expr2;
|
||||
}
|
||||
|
||||
setOpcode(line, op);
|
||||
|
@ -226,7 +226,7 @@ int CLASS::doNoPattern(MerlinLine &line, TSymbol &sym)
|
|||
op = (m == syn_abs ? 0x64 : op);
|
||||
op = (m == syn_absx ? 0x74 : op);
|
||||
|
||||
if ((op != 0) && (line.expr_value >= 0x100))
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags&FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = (op == 0x64) ? 0x9C : op;
|
||||
|
@ -236,7 +236,7 @@ int CLASS::doNoPattern(MerlinLine &line, TSymbol &sym)
|
|||
case 2: // TSB
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x04 : op);
|
||||
if ((op != 0) && (line.expr_value >= 0x100))
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags&FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = 0x0C;
|
||||
|
@ -245,7 +245,7 @@ int CLASS::doNoPattern(MerlinLine &line, TSymbol &sym)
|
|||
case 3: // TRB
|
||||
res++;
|
||||
op = (m == syn_abs ? 0x14 : op);
|
||||
if ((op != 0) && (line.expr_value >= 0x100))
|
||||
if ((op != 0) && ((line.expr_value >= 0x100) || (line.flags&FLAG_FORCEABS)))
|
||||
{
|
||||
res++;
|
||||
op = 0x1C;
|
||||
|
@ -487,14 +487,9 @@ int CLASS::doBase6502(MerlinLine & line, TSymbol & sym)
|
|||
cc = 0x01;
|
||||
op = 0x80;
|
||||
bbb = 0x02;
|
||||
//if ((mx&0x02)==0)
|
||||
//{
|
||||
// bytelen++;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
else if ((bbb > 0) && (line.expr_value >= 0x100))
|
||||
else if ((bbb > 0) && ((line.expr_value >= 0x100) || (line.flags&FLAG_FORCEABS)))
|
||||
{
|
||||
bbb |= 0x02;
|
||||
bytelen++;
|
||||
|
@ -576,6 +571,10 @@ int CLASS::doBase6502(MerlinLine & line, TSymbol & sym)
|
|||
bytelen++;
|
||||
}
|
||||
}
|
||||
if ( ((m==syn_absx) || (m==syn_diix)) && ((sym.opcode==4) || (sym.opcode==5))) // these are STX,LDX
|
||||
{
|
||||
err=true;
|
||||
}
|
||||
if ((m == syn_absx) || (m == syn_abs) || (m == syn_absy))
|
||||
{
|
||||
if ((line.flags & FLAG_FORCEABS) || (line.expr_value >= 0x100))
|
||||
|
@ -829,7 +828,7 @@ void CLASS::insertOpcodes(void)
|
|||
pushopcode("BNE", 0x03, 0, OPHANDLER(&CLASS::doBRANCH));
|
||||
pushopcode("BPL", 0x00, 0, OPHANDLER(&CLASS::doBRANCH));
|
||||
pushopcode("BRA", 0x40, 0, OPHANDLER(&CLASS::doBRANCH));
|
||||
pushopcode("BRK", 0x00, 0, OPHANDLER(&CLASS::doBYTE));
|
||||
pushopcode("BRK", 0x00, 1, OPHANDLER(&CLASS::doAddress));
|
||||
pushopcode("BRL", 0x20, 0, OPHANDLER(&CLASS::doBRANCH));
|
||||
pushopcode("BVC", 0x01, 0, OPHANDLER(&CLASS::doBRANCH));
|
||||
pushopcode("BVS", 0x81, 0, OPHANDLER(&CLASS::doBRANCH));
|
||||
|
|
64
psuedo.cpp
64
psuedo.cpp
|
@ -221,8 +221,11 @@ int CLASS::doDATA(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
int outct = 0;
|
||||
int wordsize = 2;
|
||||
int endian = 0;
|
||||
std::string oper = line.operand_expr;
|
||||
std::string oper = line.operand;
|
||||
std::string op = Poco::toUpper(Poco::trim(line.opcode));
|
||||
|
||||
//printf("DFB TOK1 : |%s|\n", oper.c_str());
|
||||
|
||||
Poco::StringTokenizer tok(oper, ",", Poco::StringTokenizer::TOK_TRIM |
|
||||
Poco::StringTokenizer::TOK_IGNORE_EMPTY);
|
||||
|
||||
|
@ -255,38 +258,49 @@ int CLASS::doDATA(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
|
||||
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
|
||||
|
||||
std::string expr = *itr;
|
||||
|
||||
//printf("DFB TOK : |%s|\n", expr.c_str());
|
||||
|
||||
int64_t eval_result = 0;
|
||||
uint8_t shift;
|
||||
int r;
|
||||
uint8_t b;
|
||||
|
||||
shift = 0;
|
||||
r = eval.evaluate(expr, eval_result, shift);
|
||||
if (r < 0)
|
||||
if (expr.length() > 0)
|
||||
{
|
||||
//printf("eval error %d |%s|\n", r,expr.c_str());
|
||||
if (a.pass > 0)
|
||||
if (expr[0] == '#')
|
||||
{
|
||||
line.setError(errBadEvaluation);
|
||||
expr[0] = ' ';
|
||||
expr = Poco::trim(expr);
|
||||
}
|
||||
shift = 0;
|
||||
eval_result = 0;
|
||||
//printf("DFB EVAL: |%s|\n", expr.c_str());
|
||||
r = eval.evaluate(expr, eval_result, shift);
|
||||
if (r < 0)
|
||||
{
|
||||
//printf("error\n");
|
||||
if (a.pass > 0)
|
||||
{
|
||||
line.setError(errBadEvaluation);
|
||||
}
|
||||
}
|
||||
if (shift == '>')
|
||||
{
|
||||
eval_result = (eval_result) & 0xFF;
|
||||
}
|
||||
if (shift == '<')
|
||||
{
|
||||
eval_result = (eval_result >> 8) & 0xFF;
|
||||
}
|
||||
else if ((shift == '^') || (shift == '|'))
|
||||
{
|
||||
eval_result = (eval_result >> 16) & 0xFF;
|
||||
}
|
||||
}
|
||||
if (shift == '>')
|
||||
{
|
||||
eval_result = (eval_result) & 0xFF;
|
||||
}
|
||||
if (shift == '<')
|
||||
{
|
||||
eval_result = (eval_result >> 8) & 0xFF;
|
||||
}
|
||||
else if ((shift == '^') || (shift == '|'))
|
||||
{
|
||||
eval_result = (eval_result >> 16) & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
outct += wordsize;
|
||||
if (a.pass > 0)
|
||||
|
@ -375,10 +389,10 @@ int CLASS::doLST(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
if (a.pass > 0)
|
||||
{
|
||||
s = Poco::toUpper(Poco::trim(line.operand_expr));
|
||||
if (s=="")
|
||||
if (s == "")
|
||||
{
|
||||
a.listing=true;
|
||||
a.skiplist=true;
|
||||
a.listing = true;
|
||||
a.skiplist = true;
|
||||
}
|
||||
else if (s == "RTN")
|
||||
{
|
||||
|
@ -560,7 +574,7 @@ int CLASS::ProcessOpcode(T65816Asm &a, MerlinLine &line, TSymbol &opinfo)
|
|||
res = doDO(a, line, opinfo);
|
||||
break;
|
||||
case P_TR:
|
||||
res=doTR(a,line,opinfo);
|
||||
res = doTR(a, line, opinfo);
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
2
qasm.cpp
2
qasm.cpp
|
@ -20,6 +20,8 @@ programOption PAL::appOptions[] =
|
|||
#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},
|
||||
|
||||
{ "", "", "", "", false, false}
|
||||
};
|
||||
|
||||
|
|
3
qasm.ini
3
qasm.ini
|
@ -21,7 +21,8 @@ path5=dirpath5
|
|||
|
||||
[asm]
|
||||
casesen=true
|
||||
showmx=false
|
||||
showmx=true
|
||||
startmx=3
|
||||
lst=true
|
||||
; can be M6502, M65C02, M65816
|
||||
cpu=M65816
|
||||
|
|
31
runtests.sh
Executable file
31
runtests.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
OUTDIR=./testout
|
||||
TMPFILE=/tmp/qasm_out.txt
|
||||
|
||||
rm -f $TMPFILE
|
||||
rm -rf $OUTDIR
|
||||
mkdir -p $OUTDIR
|
||||
|
||||
SRC=`ls ./testdata`
|
||||
|
||||
|
||||
for S in $SRC ; do
|
||||
|
||||
rm -f $TMPFILE
|
||||
|
||||
S1=$S
|
||||
S1=${S1/.S/.bin}
|
||||
S1=${S1/.s/.bin}
|
||||
|
||||
./qasm -o 0/$OUTDIR/$S1 ./testdata/$S >> $TMPFILE
|
||||
|
||||
R=?$
|
||||
echo $S " " $S1
|
||||
cat $TMPFILE | grep "End qASM assembly"
|
||||
|
||||
done
|
||||
ls -l $OUTDIR
|
||||
|
||||
|
||||
|
2
testdata/allops-common-6502.S
vendored
2
testdata/allops-common-6502.S
vendored
|
@ -2,6 +2,8 @@
|
|||
; See the LICENSE.txt file for distribution terms (Apache 2.0).
|
||||
;
|
||||
; Assembler: Merlin 32
|
||||
ABS equ $A55A
|
||||
ZP equ $FF
|
||||
|
||||
ORG $1000
|
||||
|
||||
|
|
5
testdata/allops-common-65816.S
vendored
5
testdata/allops-common-65816.S
vendored
|
@ -2,6 +2,11 @@
|
|||
; See the LICENSE.txt file for distribution terms (Apache 2.0).
|
||||
;
|
||||
; Assembler: Merlin 32
|
||||
MV0 equ $FE0000
|
||||
MV1 equi $FF0000
|
||||
|
||||
ABS equ $A55A
|
||||
ZP equ $FF
|
||||
|
||||
ORG $1000
|
||||
|
||||
|
|
3
testdata/allops-common-65C02.S
vendored
3
testdata/allops-common-65C02.S
vendored
|
@ -2,7 +2,8 @@
|
|||
; See the LICENSE.txt file for distribution terms (Apache 2.0).
|
||||
;
|
||||
; Assembler: Merlin 32
|
||||
|
||||
ABS equ $A55A
|
||||
ZP equ $FF
|
||||
ORG $1000
|
||||
|
||||
JSR PostBRK
|
||||
|
|
1
testdata/qasm
vendored
1
testdata/qasm
vendored
|
@ -1 +0,0 @@
|
|||
../qasm
|
Loading…
Reference in New Issue
Block a user