Hi Mark,
Here the results from Hias running his test suite:
I just tested atasm trunk (svn rev 83) with my test sources and found several outstanding issues:
In two cases I could get atasm to segfault
source #1:
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
.if .def FOO
BAR=$3B
.endif
FOO=1
.if .def FOO
DEC BAR
.endif
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
source #2:
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
.MACRO WAIT
WREMAIN .= %1
.IF WREMAIN >= 2
WDELAY .= WREMAIN/2
WREMAIN .= WREMAIN - [WDELAY*2]
.ENDIF
.ENDM
W .= 1
.rept 2
WAIT W
W .= W + 1
.endr
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
It looks like another pass would be needed, the interesting thing
about #2 is that the segfault only occurs in combination with
the ".rept" block.
I don't have a fix for the issues behind this, the following patch
just checks for the null-pointer and outputs an error:
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
--- src/asm.c (revision 83)
+++ src/asm.c (working copy)
@@ -824,6 +824,11 @@
}
if (eq) { /* an equate */
sym=findsym(label);
+ if (!sym) {
+ char buf[256];
+ sprintf(buf,"Cannot find label %s", label);
+ error(buf,1);
+ }
str=get_nxt_word(1);
if (pass) {
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
Using a ".if .def FOO .or .def BAR" statement doesn't work correctly.
It looks like the parser just turns this into ".if .def FOO.OR.DEFBAR".
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
FOO = 1
BAR.OR.DEFBAZ = 1
.if .def FOO .or .def BAR
.WARN "FOO or BAR defined"
.endif
.if .def BAR .or .def BAZ
.WARN "BAR or BAZ defined"
.endif
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
The first .if block doesn't trigger the warning, although FOO is defined,
and the second .if block triggers the warning, although neither BAR
nor BAZ are defined.
Here's a patch against setparse.c that fixes this issue:
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
--- src/setparse.c (revision 83)
+++ src/setparse.c (working copy)
@@ -113,7 +113,7 @@
int get_name(char *src, char *dst) {
int l=0;
- while((isalnum(*src))||(*src=='_')||(*src=='?')||(*src=='@')||(*src=='.')) {
+ while((isalnum(*src))||(*src=='_')||(*src=='?')||(*src=='@')) {
*dst++=toupper(*src++);
l++;
}
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
Next issue: unterminated strings don't produce a warning and atasm
simply snips off the last character. The following code assembles
to a single byte object file with the character 'h', the 'i' is
missing.
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
.byte "hi
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
When a standard equate is (accidentally) redefined, the second definition
is silently ignored (an error would be appropriate here IMO). The
symbol table only contains the first definition, the assembled code
also uses the first definition.
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
FOO = 1
FOO = 2
LDA FOO
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
Double forward references don't seem to work, and what's even worse,
they simply assemble to $FFFF without any warning. The following
code assembles to "JMP $FFFF" instead of "JMP $1003", but the symbol
table output lists FOO to be $1003.
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
JMP FOO
FOO = BAR
BAR RTS
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
Using a local label as a macro parameter doesn't work, atasm just
reports ?BAR to be an unknown symbol.
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
.MACRO FOO
LDA %1
.ENDM
?BAR .BYTE 1
FOO ?BAR
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
Direct references to a local label don't work, too:
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
* = $1000
?BAR .BYTE 0
.MACRO FOO
LDA ?BAR
.ENDM
FOO
----8<---- snip ----8<---- snip ----8<---- snip ----8<---- snip ----8<----
It would be great if you could fix these issues in the upcoming release,
I really like atasm a lot and use it for all of my Atari projects.
so long & thanks a lot for your excellent work,
Hias