On 16/10/11 7:36 PM, Eric Smith wrote:
On 10/16/2011 12:38 PM, Chuck Guzis wrote:
But--C is implemented on systems without byte
addressing, as
previously noted, where the smallest addressable unit is the word.
Yes, and they do one of several things:
1) implement byte pointers in software, so that a character is smaller
than a word and not hardware addressable
2) use the word as the smallest addressable unit, in which case a
character occupies a full word
3) hybrid - use software-implemented byte pointers for char, and normal
machine pointers for date types that the hardware can address
Note that (3) is possible because C does not require that all pointers
have the same representation. C does not even require that if you take a
char *, cast it to an int *, and then cast it back to a char *, that you
get a valid pointer. In fact, just doing the cast has unpredictable
results and may even crash at the point of the cast, without
dereferencing the resulting pointer.
Exactly. On DG Nova, inter alia, byte pointers and word pointers have a
different representation.
--Toby
However, the reverse, taking an int *, casting it to a char *, and then
back to an int *, is required to work....