Re: [cc65] Macros in ca65

From: Björn Spruck <bjoern1spruck.net>
Date: 2011-12-06 18:32:39
Am 06.12.2011 16:30, schrieb Ullrich von Bassewitz:
> Hi!
>
> On Tue, Dec 06, 2011 at 01:33:57PM +0100, Björn Spruck wrote:
>> now my question: any idea how this can be done in the simplest way in ca65?
> I'm not at home so I cannot try, but my first step would be to solve it in a
> similar way as the old assembler did. Use a counter to generate the labels.
> Anything else should be straight forward, provided that there is no nesting.
a) is there a way to put numbers from variables in label names?
b) nested would be needed
c) scoping was a problem for ra65 ... thus i needed a bit of patching
the source

the following was working in ra65 _after_ fixing the ifnd in code and
well the @ numbering... it was not enough to use a @ whcih is dec and
inc on nesting level as ra65 has problem with redefined labels. thus the
@ is used as a index to a table which is using unique numbers... the
lyxass assmbler did not have this problems.

  macro _IFNE
  inc@
  beq .iELSE@
  endm

  macro _IFEQ
  inc@
  bne .iELSE@
  endm

  macro _ELSE
  bra .iENDIF@
.iELSE@
  endm

  macro _ENDIF
  ifnd .iELSE@
.iELSE@
  endif
.iENDIF@
  dec@
  endm

>
>> remark: doing this with scopes or procs will not work if there is any
>> other label between IF and ENDIF which should be accessible from
>> outside, right?
> Labels within scopes are accessible from the outside (at least in the
> development version - don't remember about the stable one).
uh, but only if you have the name od the scope... which would be unknown
if the macros is creating it

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Dec 6 18:32:55 2011

This archive was generated by hypermail 2.1.8 : 2011-12-06 18:32:57 CET