Yeah, that would work too... that's not much different than declaring the
variables with absolute addressing, except that your way makes declaring
multiple variables easier.
The complexity I was referring to is if we tried to make that functionality
available in pure C - similar to the way the xdata and idata storage classes
work. Even with those, you could have used an asm to declare them in the
right place, but the storage classes make it much easier. So what I'm
getting at is, it would be really cool if you could define custom storage
One idea would be to add the capability to define a range on the storage
classes, so your variable would be declared like "code(0x3E00,0x3FFF) char
myvar;". Then you could do make a macro "#define flash code(0x3E00,0x3FFF)"
so your variable looks like "flash char myvar;". You could also use a
syntax similar to absolute addressing, like "code from 0x3E00 to 0x3FFF char
Ah, now I'm just rambling... I think all of this would be useful, but your
way works fine too...
> -----Original Message-----
> From: sdcc-user-admin@...
> [mailto:sdcc-user-admin@... Behalf Of Dave McGuire
> Sent: Monday, September 22, 2003 9:44 AM
> To: sdcc-user@...
> Subject: Re: [Sdcc-user] Anyway to specify addsolute location for
> ROM/flash variables?
> On Monday, September 22, 2003, at 10:56 AM, Josh Stone wrote:
> > I would use the absolute addressing to place it at the very last block
> > of the flash memory, so that it is completely separate from your code
> > space. For example, if it's a 16k flash, store your variables from
> > 0x3E00-0x3FFF.
> > While it would be convenient for SDCC to handle this automatically, it
> > would add quite a bit of programming complexity. Basically, there
> > would need to be a way to have user-defined data segments, and then a
> > way for the C-code to specifiy in which segment the variable
> should > go.
> Hmm...correct me if I'm wrong, but I believe this wouldn't actually
> be all that difficult. I'm doing a very similar thing in several of my
> projects (not for flash, for some other stuff) and it involves the use
> of an assembly language source file in your code. In that file, use
> the appropriate assembler directives to put variables where you want
> them, and then make them global.
> You'd want to do something like this:
> .module foo
> .title foo
> .globl _var1 ;; make these symbols global
> .globl _var2
> .area FLASH_VARS (XSEG) ;; or wherever it needs to land...see
> assembler docs
> .org 0xf000 ;; or wherever your flash is located
> _var1: .ds 1 ;; 1-byte variable
> _var2: .ds 16 ;; 16-byte variable
> Now you can reference "var1" and "var2" from C code, and they'll be
> at the absolute addresses defined by the .org directive. Be sure to
> check the .rst file to make sure the symbols land where you expect them
> Dave McGuire "My tummy hurts now, but my soul
> St. Petersburg, FL feels a little better." -Ed
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> Sdcc-user mailing list