Performing Block Transfer using Assembly Language
In this blog post, we’ll explore how to perform a block transfer using an 8086 assembly language program. The following code snippet demonstrates this process:
In this blog post, we’ll explore how to perform a block transfer using an 8086 assembly language program. The following code snippet demonstrates this process:
This C++ program determines whether a given number is even or odd using 8086-style inline assembly. It utilizes the div instruction to divide the number by 2 and then checks the remainder stored in the dx register. #include<iostream.h> #include<conio.h> void main() { clrscr(); int a, res; cout << "\n Enter a number"; cin >> a; asm mov ax, a // Move input number into AX asm mov bx, 02h // Move divisor 2 into BX asm div bx // Divide AX by BX, quotient in AX, remainder in DX asm mov res, dx // Store remainder in res if(res == 0) { cout << "\n Even"; } else { cout << "\n Odd"; } getch(); }
This program demonstrates how to use inline 8086 assembly in C++ to determine whether a given number is positive or negative. It's a great way to understand how conditional branching works at the assembly level. #include<iostream.h> #include<conio.h> void main() { clrscr(); int a; cout << "\n Enter a number:"; cin >> a; asm mov ax, 0000h // Clear AX asm mov ax, a // Move user input into AX asm cmp ax, 0000h // Compare AX with 0 asm jl less // Jump to 'less' if AX < 0 asm jge greater // Jump to 'greater' if AX >= 0 less: cout << "\n Number is negative"; asm jmp end greater: cout << "\n Number is positive"; end: getch(); }
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.
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.
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(); }
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.
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(); }
DOS interrupt 21h function 09h is the easiest way to print a string in 8086 assembly: point DX at your string, set AH to 09h, call INT 21h, and you’re done. No loop, no character counter, no BX pointer arithmetic. The tradeoff is a minor convention: the string must end with a $ character so DOS knows where to stop. Compare this with the function 02h character loop approach — 09h is cleaner for fixed strings; 02h gives you more control for dynamic output.
INT 10h is the BIOS video interrupt — completely separate from the DOS INT 21h family. Where INT 21h talks to the operating system, INT 10h talks directly to the video BIOS to control the screen: cursor shape, cursor position, character output, screen modes. This short program demonstrates two of those functions: setting the cursor shape and moving it to a specific screen position.