Tag Archives: 8086

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.

Continue reading 8086 Assembly Program for Addition of Two 8-bit Numbers

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.

Continue reading 8086 Assembly Program to Add Two 16-bit Numbers

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

This post demonstrates how to sort an array of integers using inline assembly in C++. We use basic comparison and swap logic in assembly embedded 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
                jge 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();
}
Continue reading Mix (C++ and Assembly) Program to Sort Numbers in Descending Order