I've added this here for archival purposes, as I've fixed this bug in my own fork of EASy68k.
There are a few syntax cases that trigger a false error due to how opparse.cpp handles parenthesized cases. For example:
LEA ($CFFF).w,A0 ; OK
LEA ($7FFF).w,A0 ; syntax error
LEA ($7FFF).w, A0 ; OK
The line that checks for (d,An) or (d,An,Xi) allows for some undefined behavior in syntax.
if (p[0] == '(' && p[1] != 'P' && p[2] != 'C') { // CK 2018-2-7
n = strchr(p,',');
This will find any comma in the line, even if it's outside the parenthesis. This also has a side effect of only filtering hex numbers that start with 'C':
LEA ($0FFF).w,A0 ; ERROR
LEA ($1FFF).w,A0 ; ERROR
...
LEA ($CFFF).w,A0 ; OK
LEA ($DFFF).w,A0 ; ERROR
Then:
if (n) {
if((n[1] == 'A' && isRegNum(n[2])) || (n[1] == 'S' && n[2] == 'P') ) {
This will directly point to the destination 'A0' if there is no space before the operand, and prematurely send the data off to 'eval':
p++; // skip (
// evaluate displacement, p points to ','
p = eval(p, &(d->data), &(d->backRef), errorPtr);
}
}
When a space is added to the destination after the comma, it just happens to work since n[1] != 'A'.
The easy fix is to add a check for the index of ')' and see if the comma found is inside before continuing:
n = strchr(p,',');
pn = strchr(p, ')');
if (n && n < pn) { ...
I've added this here for archival purposes, as I've fixed this bug in my own fork of EASy68k.
There are a few syntax cases that trigger a false error due to how opparse.cpp handles parenthesized cases. For example:
LEA ($CFFF).w,A0 ; OK
LEA ($7FFF).w,A0 ; syntax error
LEA ($7FFF).w, A0 ; OK
The line that checks for (d,An) or (d,An,Xi) allows for some undefined behavior in syntax.
This will find any comma in the line, even if it's outside the parenthesis. This also has a side effect of only filtering hex numbers that start with 'C':
LEA ($0FFF).w,A0 ; ERROR
LEA ($1FFF).w,A0 ; ERROR
...
LEA ($CFFF).w,A0 ; OK
LEA ($DFFF).w,A0 ; ERROR
Then:
This will directly point to the destination 'A0' if there is no space before the operand, and prematurely send the data off to 'eval':
When a space is added to the destination after the comma, it just happens to work since n[1] != 'A'.
The easy fix is to add a check for the index of ')' and see if the comma found is inside before continuing: