Использование языка ассемблер, страница 4

      __asm

      {

            mov result, 0

            mov ecx, A

            mov x, 0

            jmp x_cmp

x_add:      mov eax, x

            add eax, 1

            mov x, eax

x_cmp:      mov eax, size_x

            cmp x, eax

            jge x_end

            mov eax, x

            mov edx, [ecx+eax*4]

            mov eax, y

            mov esi, [edx+eax*4]

            mov eax, result

            add eax, esi

            mov result, eax

            jmp x_add

x_end:                 

            mov eax, result

            cdq

            mov ecx, size_x

            idiv ecx;

            mov result, eax

      }

      return result;

}

int main()

{

      A = new int *[SIZE_X];

      for (int i = 0; i < SIZE_X; i++)

          A[i] = new int [SIZE_Y];

      srand(time(NULL));

      for (int x = 0; x < SIZE_X; x++)

            for (int y = 0; y < SIZE_Y; y++)

            {

                  A[x][y] = rand()%20;

            }

      cout <<"Array:                                       | Avg:\n    ";

      for (int y = 0; y < SIZE_Y; y++)

      {

            for (int x = 0; x < SIZE_X; x++)

            {

                  cout <<setw(4) <<A[x][y];

            }

            cout <<" |" <<setw(4) <<avg_y(A, y, SIZE_X) <<"\n    ";

      }

      cout <<"-----------------------------------------+\nAvg:";

      for (int x = 0; x < SIZE_X; x++)

      {

            cout <<setw(4) <<avg_x(A, x, SIZE_Y);

      }

      point result;

      result = max(A, SIZE_X, SIZE_Y);

      cout <<"\n\nAmax = A[" << result.x+1 <<"," <<result.y+1 <<"]="<<A[result.x][result.y];

      result = min(A, SIZE_X, SIZE_Y);

      cout <<"\nAmin = A[" << result.x+1 <<"," <<result.y+1 <<"]="<<A[result.x][result.y];