gnupic: Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund


Previous by date: 11 Sep 2000 04:58:54 -0000 Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund, Wojtek Zabolotny
Next by date: 11 Sep 2000 04:58:54 -0000 Re: programming PICs using PROMATE II and dosemu, Daniel Christian
Previous in thread: 11 Sep 2000 04:58:54 -0000 Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund, Wojtek Zabolotny
Next in thread: 11 Sep 2000 04:58:54 -0000 Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund, w. v. ooijen / f. hanneman

Subject: Re: [PIC]: Global symbols in macros don't work in gpasm? - DIRTY workoraund
From: Scott Dattalo ####@####.####
Date: 11 Sep 2000 04:58:54 -0000
Message-Id: <Pine.LNX.4.21.0009101721520.21502-100000@tempest2.blackhat.net>


On Sun, 10 Sep 2000, Wojtek Zabolotny wrote:

> 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.

<snip>

> > 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...

I spent two hours just trying to figure out why this is happening. I then spent
another hour trying to fix it (before giving up :( ). And then I went back and 
spent another three hours. and now it's nearly midnight. Now I'm pissed...

The problem is, as you correctly assumed, due to the macro being evaluated
twice. However, this double evaluation is necessary because gpasm is designed as
a `two-pass' assembler. In many cases, a single pass is sufficient. However, if
there's a local label that is forward referenced, two passes are needed. In many
cases, two passes are not needed, but it doesn't hurt. The exception is when a
global variable is changed in the macro.

What is needed is a way to differentiate local and global variables and only
allow the latter to change during the second pass through the macro.
Unfortunately, I'm not too familiar with this part gpasm (James Bowman wrote
that part and I've heard from James for several months).

Scott


Previous by date: 11 Sep 2000 04:58:54 -0000 Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund, Wojtek Zabolotny
Next by date: 11 Sep 2000 04:58:54 -0000 Re: programming PICs using PROMATE II and dosemu, Daniel Christian
Previous in thread: 11 Sep 2000 04:58:54 -0000 Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund, Wojtek Zabolotny
Next in thread: 11 Sep 2000 04:58:54 -0000 Re: Global symbols in macros don't work in gpasm? - DIRTY workoraund, w. v. ooijen / f. hanneman


Powered by ezmlm-browse 0.20.