calling assembly function from c

I see the following problems with the code:

  • calling convention mandates you must preserve the value of edi
  • cmp %edi,1024 is using 1024 as address and will probably fault. You want cmp $1024,%edi for comparing with an immediate number
  • you are reloading eax and ecx from the arguments each iteration so the calculation you perform has no effect
  • you don’t seem to put any sensible return value into eax (it will return the value of from that was passed in)

The first two points apply even if “what assembly code is doing is not important”.

Leave a Comment