.

1. .

2 , . 2- . EAX, EBX, ECX

IDEAL

p586

MODEL FLAT

extrn ExitProcess:proc

DATASEG

X DD 150

Y DD 120

Z DD ?

CODESEG

begin:

mov eax, [X]

mov ebx, [Y]

mov ecx, offset Z

call gcd

call ExitProcess

;

proc gcd

push edx

; if (x<y) swap(x, y);

cmp eax, ebx

jge short m1

xchg eax, ebx

; if (y==0) return x

m1:

test ebx, ebx

je short break

; while(1)

for:

xor edx, edx

div ebx

test edx, edx

je short break

mov eax, ebx

mov ebx, edx

jmp for

break:

mov [ecx], ebx

pop edx

ret

endp gcd

end begin

- . - .

2. . EBX,

EAX.

;

; .

; EBX, - EAX.

ideal

P486

MODEL flat

extrn ExitProcess:proc

DATASEG

str1 db ' ', 0

str2 db ' ', 0

n dd ?, ?

CODESEG

begin:

lea ebx, [str1]

lea eax, [n]

call strlen

lea ebx, [str2]

lea eax, [n+4]

call strlen

call ExitProcess

proc strlen

push ecx edx

xor ecx, ecx

for:

mov dl, [ebx] ; while (str[i])ax++;

and dl, dl

je short lend;

inc ecx

inc ebx

jmp for

lend:

mov [eax], ecx

pop edx ecx

ret

endp strlen

end begin

:

1. 1, 2, 4 :

2. .

.