Re: complier problem



Chris Torek wrote:
[the compiler can produce varying machine code for the C source:]
save = p++;

In article <r9ydnT3pDI-RaFfZnZ2dnUVZ_sGdnZ2d@xxxxxxxxxxx>,
Ark <akhasin@xxxxxxxxxxxxxxxxxxxx> wrote:
Looks like a storm in a teacup. ['save' doesn't have to exist at all,
depending on the instruction set,

The intent of this later example -- which I admit is not clear if
you follow the whole thread and think that it is *not* a separate
example -- is that the "save = p++;" is a complete line of C source
code. Hence "save" *does* exist, right there in the source code. :-)

and *p++=c; may execute in a single instruction]

On some architectures (try it on a SPARC or MIPS!); but this is a
different line of source code anyway. :-) And of course, while a
number of architectures have a single instruction that implements
"*p++ = expr" and "*--p = expr", many of those do not have a single
instruction that implements "*++p = expr" or "*p-- = expr". (But
some do.)

p++ has a value (old p) and a side effect (p = old p + 1).
*p++ dereferences the value of p++ (old p).

(Correct -- but can you say that in no fewer than 1000 words? :-) )

I'd care about implementation only when shopping for a compiler (or
squeezing out that last optimization)

Indeed, this is an appropriate attitude.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
.



Relevant Pages

  • Re: How function works internally
    ... the x86 is largely based on 1970s-era architectures (specifically ... but the instruction set itself remains klunky nonetheless. ... call func ...
    (comp.lang.c)
  • Re: xp ddk 64bit built environment
    ... >64bit environment? ... because at least one of the supported 64-bit architectures (ia64) ... has an entirely different instruction set. ...
    (microsoft.public.development.device.drivers)
  • Re: 32bits and memory size.
    ... I'll admit it's a curious lack, but I don't recall lamenting its ... I guess I was too busy using the instruction set that had ...
    (uk.comp.os.linux)
  • Re: Wanted: 64bit ELF spec
    ... has some links to ELF ABI supplements for various instruction set ... architectures. ... Good luck, ...
    (comp.lang.misc)