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

Local symbols aren't recognized as macros in 68k mode #24

Open vladikcomper opened 2 years ago

vladikcomper commented 2 years ago

In the current version of AS, when the target CPU is 68000, it's impossible to refer to any macro defined as with a local symbol due to CPU-specific parsing behaviour.

When a macro is defined with a local symbol, any invocation of such macro will never be recognized by the assembler:

    cpu 68000

.local_macro:   macro message
    dc.b    message, 0
    endm

    .local_macro    'Hello'

This results into the following assembly error:

> > > main.asm(1):3: error: unknown instruction
> > > LOCAL_MACRO
> > >  .local_macro
> > >   ~~~~~~~~~~~

Notice how the actual macro name is misinterpreted as LOCAL_MACRO instruction instead (without a leading dot). This probably has something to do with 68k-specific line parsing, which treats . as opcode type separator.

The same macro seem to compile fine when the target CPU is Z80:

     cpu z80

.local_macro:   macro message
    db  message, 0
    endm

    .local_macro    'Hello'
flamewing commented 2 years ago

There are two parts to this:

  1. there is a bug that the leading dot of the opcode part will get stripped off in any processor that uses dots to split off attributes;
  2. macros (and functions) are not scoped: a macro with a leading dot is just a global macro with a dot in its name. So they will need to be extended to have local scopes.