This commit is contained in:
marketideas 2019-11-17 13:32:32 -08:00
parent 988e4b1f62
commit dcd12630af
5 changed files with 68 additions and 35 deletions

View File

@ -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++;

View File

@ -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;
}

23
runtests.sh Executable file
View File

@ -0,0 +1,23 @@
#!/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
./qasm ./testdata/$S >> $TMPFILE
R=?$
echo $S
cat $TMPFILE | grep "End qASM assembly"
done

View File

@ -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

1
testdata/qasm vendored
View File

@ -1 +0,0 @@
../qasm