The stupid question is the question not asked | |
PerlMonks |
Re^2: Help me to understand increment / decrement operator behavior in perlby BrowserUk (Patriarch) |
on Mar 04, 2015 at 17:06 UTC ( [id://1118763]=note: print w/replies, xml ) | Need Help?? |
C behaves differently since it places values on the stack. Um. Actually, C doesn't place anything on the stack. It loads the values into registers. This is the MS compiler:
The interesting thing about that is that for the post decrement, it loads the value of a into two registers (edx & ecx), then loads it a third time in to eax, where it decrements it and then writes it back. Only then does it compare hte first two values and branch accordingly. And for the predecrement, it loads one register, decrements it and then saves it back before loading the modified value back into the same register and the comparing it with the stored value and branching accordingly. That's before the optimiser takes a look. After the optimiser, all those shenanigins are optimised away and all that remains is the printfs:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
In Section
Seekers of Perl Wisdom
|
|