Re: [cc65] Macros in ca65

From: Björn Spruck <bjoern1spruck.net>
Date: 2011-12-08 10:59:33
Correction:

A simple solution would be a stack, -> push and pop

counter         .set    0   ;;; counting up only ((nesting level not needed))
counter3         .set    0  ;;; local variable



.macro  _IFNE
        counter .set    counter +1
        beq     .ident (.sprintf ("else%04d", counter))
	.push counter
 .endmacro

.macro  _IFEQ
        counter .set    counter +1
        bne     .ident (.sprintf ("else%04d", counter))
	.push counter
.endmacro

.macro  _ELSE
	.pop counter3
        bra     .ident (.sprintf ("endif%04d", counter3))
        .ident  (.sprintf ("else%04d", counter3)) := *
	.push counter3
.endmacro

.macro  _ENDIF
	.pop counter3
        .if     .not .defined( .ident (.sprintf ("else%04d", counter3)))
        .ident  (.sprintf ("else%04d", counter3)) := *
        .endif
        .ident  (.sprintf ("endif%04d", counter3)) := *
.endmacro




----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Dec 8 10:59:41 2011

This archive was generated by hypermail 2.1.8 : 2011-12-08 10:59:46 CET