Mix (C++ and Assembly) Program to Find Square/Cube/Factorial of a Number

This program demonstrates how to calculate the square, cube, or factorial of a number using 8086 inline assembly in C++. It presents a menu-based approach for the user to choose an operation and performs the calculation using the mul instruction in assembly.

Continue reading Mix (C++ and Assembly) Program to Find Square/Cube/Factorial of a Number

Mix (C++ and Assembly) Program to Perform Signed & Unsigned Multiplication and Division

This post walks through a C++ program that demonstrates how to perform basic arithmetic operations like multiplication and division using inline assembly. It allows the user to choose between signed/unsigned multiplication and division in a loop until they decide to exit.

Continue reading Mix (C++ and Assembly) Program to Perform Signed & Unsigned Multiplication and Division

Mix (C++ and Assembly) Program to Subtract Two 8 bit Numbers

While modern high-level languages like C++ abstract away many low-level operations, sometimes it’s useful to get closer to the hardware to understand how things work under the hood. This example demonstrates how to subtract two 8-bit numbers using inline assembly in a simple C++ program.

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

void main() {
    clrscr();

    short int a, b, c;

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

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

    asm mov ax, a      // Move 'a' into AX
    asm mov ah, 00h    // Ensure AH is cleared
    asm mov bx, b      // Move 'b' into BX
    asm mov bh, 00h    // Ensure BH is cleared
    asm sub al, bl     // Subtract BL from AL
    asm mov c, ax      // Store result in 'c'

    cout << "Result:";
    cout << c;

    getch();
}
Continue reading Mix (C++ and Assembly) Program to Subtract Two 8 bit Numbers

8086 Assembly Program to Search an Element in an Array

Array search is where assembly starts feeling like real programming — you need a pointer, a counter, a comparison, and a conditional branch, all working together. This program searches a five-element byte array for a target value and prints either “FOUND” or “NOT FOUND” using a reusable MACRO that wraps the DOS print call.

Continue reading 8086 Assembly Program to Search an Element in an Array

Implementing Socket Programming in Java

Socket programming is the foundation of network communication in Java. A socket is one endpoint of a two-way communication channel between two programs running on a network. Java provides the java.net package with high-level abstractions — ServerSocket for the server side and Socket for the client side — that handle the underlying TCP/IP details so you can focus on reading and writing data streams.

This example implements a simple interactive TCP chat between a server and a client. Both sides can send and receive messages. Either side can type Q or q to close the connection gracefully. The server listens on port 5000; the client connects to localhost:5000.

Continue reading Implementing Socket Programming in Java

Illustrating Working of Bit-Map Protocol with C++ Program

The Bit-Map Protocol is a contention-free MAC (Medium Access Control) layer protocol used to coordinate which stations are allowed to transmit on a shared channel. Before any data frame is sent, each station broadcasts a single bit during its reserved slot in a contention slot period: a 1 signals that the station has a frame ready to send, while a 0 means the station has nothing to transmit. Once every station has announced its status, transmissions occur in station order, eliminating collisions entirely.

This C++ program simulates the Bit-Map Protocol. The user specifies the number of stations and their ready/not-ready status. The program reads each station’s status, then announces which stations are ready to transmit in station-number order.

Continue reading Illustrating Working of Bit-Map Protocol with C++ Program

Implementation of Cyclic Redundancy Check Algorithm in C++

Cyclic Redundancy Check (CRC) is one of the most widely used error-detection techniques in data communications. The sender treats the data frame as a binary number, appends zeros equal to one less than the generator polynomial length, and then divides the extended frame by the generator using XOR (modulo-2) division. The remainder — called the CRC bits — is appended to the original frame before transmission.

At the receiver, the same division is performed on the received frame. If the remainder is zero, the frame arrived without errors; a non-zero remainder indicates corruption. This C++ program demonstrates both the sender-side CRC generation and the receiver-side error check for a user-supplied frame and generator.

Continue reading Implementation of Cyclic Redundancy Check Algorithm in C++