gnupic: Thread: macro usage


[<<] [<] Page 1 of 1 [>] [>>]
Subject: macro usage
From: Joe M ####@####.####
Date: 30 Jun 2011 20:03:50 -0000
Message-Id: <BANLkTikQaKfT_-cx-_S-+4F3Lw3aubTpwQ@mail.gmail.com>

Hello,

I am trying to figure out how the macros in gpasm work?

I am trying to generate a table of calls such as:

  call mycall1
  call mycall2
  call mycall3

and this is the code I am trying it with:

repeat macro label,firstIndex,no_of_times
   if (no_of_times > 0)
      call label#v(firstIndex)
      repeat label, (firstIndex + 1),(no_of_times - 1)
   endif
   endm

   repeat mycall,1,10

repeat mycall,1,9 works fine. But, not "repeat mycall,1,10"

but, gpasm gives me these errors:

cp ../src/test_macro_usage.asm ./ && gpasm --expand ON -c test_macro_usage.asm
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall11).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall11).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall12).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall12).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall13).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall13).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall14).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall14).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall15).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall15).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall16).
test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall16).

sample source file:

;==== test_macro_usage.asm BEGIN

   errorlevel 0
   list p=18f4455 ; set processor type
   list n=0 ; supress page breaks in list file
   include <p18f4455.inc>

RESET_VECTOR CODE 00000h ; Reset and Interrupt Vectors
   pagesel start
   global start
   goto start

MAIN CODE

   global start
start
   nop

mycall1
   return
mycall2
   return
mycall3
   return
mycall4
   return
mycall5
   return
mycall6
   return
mycall7
   return
mycall8
   return
mycall9
   return
mycall10
   return

; macro to generate a list of call such as
;  call mycall1
;  call mycall2
;  call mycall3
repeat macro label,firstIndex,no_of_times
   if (no_of_times > 0)
      call label#v(firstIndex)
      repeat label, (firstIndex + 1),(no_of_times - 1)
   endif
   endm

   repeat mycall,1,10

loop
   goto loop

   return

Any thoughts, please?

Thanks
Joe
Subject: Re: macro usage
From: Noel Henson ####@####.####
Date: 30 Jun 2011 20:14:58 -0000
Message-Id: <1309464870.1920.24.camel@HP>

Have you check the .lst output file? If your radix is not set to
decimal, you may be generating mycalls 1-9,a,b,c,d,e,f.

Noel

On Tue, 2011-06-28 at 16:56 -0400, Joe M wrote:
> Hello,
> 
> I am trying to figure out how the macros in gpasm work?
> 
> I am trying to generate a table of calls such as:
> 
>   call mycall1
>   call mycall2
>   call mycall3
> 
> and this is the code I am trying it with:
>
> repeat macro label,firstIndex,no_of_times
>    if (no_of_times > 0)
>       call label#v(firstIndex)
>       repeat label, (firstIndex + 1),(no_of_times - 1)
>    endif
>    endm
> 
>    repeat mycall,1,10
> 
> repeat mycall,1,9 works fine. But, not "repeat mycall,1,10"
> 
> but, gpasm gives me these errors:
> 
> cp ../src/test_macro_usage.asm ./ && gpasm --expand ON -c test_macro_usage.asm
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall11).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall11).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall12).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall12).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall13).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall13).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall14).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall14).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall15).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall15).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall16).
> test_macro_usage.asm:52:Error [113] Symbol not previously defined (mycall16).
> 
> sample source file:
> 
> ;==== test_macro_usage.asm BEGIN
> 
>    errorlevel 0
>    list p=18f4455 ; set processor type
>    list n=0 ; supress page breaks in list file
>    include <p18f4455.inc>
> 
> RESET_VECTOR CODE 00000h ; Reset and Interrupt Vectors
>    pagesel start
>    global start
>    goto start
> 
> MAIN CODE
> 
>    global start
> start
>    nop
> 
> mycall1
>    return
> mycall2
>    return
> mycall3
>    return
> mycall4
>    return
> mycall5
>    return
> mycall6
>    return
> mycall7
>    return
> mycall8
>    return
> mycall9
>    return
> mycall10
>    return
> 
> ; macro to generate a list of call such as
> ;  call mycall1
> ;  call mycall2
> ;  call mycall3
> repeat macro label,firstIndex,no_of_times
>    if (no_of_times > 0)
>       call label#v(firstIndex)
>       repeat label, (firstIndex + 1),(no_of_times - 1)
>    endif
>    endm
> 
>    repeat mycall,1,10
> 
> loop
>    goto loop
> 
>    return
> 
> Any thoughts, please?
> 
> Thanks
> Joe
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
> 


Subject: Re: macro usage
From: Dave Tweed ####@####.####
Date: 30 Jun 2011 21:26:22 -0000
Message-Id: <E1QcOki-00013Z-Tx@elasmtp-mealy.atl.sa.earthlink.net>

Joe M wrote:
> I am trying to generate a table of calls such as:
> 
>   call mycall1
>   call mycall2
>   call mycall3
> 
> and this is the code I am trying it with:
> 
> repeat macro label,firstIndex,no_of_times
>    if (no_of_times > 0)
>       call label#v(firstIndex)
>       repeat label, (firstIndex + 1),(no_of_times - 1)
>    endif
>    endm
> 
>    repeat mycall,1,10
> 
> repeat mycall,1,9 works fine. But, not "repeat mycall,1,10"

Recursive macro expansion?!?

It wouldn't surprise me in the least if the stack limit for expanding macros
is on the order of 10 levels. But I guess I would be surprised that gpasm
doesn't give you an explicit error message about exceeding that.

It would be better to use a loop. MPASM has while/endw directives -- does
gpasm have this as well?

-- Dave Tweed
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.