gnupic: gpasm - how to get address of variable ?
Subject:
Re: gpasm - how to get address of variable ?
From:
Joe Pfeiffer ####@####.####
Date:
8 Sep 2012 17:04:57 -0000
Message-Id: <20555.31412.478275.849821@pfeifferfamily.net>
Assembly languages generally don't have a real concept of "variables" --
they have lower-level concepts like symbols with values, which we use
as variables. A cblock is the way to get the assembler to
automatically assign values to symbols in a way that makes them useful
to us as variables -- they're really aren't structs.
Which reminds me that your use of
var_array: 1
is a little bit odd. From the name, it sounds like you want that
symbol to be useful as an array. If that's the case, you should
allocate as much space to it as you need for your array. If you want
a five element array, you'd say
var_array: 5
Borut Ražem writes:
>I was totally wrong: the cblock "variables" actually hold the address. I
>was wrongly thinking about cblocks as C structures...
>
>Obviously I have no idea how the assembler works :-[
>
>My apologies,
>Borut
>
>On 07. 09. 2012 10:15, Borut Ražem wrote:
>> Hi Vaclav,
>>
>> I don't think you can get the address of CBLOCK variable.
>> The alternative is to use EQUs instead of CBLOCK:
>>
>> var1 EQU 0x20
>> var_array EQU 0x21
>>
>> movlw var_array
>> movwf FSR
>>
>> Borut
>>
>> On 07. 09. 2012 09:52, Vaclav Peroutka wrote:
>>> Hello,
>>>
>>> I want to use FSR/INDF in assembler. I have defined
>>>
>>> CBLOCK 0x20
>>> var1: 1
>>> var_array: 1
>>> ENDC
>>>
>>> In the code, I want to use
>>> movlw address_of_var_array
>>> movwf FSR
>>>
>>> and then to write to var_array through INDF.
>>>
>>> How can I do that ? I did not find any expression in gputils manual.
>>>
>>> Thank you in advance,
>>> Vaclav
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ####@####.####
>For additional commands, e-mail: ####@####.####
>
--
Joseph J. Pfeiffer, Jr., Ph.D. http://pfeifferfamily.net/
1440 Tierra del Sol Dr 575.525.2764 (H)
Las Cruces, NM 88007 575.496.3501 (C)