gnupic: address space


Previous by date: 10 Dec 2004 02:13:25 +0000 address space, Dante
Next by date: 10 Dec 2004 02:13:25 +0000 Re: address space, Dante
Previous in thread: 10 Dec 2004 02:13:25 +0000 address space, Dante
Next in thread: 10 Dec 2004 02:13:25 +0000 Re: address space, Dante

Subject: Re: address space
From: Maxime Larocque ####@####.####
Date: 10 Dec 2004 02:13:25 +0000
Message-Id: <41B905FE.6090402@yahoo.ca>

Hello,

Dante wrote:

> Ok, so I think perhaps this time I am using the proper forum for this 
> question.
>
> I am using gpasm-0.12.4 (beta as per debian) I am attempting to use 
> the variable directive to set up the variable labels to make life a 
> wee bit easier. My own (and very limited experience) indicates that 
> this should assign data address space for the variable. However 
> looking at the symbols for the resulting code file seems to indicate 
> that this is not really the case. It looks like attempting to <label> 
> = (value); results in (value) being assigned as an address. This being 
> the case, is there a way to assign both the address and a value, or do 
> I need to do this a two seperat operations, or am I just being stupid?
>
> Keith
>

I was browsing the gputils manual about this.

Chapter 2 talks about a VARIABLE directive that does just that, but it 
is about gpal. I does know much about gpal.

Chapter 3 talks about another VARIABLE directive, but this time for 
assembler. This one is similar to CONSTANT, but is variable only at 
compilation time, not runtime.


If that can help, I use the following macros in all my asm PIC projects 
since maybe 2000:


===================== Code snipplet start

    if PIC_FAMILY==16870
#define MAXLIB_MEMSTART_B0  0x020   ; 80 bytes + 16 shared
#define MAXLIB_MEMSTART_B1  0x0A0   ; 80 bytes
#define MAXLIB_MEMSTART_B2  0x110   ; 96 bytes
#define MAXLIB_MEMSTART_B3  0x190   ; 96 bytes
    endif
    if PIC_FAMILY==16628
#define MAXLIB_MEMSTART_B0  0x020   ; 80 bytes + 16 shared
#define MAXLIB_MEMLEN_B0    0x060
#define MAXLIB_MEMSTART_B1  0x0A0   ; 80 bytes
#define MAXLIB_MEMLEN_B1    0x050
#define MAXLIB_MEMSTART_B2  0x120   ; 48 bytes
#define MAXLIB_MEMLEN_B2    0x030
#define MAXLIB_MEMEND_B2    0x150
    ; No bank 3 in the pic16f628.
    endif

; Dynamic variable allocation

;       start of available memory
dec_var_count   set     MAXLIB_MEMSTART_B0

dec_var         macro   VARNAME
VARNAME         set     dec_var_count
dec_var_count   set     dec_var_count+1
    if (dec_var_count == 0x71)
    too_much_variables_bank0
    endif
                endm

===================== Code snipplet end


You just have to declaration actual RAM variable by using the macro:

       dec_var   A_RAM_VARIABLE

 ... and then use it in your software:

       movfw   A_RAM_VARIABLE
      incf A_RAM_VARIABLE,f

  etc...


I found it very usefull to develop modular software, since adding / 
removing module does not imply reassigning all the data memory.

Hope that help.

Maxime Larocque
(Sorry about the library name, it's just a lack of imagination!)


Previous by date: 10 Dec 2004 02:13:25 +0000 address space, Dante
Next by date: 10 Dec 2004 02:13:25 +0000 Re: address space, Dante
Previous in thread: 10 Dec 2004 02:13:25 +0000 address space, Dante
Next in thread: 10 Dec 2004 02:13:25 +0000 Re: address space, Dante


Powered by ezmlm-browse 0.20.