gnupic: Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund
Subject:
Re: [PIC]: Global symbols in macros don't work in gpasm? - DIRTY workoraund
From:
Wojtek Zabolotny ####@####.####
Date:
10 Sep 2000 10:36:32 -0000
Message-Id: <20000910123628.A2365@wzab.nasz.dom>
On Sun, Sep 10, 2000 at 11:40:17AM +0200, Wojtek Zabolotny wrote:
> I have a problem with setting of global symbols in macros in gpasm.
> Let's consider the following source:
> => test.asm <=
> list p=16f877
> counter macro
> x_cnt set x_cnt + 1
> movlw x_cnt
> endm
>
> org 0
> x_cnt set 0
> counter
> counter
> counter
> end
> => end of test.asm <=
>
> Well it has no sense, but clearly demonstrates the problem. I'd expect
> to get the following instructions assembled:
> movlw 1
> movlw 2
> movlw 3
>
> But in fact I get the
> movlw 2
> movlw 4
> movlw 6
>
> It seems that each macro is evaluted TWICE =:-( ?!
I've just found a very dirty workaround for the problem stated above
It is based on the assumption, that each macro is evaluated EXACTLY TWICE,
so it works with gpasm, but doesn't work with mpasm (my original source
works with mpasm and dosn't work with gpasm).
However it may be a solution, until the weird behaviour of gpasm gets
fixed...
The "counter" macro should be redefined in the following way:
counter macro
x_cnt_tmp1 set x_cnt + 1
x_cnt set x_cnt_tmp
x_cnt_tmp set x_cnt_tmp1
movlw x_cnt
endm
Very dirty trick, but at least works...
--
Greetings
Wojciech Zabolotny
http://www.ise.pw.edu.pl/~wzab
http://www.gnupg.org Gnu Privacy Guard - protect your mail & data
with the FREE cryptographic system