Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!unmvax!bbx!bbxsda!scott From: scott@bbxsda.UUCP (Scott Amspoker) Newsgroups: comp.lang.c Subject: Re: Compilers and programming style (was Re: A question of style) Message-ID: <539@bbxsda.UUCP> Date: 10 Jan 90 16:01:02 GMT References: <1989Dec22.100135.2903@gdt.bath.ac.uk> <4367@rtech.rtech.com> <1989Dec31.153241.16479@gdt.bath.ac.uk> <649@codonics.COM> <1990Jan5.100042.26760@gdt.bath.ac.uk> <2283@dataio.Data-IO.COM> <534@bbxsda.UUCP> <279@dino.cs.iastate.edu> Reply-To: scott@bbxsda.UUCP (Scott Amspoker) Organization: Basis International, Albuquerque, NM Lines: 35 In article <279@dino.cs.iastate.edu> hascall@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