0

I've looked at all the suggested threads on how to solve this, and i cant find one that matches my mistake.

When i compile i get "too many memory references for 'mov'", even if i take out all of them...?

__asm__(
    "mov    0x8(%ebp),  %edx;"
    "mov    0x8(%edx),  %edx;"
    "cmp        $0x0,       %edx;"
    "je     notFound;"

    "sub        $0x10,      %esp;"
    "movl   0xc(%ebp),  (%esp);"
    "movl   $0x24,      0x8(%esp);"


    "mainloop: "
    "movl   %edx,       0x4(%esp);"
    "call _memcmp;"
    "cmp        $0xffffffff,    %eax;"
    "je     leftBranch;"

    "cmp        $0x1,       %eax;"
    "je     rightBranch;"
    "jne        found;"


    "leftBranch: "
    "mov    0xc(%edx),  %edx;"
    "cmp        $0x0,       %edx;"
    "je     notFound;"
    "jne        mainloop;"

    "rightBranch: "
    "mov    0x10(%edx), %edx;"
    "cmp        $0x0,       %edx;"
    "je     notFound;"
    "jne        mainloop;"

    "notFound: "
    "mov    $0x0,       %eax;"
    "add        $0x10,      %esp;"  
    "leave;"
    "ret;"

    "found: "
    "add        $0x10,      %esp;"
    "leave;"
    "ret;"
);
AndrewGrant
  • 786
  • 7
  • 17

1 Answers1

8

The problem is likely this line:

"movl   0xc(%ebp),  (%esp);"

You can't reference two memory locations in a single mov instruction.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285