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

            mov result.y, 0

            mov ecx, A

            mov edx, [ecx]

            mov edi, [edx]

            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 y, 0

            jmp y_cmp

y_add:      mov eax, y

            add eax, 1

            mov y, eax

y_cmp:      mov eax, size_y

            cmp y, eax

            jge y_end

            mov eax, y

            mov esi, [edx+eax*4]

            cmp esi, edi

            jge y_add

            mov eax, x

            mov result.x, eax

            mov eax, y

            mov result.y, eax

            mov edi, esi

            jmp y_add

y_end:

            jmp x_add

x_end:                 

      }

      return result;

}

int avg_x(int **A, int x, int size_y)

{

      int result;

      int y;

      __asm

      {

            mov result, 0

            mov ecx, A

            mov eax, x

            mov edx, [ecx+eax*4]

            mov y, 0

            jmp y_cmp

y_add:      mov eax, y

            add eax, 1

            mov y, eax

y_cmp:      mov eax, size_y

            cmp y, eax

            jge y_end

            mov eax, y

            mov esi, [edx+eax*4]

            mov eax, result

            add eax, esi

            mov result, eax

            jmp y_add

y_end:

            mov eax, result

            cdq

            mov ecx, size_y

            idiv ecx;

            mov result, eax

      }

      return result;

}

int avg_y(int **A, int y, int size_x)

{

      int result;

      int x;