I see the following problems with the code:
- calling convention mandates you must preserve the value of
edi
cmp %edi,1024
is using1024
as address and will probably fault. You wantcmp $1024,%edi
for comparing with an immediate number- you are reloading
eax
andecx
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 offrom
that was passed in)
The first two points apply even if “what assembly code is doing is not important”.