You are on page 1of 2

#include <iostream>

using namespace std;

int main()
{
int a[8] = { 1, 3, 5, 6, 7, 11, 12, 13}, b[4] = { 2, 8, 9, 10 }, na = 8, nb =
4, c[12];

_asm
{
mov esi, 0 // i = 0
mov edi, 0 // j = 0

lea eax, a
lea ebx, b
lea ecx, c

startwhile:
cmp esi, na // i < na
jae endwhile

cmp edi, nb // j < nb


jae endwhile

mov edx, [ebx]

cmp edx, [eax]


ja adaugaj

mov edx, [ebx]


mov[ecx], edx
add ebx, 4
add ecx, 4
inc edi
jmp startwhile

adaugaj:
mov edx, [eax]
mov[ecx], edx
add eax, 4
add ecx, 4
inc esi
jmp startwhile

endwhile:
startfor1:
cmp esi, na
jae startfor2

mov edx, [eax]


mov [ecx], edx
inc esi
add eax, 4
add ecx, 4
jmp startfor1

startfor2:
cmp edi, nb
jae endall

mov edx, [ebx]


mov [ecx], edx
inc edi
add ebx, 4
add ecx, 4
jmp startfor2

endall:
}
for (int i = 0; i < na + nb; i++)
cout << c[i] << " ";
cin >> na;
}

You might also like