gnupic: Question about macros in gpasm


Previous by date: 10 Feb 2005 22:33:19 +0000 Re: [gnupic] gplink segmentation fault, craigfranklin.users.sourceforge.net
Next by date: 10 Feb 2005 22:33:19 +0000 upgrading gpasm/gplink warnings to errors, David McNab
Previous in thread:
Next in thread:

Subject: Question about macros in gpasm
From: David Willmore ####@####.####
Date: 10 Feb 2005 22:33:19 +0000
Message-Id: <200502102233.j1AMXDRp006432@localhost.localdomain>

Hello, all!

I've finally been tempted to use macros in some code--
lots of tedious repitition that I don't mind letting the
preprocessor do.  But, the final code is very hard to
read and debug.

I tried to solve things with careful use of EXPAND and
NOEXPAND, and got partial results.  NOEXPAND would make
the listing of the macro expansion immediately terminate--
including the NOEXPAND keyword.  This is good.  EXPAND,
unfortunately, included itself when it restarted listing
of macto expansion--not good.  Who wants a file full of
"EXPAND" statements.

The second issue is that when expanded into the list file,
values in macros don't appear as real values--the assembly
is right next to them, so they were concrete values.

Is there any way to have a macro like:

clrvar  macro   base, len
        clrf    base
        IF ((len-1) > 0)
          clrvar (base+1), (len-1)
        endm

That when used will look in the listing like:
               00007 CBLOCK  0x20
               00010         ta:4                    ; 32 bit temporary
               00014 ENDC
 
               00043         clrvar  ta,4
0011 01A6          M         clrf    ta
0012 01A7          M         clrf    ta+1
0013 01A8          M         clrf    ta+2
0014 01A9          M         clrf    ta+3

Or similar?  Because the current:
               00043         clrvar  ta,4
                   M         EXPAND
0011 01A6          M         clrf    base
                   M         EXPAND
0012 01A7          M         clrf    base
                   M         EXPAND
0013 01A8          M         clrf    base
                   M         EXPAND
0014 01A9          M         clrf    base

Isn't horribly useful.  Is there a pretty way to do this
other than symbolically dissassembling my code and using
that?

Oh the CBLOCK was altered to remove other variables not important
in this chunk of code, so don't worry that the address of 'f' in
the clrf instructions doesn't point to 0x20.

Thanks, everyone!

Cheers,
David

Previous by date: 10 Feb 2005 22:33:19 +0000 Re: [gnupic] gplink segmentation fault, craigfranklin.users.sourceforge.net
Next by date: 10 Feb 2005 22:33:19 +0000 upgrading gpasm/gplink warnings to errors, David McNab
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.