Mix (C++ and Assembly) Program to Find Smallest Number from Given Numbers
This C++ program demonstrates how to find the smallest number from an array using inline 8086 assembly language instructions. The logic involves comparing each array element and storing the smallest found so far using cmp and conditional jump instructions. #include<iostream.h> #include<conio.h> void main() { short a[5], x, y, res; short i, j; y = 999; // Initialize with a large number cout << "\n Enter 5 Numbers:"; for (i = 0; i < 5; i++) { cin >> a[i]; } asm { mov bx, y } // Finding smallest for (i = 0; i < 5; i++) { x = a[i]; asm { mov ax, x mov bx, y cmp ax, bx jnb nxt // Jump if not below (i.e., current is not smaller) mov bx, ax mov y, bx } nxt: } asm { mov res, bx; } cout << "\n Smallest Element:" << res; getch(); }