Dominic Kay wrote:
 > Its an outrage - 43 years old and no assembler skills! For lack of
 > better introductory material I am learning it by compiling up very
 > simple bits of C and using the Frank Hoffman's x86 Crash book and this
 > article
 > <http://developers.sun.com/solaris/articles/x86_assembly_lang.html> to
 > work out whats going on. I don't want to be able to write it; just read
 > it and keep track of the passed parameters etc. Below is the code,
 > followed by the assembler and comments on what I think is going on. My
 > problem is with asm lines 8-12 where some pointless dance seems to be
 > occuring.
 >
 > Do you have any idea what is happening here? Am I missing something
 > really obvious? Also I'm a bit queasy about line 3 of the assembler
 > output. I can remove lines 3,8-12 and it compiles and runs just fine
 > without the extra instructions but if thats systems performance and
 > tuning, I'm off to join a rock'n'roll band.

   The assembly you have is a very pedantic translation of the C code.
   Line 3 is reserving space for the local variable "l", and the
   instructions on line 8-12 are first storing it to the local variable
   (corresponding to the assingment) and then loading it from the local
   variable (corresponding to the return).

   The jmp and second store/load could be the compiler implementing a
   common function postlude (i.e. to handle the case where the C code
   returns from multiple places).

   How are you compiling your program?  Try compiling it optimized.
   The result will probably be closer to what you'd expect.

   Dave

_______________________________________________
perf-discuss mailing list
[email protected]

Reply via email to