Re: [cc65] Macros in ca65

From: Björn Spruck <bjoern1spruck.net>
Date: 2011-12-07 18:22:18
Am 06.12.2011 21:59, schrieb Ullrich von Bassewitz:
> -----------------------------------------------------------------------------
> counter         .set    0
>
> .macro  _IFNE
>         counter .set    counter +1
>         beq     .ident (.sprintf ("else%04d", counter))
> .endmacro
>
> .macro  _IFEQ
>         counter .set    counter +1
>         bne     .ident (.sprintf ("else%04d", counter))
> .endmacro
>
> .macro  _ELSE
>         bra     .ident (.sprintf ("endif%04d", counter))
>         .ident  (.sprintf ("else%04d", counter)) := *
> .endmacro
>
> .macro  _ENDIF
>         .if     .not .defined( .ident (.sprintf ("else%04d", counter)))
>         .ident  (.sprintf ("else%04d", counter)) := *
>         .endif
>         .ident  (.sprintf ("endif%04d", counter)) := *
>         counter .set    counter - 1
> .endmacro
> -----------------------------------------------------------------------------
>
> It doesn't do nesting, but I think you get the idea how to construct
> identifiers and use counters. To support nesting, I would add a second counter
> that counts the nesting level and is also placed into the identifier.
>
this looks promising.
but what happens if you have two of these after each other?
Is it possible to undef a label to bring it out of scope at with the _IF ?


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Dec 7 18:22:31 2011

This archive was generated by hypermail 2.1.8 : 2011-12-07 18:22:35 CET