Mix (C++ and Assembly) Program to Find Largest Number from Given Numbers

#include<iostream.h>
#include<conio.h>
void main()
{
	int a[5],x,y,res;
	int i,j;
	y=0;

	cout<<"\n Enter 5 Numbers:";
	for(i=0;i<5;i++)
	{
		cin>>a[i];
	}

	_asm{
		mov bx,y
	}

	//Finding largest
	for(i=0;i<5;i++)
	{
		x=a[i];
		_asm{
			mov ax,x
			mov bx,y
			cmp ax,bx
			jl nxt
			mov bx,ax
			mov y,bx
		}
		nxt:
	}

	_asm{
		mov res,bx;
	}

	cout<<"\n Largest Element:"<<res;
	getch();
}

/* OUTPUT

 Enter 5 Numbers:10
12
8
24
16

 Largest Element:24

*/

Leave a Reply

Your email address will not be published. Required fields are marked *