Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] fixed address variable

2005-11-09 by Tom Walsh

Charles Manning wrote:

>On Thursday 10 November 2005 05:26, Tom Walsh wrote:
>  
>
>>szemzoandras wrote:
>>    
>>
>>>Hello,
>>>
>>>
>>>Is it possible to place a variable to a fixed memory location in gcc,
>>>like in keil, i mean:
>>>
>>>unsigned int dd _at_ 0x81000000;
>>>      
>>>
>>FWIW, I wonder why Keil added an extension to their C compiler?  I've
>>been using "int * dd = ((unsigned int *)0x81000000)" for many many
>>years.  Not only with gcc, but other compilers as well.
>>    
>>
>
>There is a difference.
>
>When you do something like:
>unsigned int dd _at_ 0x810000;
>
>often the linker will check for overlaps etc. Depends on the compiler/linker 
>though.
>
>Also, you need to look at the their offerings to understand it. Their older 
>compilers (8051 etc) had this feature and so did PLM (now that was a 
>fantastic language for 8051s)! They don't want to make their newer compilers 
>seem less capable.
>
>When you do 
>int * dd = ((unsigned int *)0x81000000
>you're bypassing everything. That's probably fine for accessing hard locations 
>like peripherals etc.
>
>IMHO, using extensions is a very bad thing. It was OK in the days of 8-bitters 
>where "C" code was just a C representation of assembly and code was very 
>non-portable. With most code though, you need portability. Heck I still use 
>code I first wrote 15 years ago and have been dragging from project to 
>project. Using any non-standard things breaks portability.
>
>I prefer to not do any of this sort of thing (except for hardware-specified 
>stuff like peripherals) and instead use linker scripts to do any placement.
>
>  
>
Yeah, like trying to get portability between Intel 8051 vs. Archemedes 
v3  vs Archemedes v4 compilers: it just ain't gonna happen!  Each dev 
system had its own funny little linker rules, bit access functions, C 
language extensions and assembly language file structure.  Each to deal 
in some weird way with code acess vs ram access.

ARM and gcc is so much simpler.  Linear address space and ANSI C.


TomW


-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.