This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MS/CW-style inline assembly for GCC


Neil Booth wrote:

Robert Dewar wrote:-


Robert Dewar wrote:


For reference, the code on the x86 should look something like
(in Intel syntax):

   lp:   mov  eax, [ebx]
         adc  eax, [ecx]
         inc  ebx
         inc  ecx
         loop lp

that's the code that was wrong, should be



    lp:   mov  eax, [ebx]
          adc  eax, [ecx]
          lea  ebx, [ebx+4]
          lea  ecx, [ecx+4]
          loop lp


Except that loop decrements ecx and loops if non-zero, so I
think you've still got some work to do 8-)

OK, well I did say look something like :-) Yes indeed we need to use some other register than ecx for the second index register. Might also be nice to store the result :-) Just goes to show that dashing off code in email is a hazzardous occupation. How about

         lp:   lodsw
               adc     eax, [ebx]
               lea     ebx, [ebx+4]
               stosw
               loop    lp

Here source registers are esi,ebx and destination register is edi

Did someone check what GCC generates for the C code?




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]