m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Maintaining global state with m4 macros


From: Paolo Amoroso
Subject: Re: Maintaining global state with m4 macros
Date: Thu, 2 Dec 2021 19:25:11 +0100

On Thu, Dec 2, 2021 at 6:45 PM Douglas McIlroy
<douglas.mcilroy@dartmouth.edu> wrote:
>
> define(bump,`define(`$1',incr($1))')dnl
> define(counter,0)dnl
> counter
> bump(`counter')counter
> bump(`counter')counter

Thanks Douglas, your solution works great. In the context of the
Assembly macros I mentioned in an
earlier message I'd add something like this to your code:

    define(`mymacro',
    `Lbump(`counter')counter
            mvi     a, $1')

    mymacro(`3')

But the output is not what I'd expect:

    0
    1
    2
    [blank lines]
    Lbump(counter)2:
            mvi     a, 3

Instead I need:

    L2:
            mvi     a, 3


Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]