gnupic: gpasm quirks
Subject:
Re: gpasm quirks
From:
####@####.#### (Linas Vepstas)
Date:
20 Jun 2002 01:52:38 -0000
Message-Id: <20020620014117.GA2099@backlot.linas.org>
On Thu, Jun 20, 2002 at 12:06:04AM +0100, Tim ODriscoll was heard to remark:
>
> 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? :)
I am the wrong person to answer this question, but I'll try anyway.
The variable only takes on values while you are assembling the program;
there is no 'myVar' in the binary. If you disassemble the binary,
you'll see where its a hard-coded '8'.
If you really want symbolic variables, you need to code in C,
not assembly. Alternately, you can do something like this:
myVarLocation=0x24 ; if location 0x24 is taken, try another
loop
movlw 4
movwf myVarLocation
call myFunc
movlw 5
movwf myVarLocation
call myFunc
movlw 8
movwf myVarLocation
call myFunc
--linas
--
pub 1024D/01045933 2001-02-01 Linas Vepstas (Labas!) ####@####.####
PGP Key fingerprint = 8305 2521 6000 0B5E 8984 3F54 64A9 9A82 0104 5933