Re: increment



mike7411@xxxxxxxxx wrote:
I defined an integer in Visual C++ as follows:

int c=0;

Then, I did the following:

c++;

Miscrosoft Visual C++ says "c++;" compiled into the following code:

mov eax,dword ptr [c]
add eax,1
mov dword ptr [c],eax

I'm trying to figure out why it didn't just compile into this:

add dword ptr [ebp-4], 1

Is this just compiler inefficiency, or is there some reason the VC++
code is actually faster?

Thanks.


Just a hint: maybe it is because there is no optimisation performed...
.



Relevant Pages

  • Re: increment
    ... int c=0; ... I'm trying to figure out why it didn't just compile into this: ... add dword ptr [ebp-4], 1 ...
    (alt.lang.asm)
  • Re: GCC difference in size of long int on Suse SLES9 / Suse Professional 10.0
    ... The kernel uses printf() with 'long int', ... I can't compile 'on-the-fly'. ... clashing with the hardware and any libs that you interact with. ... platform types build up their own int types. ...
    (comp.os.linux.development.apps)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
    (comp.lang.lisp)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
    (comp.unix.programmer)
  • Re: new order doubt
    ... Warning test2.c: 8 no type specified. ... Defaulting to int ... Tests probably come in several different types: this should compile ... Even Microsoft has problems with this obscure rules. ...
    (comp.lang.c)