L
Luke Wu
Hello,
Is it safe to say that almost nothing can be gleaned about physical CPU
behaviour from C level behaviour.
For example:
- do the addresses returned by & have to have (by Standard) any direct
relationship to real addresses?
-- if the address of 2 objects is different by 'x' in C (when using &
operator), are they so in the hardware?
- do the elements of an array usually end up being placed side by side
in most implementations (does the standard require this) ?
how about multidimensional arrays?
-- I've seen code where two or more arrays would be declared side by
side and then the first array with extended indexing would be used to
access the elements of the second/more array. Does this suggest that C
guarantees that declared variables of the same storage class are placed
in ascending order in memory?
int a[10], b[10], c[20];
int i;
for(i = 0; i < 40; i++)
{
a = 0; /* zero initializes all three arrays */
}
- I read in an article once (can't find it now) that a "byte" in C
doesn't necessarily have to be an octet of bits at the hardware level
Any help would be appreciated.
(Are there any links on the net that point to details of C's
abstraction layer? I can't seem to find any. I guess these details
are woven through the standards documents, but I'm talking about a
single cohesive document)
the CPU can be totally different from the atual CPU.From spending some time in clc, I've come to realize that C's model of
Is it safe to say that almost nothing can be gleaned about physical CPU
behaviour from C level behaviour.
For example:
- do the addresses returned by & have to have (by Standard) any direct
relationship to real addresses?
-- if the address of 2 objects is different by 'x' in C (when using &
operator), are they so in the hardware?
- do the elements of an array usually end up being placed side by side
in most implementations (does the standard require this) ?
how about multidimensional arrays?
-- I've seen code where two or more arrays would be declared side by
side and then the first array with extended indexing would be used to
access the elements of the second/more array. Does this suggest that C
guarantees that declared variables of the same storage class are placed
in ascending order in memory?
int a[10], b[10], c[20];
int i;
for(i = 0; i < 40; i++)
{
a = 0; /* zero initializes all three arrays */
}
- I read in an article once (can't find it now) that a "byte" in C
doesn't necessarily have to be an octet of bits at the hardware level
Any help would be appreciated.
(Are there any links on the net that point to details of C's
abstraction layer? I can't seem to find any. I guess these details
are woven through the standards documents, but I'm talking about a
single cohesive document)