Skip to main content

8086 Assembly Program to Subtract Two 16-bit Numbers

Assembly language offers a hands-on approach to understanding how computers perform basic arithmetic at a low level. Subtraction in 8086 assembly follows the same register-first pattern as addition — but with one extra detail worth getting right: operand order. SUB AX, BX computes AX − BX, not BX − AX. Getting that backwards produces a wrong result with no assembler warning. This post walks through a working implementation in three environments: MASM/TASM, emu8086, and NASM.

8086 Assembly Program to Divide Two 16-bit Numbers

Division in 8086 assembly is the most instruction-constrained of the four arithmetic operations. Unlike addition or subtraction, the DIV instruction does not let you choose which registers hold the dividend and quotient — the hardware fixes those roles permanently. Understanding why the registers are wired this way is the key to writing correct division programs and avoiding the dreaded divide overflow exception. This post walks through a working implementation in three assembler environments: MASM/TASM, emu8086, and NASM.

8086 Assembly Program for Addition of Two 8-bit Numbers

Adding two 8-bit numbers is the entry point into 8086 assembly arithmetic — simpler than 16-bit addition in operand size, but identical in structure. You will see the same segment setup, the same register-first constraint, and the same result-storage pattern. This post covers a working implementation in three environments: MASM/TASM (classic DOS toolchain), emu8086 (the Windows emulator used in most college labs), and NASM (modern open-source assembler). All versions are tested and produce verifiable output.

8086 Assembly Program to Add Two 16-bit Numbers

Adding two 16-bit numbers is one of the first real programs every assembly language student writes — and for good reason. It touches every foundational concept at once: segment registers, data declarations, arithmetic instructions, result storage, and program termination. This post walks through a working implementation in three assembler environments: MASM/TASM (the classic DOS toolchain), emu8086 (the popular Windows emulator used in college labs), and NASM (the modern open-source assembler). All examples are tested and produce verifiable output.

Inheritance Example in Java

Learn Java inheritance with a clear, hands-on example. See how a Box class extends Rectangle using the extends keyword and super() constructor chaining, with a full code walkthrough, sample output, and FAQs.

Polymorphism Example in Java

Learn Java polymorphism with clear examples of both method overloading (compile-time) and method overriding (runtime). Includes step-by-step walkthroughs, sample output, and FAQs covering dynamic dispatch, @Override, and static method hiding.

Implementation of K-Means Algorithm in C++

The K-Means algorithm is one of the most widely used unsupervised machine learning algorithms. It partitions a dataset into K clusters such that each data point belongs to the cluster whose mean (centroid) it is closest to. Unlike KNN, K-Means does not use labelled data — it discovers natural groupings entirely on its own through iteration. In this post we walk through a well-commented C++ implementation of K-Means that clusters 10 integer values into 2 groups. We cover the algorithm, explain each line of code, trace through the iterative process, and analyse the output in detail. What is the K-Means Algorithm? K-Means works by alternating between two steps until the cluster centres stop changing: Assignment step: Assign each data point to the cluster whose mean it is closest to. Update step: Recalculate the mean of each cluster based on its current members. The algorithm converges when the means no longer change between iterations — meaning the clusters have stabilised. In this implementation: K = 2 (two clusters) Distance metric: absolute difference (1D Manhattan distance) Dataset: 10 integers entered by the user Initial means: provided by the user

Implementation of Nearest Neighbour Algorithm in C++

The Nearest Neighbour Algorithm is one of the foundational concepts in Data Warehousing and Mining (DWM). It is used to analyse a graph or dataset and classify its nodes into two groups based on a given threshold distance. A node is placed in the close neighbourhood (K1) if it is within the threshold, and in the far neighbourhood (K2) if it exceeds it. In this post we walk through a well-commented C++ implementation that reads an adjacency matrix of 5 vertices, accepts a starting vertex and a distance threshold, and partitions all connected vertices into the two neighbourhood sets K1 and K2. What is the Nearest Neighbour Algorithm? Given a graph represented as an adjacency matrix where adjMatrix[i][j] stores the distance (edge weight) between vertex i and vertex j, the algorithm works as follows for a chosen source vertex s: Read the distance from s to every other vertex from the adjacency matrix row corresponding to s. For each vertex v: if the distance is greater than 0 (there is an edge) and less than or equal to the threshold, add v to K1. If the distance exceeds the threshold, add v to K2. Also print all direct connections along with their distances. A value of 0 on the diagonal represents the distance from a vertex to itself (no self-loops). A large value like 99 is typically used to represent no direct connection (infinity).

Implementation of K-Nearest Neighbors (KNN) Algorithm in C++

The K-Nearest Neighbors (KNN) algorithm is one of the simplest and most intuitive supervised machine learning algorithms. It classifies a new data point based on the majority class among its K closest neighbors in the training dataset. There is no explicit training phase — the algorithm memorizes the entire dataset and makes decisions at prediction time, which is why it is also called a lazy learner. In this post, we will walk through a C++ implementation of the KNN algorithm that classifies a person's height as short, medium, or tall using a small training set of 12 records. We cover the algorithm step by step and explain the output in detail. What is the KNN Algorithm? KNN works on a very simple principle: similar things exist in close proximity. Given an unlabeled data point, the algorithm: Calculates the distance between the new point and every point in the training dataset. Sorts all training points by distance (ascending). Picks the K nearest points (the threshold). Assigns the class that appears most frequently among those K neighbors. This program uses a single feature — height — and the distance metric is the simple absolute difference (Manhattan distance in 1D). Gender is stored in the dataset but is not used as a feature for classification in this implementation.

Implementation of Apriori Algorithm in C++

Apriori is a cornerstone algorithm in association rule mining, widely used in market basket analysis (e.g., identifying which items are frequently bought together in stores). The algorithm’s power lies in its ability to uncover hidden patterns in large transactional datasets. What Does the Apriori Algorithm Do? The Apriori algorithm is used for discovering frequent itemsets—groups of items that appear together in a dataset with frequency above a specified threshold (called minimum support). These itemsets form the basis for generating association rules—for example, “if someone buys bread and butter, there’s a good chance they’ll also buy jam.”