. , .

1. .

nom=-1;

i=0; j=n-1;

while (i<=j){

k=(i+i)/2;

if (x[k]==r){

nom = k;

break;

}

if (x[k]<r)i=k+1; else j=k-1;

}

;nom=-1;

mov eax, -1

;i=0; j=n-1;

mov ebx, 0

mov ecx, [n]

dec ecx

;while (i<=j){

cmp ebx, ecx

jg short m1

; k=(i+i)/2;

mm9:

mov edx, ebx

add edx, ecx

shr edx, 1

; if (x[k]==r){

mov esi, [x+edx*4]

cmp esi, [r]

jne mm6

;nom = k;

mov [nom], edx

;break;

jmp short mm7

;}

;if (x[k]<r)i=k+1; else j=k-1;

mm6:

cmp esi, [r]

jge short mm8

mov ebx, edx

inc ebx

jmp short mm9

mm8:

mov ecx, edx

dec ecx

jmp short mm9

;}

2. ,

for (i=0; str1[i]; i++){

ch = str1[i];

n = nom[i];

str2[n] = ch;

}

str2[i] = 0;

str1 db abcdef, 0

nom dd 5, 1, 0, 2, 4, 3

str2 db (nom - str1) dup (?)

...

;for (i=0; str1[i]; i++){

mov eax, 0

;ch = str1[i];

m2:

mov bl, [str1+eax]

test bl, bl

je short m1

;n = nom[i];

mov ecx, [nom+eax]

;n = nom[i];

mov [str2+ecx], bl

inc eax

jmp m2

m1: