尝试使用 GCC 编译 x86 程序集,但出现有关缺少括号和 "junk after expression" 的错误

Trying to compile x86 assembly with GCC but getting errors about missing parenthesis and "junk after expression"

完全公开以下代码是作业,但我写了代码我只需要帮助弄清楚为什么我在尝试编译它时会遇到几个错误(我的教授从未谈论过 GCC 错误)。

我写了一个函数 returns 大小为 10 的数组中两个最大成员的总和。我标记了第 70 行和第 74 行:

function1:
    pushl   %ebp
    pushl   %ebx
    movl    , %ebx #ebx will be counter
    movl    %esp, %ebp #first will be %edx and second will be %eax
    movl    8(%ebp), %edx #first = arr[0]
    movl    (%edx,1,4), %eax #second = arr[1] **LINE 70**
    cmpl    %eax, %edx #if(arr[0] > arr[1]) don't jump
    jle .L6
.L7:
    movl    (8(%ebp),%ebx,4), %ecx #%ecx = next value to compare **LINE 74**
    cmpl    %ecx, %edx #if first > next don't jump
    jle .L8
    cmpl    %ecx, %eax #if second > next don't jump
    jle .L9
    cmpl    , %ebx #check if counter = 9
    je  .L10
    addl    , %ebx #counter++ 
    jmp .L7
.L6:
    movl %edx, %ecx #move arr[0] into %ecx
    movl %eax, %edx #first = arr[1]
    movl %ecx, %eax #second = arr[0]
    jmp .L7
.L8:
    movl %edx, %eax #move previous first into second
    movl %ecx, %edx #move new first into first
    addl , %ebx   #counter++
    jmp .L7
.L9:
    movl %ecx, %eax #move new second into second
    addl , %ebx   #counter++
    jmp .L7
.L10:
    addl %edx, %eax
    popl    %ebx
    popl    %ebp
    ret

我收到以下错误消息:

assign3.s:70: Error: expecting `)' after scale factor in `(%edx,1,4)'
assign3.s:74: Error: missing ')'
assign3.s:74: Error: missing ')'
assign3.s:74: Error: junk `(%ebp),%ebx,4))' after expression

感谢您的帮助,让我知道以后如何改进我的问题

我不得不完全重写我的代码,但多亏了@fuz,我才能够找到合适的解决方案。我的问题在于语法以及对寄存器和指针的理解。这是正确的代码:

function1:
    #FIRST %edx
    #SECOND %eax
    #THIRD  %ebx
    #LOCATION OF ARRAY %esi
    #COUNTER %edi
    pushl   %ebp
    pushl   %ebx
    pushl   %esi
    pushl   %edi
    movl    %esp, %ebp
    movl    , %edi
    movl    %eax, %esi
    movl    (%esi), %edx
    movl    (%esi, %edi, 4), %eax
    addl    , %edi
    cmpl    %eax, %edx
    jle     .L6
.L7:
    movl    (%esi, %edi, 4), %ebx
    cmpl    %ebx, %edx
    jle     .L8
    cmpl    %ebx, %eax
    jle     .L9
.L11:
    addl    , %edi
    cmpl    , %edi
    jne     .L7
    jmp     .L10
.L6: #Switch FIRST and SECOND
    movl %edx, %ebx
    movl %eax, %edx
    movl %ebx, %eax
.L8: #THIRD is bigger than FIRST
    movl %edx, %eax
    movl %ebx, %edx
    jmp .L11
.L9: #THIRD is bigger than SECOND
    movl %ebx, %eax
    jmp .L11
.L10: #Add and return
    addl %edx, %eax
    popl    %edi
    popl    %esi
    popl    %ebx
    popl    %ebp
    ret