Category Archives: Snippets

Implementation of Distance Vector Routing (DVR) Algorithm in C++

This is an outdated post! Please click here to see latest version of Implementation of Distance Vector Routing (DVR) Algorithm in C++

The Distance Vector Routing (DVR) Algorithm is a fundamental routing algorithm used in computer networks to determine the shortest path between nodes. It is based on the Bellman-Ford algorithm and operates by sharing routing tables among directly connected nodes to update their knowledge about the shortest paths.

In this blog post, we will discuss the implementation of the DVR algorithm in C++, go through the code step by step, and explain its output.

Continue reading Implementation of Distance Vector Routing (DVR) Algorithm in C++

Mix (Assembly and C++) Program to Find Greatest of Two Numbers

This program demonstrates how to compare two integers using 8086 inline assembly in C++. By leveraging assembly instructions like sub and conditional jump js, the program determines which number is greater.

#include<iostream.h>
#include<conio.h>

void main() {
    clrscr();
    short a;
    short b;

    cout << "\n Enter First Number:";
    cin >> a;

    cout << "\n Enter Second Number:";
    cin >> b;

    asm mov ax, 0000h        // Clear AX
    asm mov bx, 0000h        // Clear BX
    asm mov ax, a            // Load first number into AX
    asm mov bx, b            // Load second number into BX
    asm sub ax, bx           // Subtract BX from AX
    asm js true              // Jump if result is negative (AX < BX)

    cout << "\n " << a << " is greater than " << b;
    asm jmp end              // Skip 'true' block

true:
    cout << "\n " << b << " is greater than " << a;

end:
    getch();
}
Continue reading Mix (Assembly and C++) Program to Find Greatest of Two Numbers

8086 Assembly Program to Print ‘hello’ using 09H

Displaying a string using DOS interrupt 21H function 09H is a straightforward way to print messages to the screen in 8086 assembly language. This blog post explores an 8086 assembly program that prints the string ‘hello’ to the console.

data segment
msg1 db 'hello$'
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov sp,0d00h
mov ah,09h
int 21h
mov ax,4c00h
int 21h
int 3
code ends
end start
Continue reading 8086 Assembly Program to Print ‘hello’ using 09H