How many instructions to access pointer in C?

Posted by Derek on Stack Overflow See other posts from Stack Overflow or by Derek
Published on 2010-04-30T20:35:06Z Indexed on 2010/04/30 20:37 UTC
Read the original article Hit count: 281

Filed under:
|

Hi All,

I am trying to figure out how many clock cycles or total instructions it takes to access a pointer in C. I dont think I know how to figure out for example, p->x = d->a + f->b

i would assume two loads per pointer, just guessing that there would be a load for the pointer, and a load for the value. So in this operations, the pointer resolution would be a much larger factor than the actual addition, as far as trying to speed this code up, right?

This may depend on the compiler and architecture implemented, but am I on the right track?

I have seen some code where each value used in say, 3 additions, came from a

 f2->sum = p1->p2->p3->x + p1->p2->p3->a + p1->p2->p3->m

type of structure, and I am trying to define how bad this is

© Stack Overflow or respective owner

Related posts about pointer

Related posts about instructions