flamewing / asl-releases

Improved/bugfixed version of Alfred Arnold's The Macro Assembler AS
http://john.ccac.rwth-aachen.de:8000/as/
GNU General Public License v2.0
20 stars 2 forks source link

Labels of different kinds do not interact well #17

Closed flamewing closed 3 years ago

flamewing commented 3 years ago

There are four kinds of labels in AS:

Normal and composite labels and nameless temporaries work well enough together:

-   bra.s   +
.test1:
    bra.s   .test2
.test3:
    bra.s   -
.test2:
+

This assembles without error and works as expected. The equivalent for normal labels also works.

Named temporaries and nameless temporaries, however, do not:

-   bra.s   +
$$test1:
    bra.s   $$test2
$$test3:
    bra.s   -
$$test2:
+
    bra.s   -

This usually gives an error:

> > > s2.asm(920):8: error: symbol undefined
> > > test23904
> > >  bra.s $$test2
> > >        ~~~~~~~

But moving it around gave me another error:

> > > s2.asm(1057): error: expression must be evaluatable in first pass
> > >  switch .c/4

The catch is that the code in question is inside a block of code that is disabled:

  if 1==0    ; <====
; freeObject2:
DeleteObject2:
    ; some code
    set .c,playerobj_size-4
    ; some code
    set .c,.c#(9*4)
    ; Clear in multiples of 4 bytes
    switch .c/4

Might be related to issue #3

flamewing commented 3 years ago

Hm. This definitely seems related to #3; this code also causes the switch error if placed on the same location as the code with $$ labels:

test0:
back:
    bra.s   forward
test1:
    bra.s   test2
test3:
    bra.s   back
test2:
forward:
    bra.s   back

Note that it only has normal labels. In fact, this code does not cause the switch error if placed in the same location:

.test0:
.back:
    bra.s   .forward
.test1:
    bra.s   .test2
.test3:
    bra.s   .back
.test2:
.forward:
    bra.s   .back

So it seems composite labels are doing something that prevents the issue altogether!

flamewing commented 3 years ago

On further investigation, the switch issue is just a missing check to see if it happens in an unevaluated context. There was a variable .cnt used before the point of the error and no intervening labels, which hid the error; in the end, the switch error is probably not related to issue #3.