gnupic: gpasm quirks
Subject:
Re: gpasm quirks
From:
Craig Franklin ####@####.####
Date:
20 Jun 2002 01:48:56 -0000
Message-Id: <3D11331A.381DAEF@attbi.com>
I know you are using it for pins but are you seeing something like this?
00001
00002 processor 16c84
00003
0000 00004 myFunc
0000 3008 00005 movlw myVar
0001 0008 00006 return
00007
00008 variable myVar
00009
0002 00010 loop
00000004 00011 myVar=4
0002 2000 00012 call myFunc
00013
00000005 00014 myVar=5
0003 2000 00015 call myFunc
00016
00000008 00017 myVar=8
0004 2802 00018 goto loop
00019
gpasm is operating as intended. The code for myFunc is generated once,
on the second pass. When that pass starts MyVar has a value of 8, so
that is the value gpasm uses to generate the code. MPASM would do the
same but it removes the variables from the symbol table between passes,
so it generates an undefined symbol error.
You need to either use macros or place myVar in data memory. The
following is a example of how it could be accomplished using macros.
processor 16c84
myFunc macro value
movlw value
endm
variable myVar
loop
myVar=4
myFunc myVar
myVar=5
myFunc myVar
myVar=8
goto loop
end
Hope this helps.
Tim ODriscoll wrote:
>
> Hi everyone,
>
> Sorry for the really basic question, but I've not found an answer in the
> docs/pdf's..
>
> I'm wanting to use the variable command of gpasm so I can tell a function
> which pin it should be using for it's output.
>
> Here's what I'm doing:
> ;=======================
> variable myVar
>
> loop
> myVar=4
> call myFunc
>
> myVar=5
> call myFunc
>
> myVar=8
> goto loop
> ;========================
>
> Trouble is that each time myFunc is called, it seems to think myVar=8...
>
> I'm using the latest gputils-0.10.3, so it's gotta be my syntax.. I've
> tried all the different combinations I can think of, but the one that
> works is eluding me!.. There's no compiler errors from gpasm when it
> assembles the hex file, either..
>
> Can someone show me The Right Way to assign values to variables? :)
>
> Cheers,
>
> Tim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####