gnupic: Thread: Re: [gnupic] How to correctly use UDATA ?


[<<] [<] Page 1 of 1 [>] [>>]
Subject: Re: [gnupic] How to correctly use UDATA ?
From: Robert Pearce ####@####.####
Date: 29 Aug 2007 19:33:59 +0100
Message-Id: <20070829193320.f772ac92.rob@bdt-home.demon.co.uk>

Hi Vaclav,

On Wed, 29 Aug 2007 12:04:25 +0200 (CEST) you wrote:
> Hello all,
> 
> I used to use CBLOCK for uninitialized data section.
> 
> But now I am writing larger program so I need relocatable code. But I want to manage placing by myself to correct data-bank.
> 
> In LKR file there is following line:
> DATABANK   NAME=gpr0     START=0x20     END=0x6F
> DATABANK   NAME=gpr1     START=0xA0     END=0xEF
> 
> How can I set that some variables should be put into "gpr0" section and others into "gpr1" section ?
> 

In my application I'm using a 16F871, so all the GPRs are in shared banks:
SHAREBANK   NAME=gprnobnk0  START=0x20     END=0x5F
SHAREBANK   NAME=gprnobnk0  START=0x120    END=0x15F

SHAREBANK   NAME=gprnobnk1  START=0xA0     END=0xBF
SHAREBANK   NAME=gprnobnk1  START=0x1A0    END=0x1BF

SHAREBANK   NAME=gprnobnk2  START=0x70     END=0x7F
SHAREBANK   NAME=gprnobnk2  START=0xF0     END=0xFF
SHAREBANK   NAME=gprnobnk2  START=0x170    END=0x17F
SHAREBANK   NAME=gprnobnk2  START=0x1F0    END=0x1FF

(I've deliberately restricted the memory, so 0x60 to 0x6F is unused, but don't worry about that)

Then lower down I declare:
SECTION     NAME=.udata     RAM=gprnobnk0
SECTION     NAME=.idata     RAM=gprnobnk0
SECTION     NAME=.udata_ovr RAM=gprnobnk2
SECTION     NAME=iscratch   RAM=gprnobnk2
SECTION     NAME=isr_comn   RAM=gprnobnk2
SECTION     NAME=sio_temp   RAM=gprnobnk1

Then in the code, I can use:
 udata_ovr
fifo_temp       res 1

sio_temp    udata_ovr
tDatePtr        res 1
tCommandByte    res 1

 udata
cmdState        res 1
sioEEAdr        res 1

This puts fifo_temp into gprnobnk2 (0x70-0x7f), tDatePtr and tCommandByte into gprnobnk1 (0xA0-0xBF) and cmdState and sioEEAdr into gprnobnk0. Note also that only the last two get unique addresses, the others can all be overlaid by variables in other files.

Hope that helps

Rob
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.