Mail Archives: djgpp/1996/06/06/12:50:54
In article <4p0mul$6ha AT sky DOT inp DOT nsk DOT su>,
Vyacheslav O. Myskin <myskin AT inp DOT nsk DOT su> wrote:
>while(!interrupt_occured) counter++;
>The count was started and stopped by two consecutive timer interrupts.
>Here is the assembler source:
>
> movl _counter,%eax ;
> incl %eax ; Why not 'incl _counter' ?
> movl %eax,_counter ;
In intel 486 and pentium, the simple instructions like the above are
able to execute quickly, perhaps in one cycle each, without stalling
the instruction pipeline. "incl _counter" is a compilcated instruction,
it's got to do three things (load a virtual register from memory, increment
it, and store the result.) while these things are going on no other
instructions can be decoded and the pipeline stalls. "incl _counter"
probably takes at least 4 cycles to execute.
> movl _counter,%eax ; And what is it for???
This looks to me like you compiled "while(!interrupt_occured) ++counter;"
instead of the above. I'm guessing that because counter is declared
volatile, the return value of ++counter cannot be optimized away. In
gcc values are returned in the %eax register. I'm guessing that you
really didn't need to declare counter as volatile. If you don't, I'd
guess this instruction will go away.
> movl _interrupt_occured,%eax
> testl %eax,%eax
> je ...
Eric
--
Eric Korpela | An object at rest can never be
korpela AT ssl DOT berkeley DOT edu | stopped.
<a href="http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpela/w">
Click here for more info.</a>
- Raw text -