第一个汇编程序错误"对mov的引用太多"

mat*_*cks 3 assembly bit-manipulation

在下面的汇编代码我想使用逐班等,以实现倍增的方法,但我一遍又一遍地让两个错误,以及对"暧昧操作数大小"'MOV’太多的内存引用""CMP /和/ MOV/SHL/SHR'".有任何想法吗?

多谢你们.根据要求,相关错误如下.

    .intel_syntax
    .data

    .globl x
x:  .long 0

    .globl y
y:  .long 0
    .text

    .globl multiply
multiply:
    push    ebp #These two statements are necessary
    mov ebp,esp

    mov eax,0
    mov ebx,x
    mov edx,y

LOOP:
    cmp ebx,0
    je  DONE

    mov ecx,ebx
    and ecx,1
    cmp ecx,1
    jne LOOPC   #jump to continued loop if low_bit(x) not 1

    add eax,edx

LOOPC:
    shr ebx,1
    shl edx,1
    jmp LOOP

DONE:
    pop ebp #Necessary statement
    ret     #return
Run Code Online (Sandbox Code Playgroud)

错误消息:

multiply.s: Assembler messages:
multiply.s:0: Warning: end of file in comment; newline inserted
multiply.s:15: Error: too many memory references for `mov'
multiply.s:17: Error: ambiguous operand size for `mov'
multiply.s:18: Error: too many memory references for `mov'
multiply.s:19: Error: too many memory references for `mov'
multiply.s:22: Error: ambiguous operand size for `cmp'
multiply.s:25: Error: too many memory references for `mov'
multiply.s:26: Error: ambiguous operand size for `and'
multiply.s:27: Error: ambiguous operand size for `cmp'
multiply.s:30: Error: too many memory references for `add'
multiply.s:33: Error: ambiguous operand size for `shr'
multiply.s:34: Error: ambiguous operand size for `shl'
Run Code Online (Sandbox Code Playgroud)

Mys*_*ial 7

%在所有注册名称前面缺少:

所以它应该是:

mov %eax,0
mov %ebx,x
mov %edx,y
Run Code Online (Sandbox Code Playgroud)

实际上,它将它们解析为内存位置的变量.(无%,他们会是相同的xy其中存储器的引用.)

编辑:

啊......看起来ughoavgfhw已经在评论中指出了这一点.