Assembly Definition Errors

偶尔善良 提交于 2019-12-11 15:46:31

问题


I am trying to mess around with my assembly function to get it to work but have ran into a couple of errors that are difficult to get by. One is A2005 which states symbol redefinition :_Average. The other one is A1010 which states unmatched block nesting :_Average Any help is appreciated.

.cpp code

#include<iostream>

using namespace std; 

extern "C" long Average(long, long[]);

int main()

{ 
long Array1[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; 
long Array2[11] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; 
cout << "Average of Array1 is " << Average(10, Array1) << endl;
cout << "Average of Array2 is " << Average(11, Array2) << endl; 
}

long Average(long, long[])
{
    return 0;
}

.asm file

.386
.model flat

public _Average

.data

.code


_Average    proc
            push    ebp;
            mov     edx, 10;
            mov     ebx, [ebp+12]
            xor     ecx, ecx;
            xor     eax, eax;
        Loop1:
            add     eax, [edx + (ecx * 4)];
            inc     ecx;
            cmp     ecx, edx;
            jnz     Loop1;
        Done1:
            mov     ebx, 2;
            idiv            ebx;
            pop     ebp;
            ret
_Average    endp

_Average    proc
            push    ebp;
            mov     edx, 11;
            mov     ebx, [ebp+12];
            xor     ecx, ecx;
            xor     eax, eax;
        Loop2:
            add     eax, [edx + (ecx * 4)];
            inc     ecx;
            cmp     ecx, edx;
            jnz     Loop2;
        Done2:  
            mov     ebx, 2;
            idiv    ebx;
            pop     ebp;
            ret
_Average    endp


            end

来源:https://stackoverflow.com/questions/49412315/assembly-language-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!