我已经查看了有关如何解决这个问题的所有建议线程,我找不到符合我错误的帖子。
当我编译时,我得到“'mov'的”太多内存参考“,即使我拿出所有内容......?
__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;"
);
答案 0 :(得分:7)
问题可能就在这一行:
"movl 0xc(%ebp), (%esp);"
您无法在单个mov
指令中引用两个内存位置。