Skip to main content

Mix (C++ and Assembly) Program to Sort Numbers in Ascending Order

This post demonstrates how to sort an array of integers using inline assembly in C++. Here, we perform sorting in ascending order by comparing and swapping adjacent elements using embedded assembly within a C++ program. #include<iostream.h> #include<conio.h> void main() { int a[5], x, y; int i, j; cout << "\n Enter 5 Numbers:"; for(i = 0; i < 5; i++) { cin >> a[i]; } //Sorting for(i = 0; i < 4; i++) { for(j = 0; j < 4; j++) { x = a[j]; y = a[j + 1]; _asm { mov ax, x mov bx, y cmp ax, bx jl nxt mov cx, ax mov ax, bx mov bx, cx mov x, ax mov y, bx } nxt: a[j] = x; a[j + 1] = y; } } cout << "\n Sorted Array:"; for(i = 0; i < 5; i++) cout << a[i] << " "; getch(); }

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(); }

8086 Assembly Program to Sort Numbers in Descending Order

In this blog post, we will explore an 8086 assembly language program designed to sort a list of numbers in descending order. Sorting is a fundamental operation in computer science, and understanding how to implement it at the assembly level provides valuable insights into low-level programming and processor operations. The following assembly program sorts an array of numbers in descending order using the bubble sort algorithm:

8086 Assembly Program to Sort Numbers in Ascending Order

In this blog post, we will explore an 8086 assembly language program designed to sort a list of numbers in ascending order. Sorting is a fundamental operation in computer science, and understanding how to implement it at the assembly level provides valuable insights into low-level programming and processor operations.​ The following assembly program sorts an array of numbers in ascending order using the bubble sort algorithm:

8086 Assembly Program to Convert Binary Number into BCD Format

In this blog post, we will explore an 8086 assembly language program designed to convert a binary number into its Binary-Coded Decimal (BCD) format. This conversion is essential in applications where binary numbers need to be represented in a decimal-like format, such as digital displays or interfaces that require human-readable numbers. The following assembly program performs the conversion: