Re: C programming on ARM



On 2008-01-30, Wilco Dijkstra <Wilco_dot_Dijkstra@xxxxxxxxxxxx> wrote:

"Hans-Bernhard Bröker" <HBBroeker@xxxxxxxxxxx> wrote in message news:fnr0vs$mp6$00$1@xxxxxxxxxxxxxxxxxxxx
Wilco Dijkstra wrote:

With any byte addressable architecture, a pointer is just a pointer.

But there are quite a few non-byte addressable architectures out there.
Including ARM, last I checked.

Actually most architectures are byte addressable, including ARM,

Depends on what exactly you mean by the term.

AFAIK ARM7 is byte-addressable only for bytes, but not for larger objects. Well, may be it's just me, but I wouldn't
call what happens when an ARM7 accesses a 32-bit integer without 4-byte alignment "addressing".

Obviously not all possible pointer values are valid for all types. This doesn't
affect byte addressability as casting between char* and int* doesn't lose
information. Accessing a misaligned pointer will result in an exception

On some systems. On others you just get garbage values.

(which is a good way to detect corrupted pointers). However if
you use the correct type (eg. __packed int *p rather than int
*p), the compiler will generate an unaligned access.

I tried to figure out how to do that using gcc, but never I
seemed to get the declarations or typedefs right...

--
Grant Edwards grante Yow! We have DIFFERENT
at amounts of HAIR --
visi.com
.



Relevant Pages

  • Re: pointer problem
    ... to the correct type as you pass it in. ... Then the cast is unnecessary. ... void qsort(void *lineptr, int left, int right, ...
    (comp.lang.c)
  • Re: Strange behaviour
    ... If any argument is not the correct type for the corresponding ... conversion specification, the behaviour is undefined. ... wherever an int or unsigned int may be used: ... whose integer conversion rank is less than ...
    (comp.lang.c)
  • Re: Error message : "function returns address of local variable"
    ... Please what's the correct type of the fb function? ... >int main { ... res is a local variable. ... your compiler also should also have complained that res ...
    (comp.lang.c)
  • Re: Usefulness of %hd in printf
    ... i.e. it doesn't truncate 'a' (which of type int) when prints ... promotions, but its value shall be converted to short int or ... If the correct type is short, ... The standard doesn't say that printf() uses. ...
    (comp.lang.c)