Compilers and programming style (was Re: A question of style)
Scott Amspoker
scott at bbxsda.UUCP
Thu Jan 11 03:01:02 AEST 1990
In article <279 at dino.cs.iastate.edu> hascall at cs.iastate.edu (John Hascall) writes:
>}Just curious - what kind of code should be generated for the above
>}C fragment?
>
> (using VAX-11 as an example)
>
> MOVL @P,temp ; move int pointed to by P into a throwaway
> or
> TSTL @P ; compare int pointed to by P to zero
>
> If you've never written a device driver, you may not understand why
> you would want to do this.
I've written plenty of device drivers and I still wouldn't do it. I
suppose that since device drivers are extremely implementation dependant
it probably wouldn't hurt to assume that the C semantics for
*p;
would cause a TSTL instruction - especially if by experimentation you
discover that to be true on your particular compiler. I just don't
recall reading that anywhere. If I wanted to merely access a memory
location I would do something like
dummy = *p;
But even then, some compilers might throw that away if dummy is dead
(which it probably is).
--
Scott Amspoker
Basis International, Albuquerque, NM
(505) 345-5232
unmvax.cs.unm.edu!bbx!bbxsda!scott
More information about the Comp.lang.c
mailing list