Tag Archives: 8086

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

Interrupting BIOS with 8086 Assembly Program

Interacting with BIOS interrupts in 8086 assembly language is a crucial technique for handling low-level hardware operations. This blog post explores an 8086 assembly language program that invokes BIOS interrupts to manipulate the screen cursor position and handle user input.

code segment
assume cs:code
start:
mov sp, 7000h
mov ah, 01
mov ch, 00
mov cl, 14
int 10h
mov ah, 02
mov bh, 00
mov dh, 23
mov dl, 10
int 10h
mov ax, 4c00h
int 21h
int 3
code ends
end start
Continue reading Interrupting BIOS with 8086 Assembly Program

Mix Program in Assembly and C++ to Find Factorial of Number

This C++ program calculates the factorial of a number between 0 and 8 using inline 8086 assembly instructions. The multiplication is handled within an assembly loop, showcasing a basic yet insightful use of mul, dec, and jnz instructions.

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

void main() {
    clrscr();
    short a;
    unsigned int c;

    cout << "\n Enter Number between 0 to 8:";
    cin >> a;

    asm mov ax, 0000h
    asm mov al, 01h     // Initialize AX to 1
    asm mov cx, 0000h
    asm mov cx, a       // Set CX loop counter to input value

bac:
    asm mul cx          // Multiply AX by CX
    asm dec cx          // Decrement CX
    asm jnz bac         // Loop until CX reaches zero

    asm mov c, ax       // Move result from AX to variable c

    cout << "\n Factorial of " << a << " is " << c;
    getch();
}
Continue reading Mix Program in Assembly and C++ to Find Factorial of Number

Implementing JUMP, PUSH, POP, IN & OUT in Assembly Program on 8086

Manipulating registers and memory efficiently using instructions like JUMP, PUSH, POP, IN, and OUT is essential in assembly language programming. This program demonstrates these operations in 8086 assembly, utilizing stack operations and port I/O.

data segment
abc dw 1101H
def dw 0025H
pqr dw 0011H
res dw ?
res1 dw ?
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,abc
mov bx,def
mov cx,pqr
mov dx,0002H
jmp ma
back:
push ax
push bx
push cx
pop cx
pop bx
pop ax
mov ax,abc
inc ax
mov abc,ax
mov bx,def
dec bx
mov def,bx
ma:
add ax,bx
mov res,ax
dec dx
jnz back
in ax,25H
out 30H,ax
mov res1,ax
int 3
code ends
end start
Continue reading Implementing JUMP, PUSH, POP, IN & OUT in Assembly Program on 8086

8086 Assembly Program to Display String ‘hello’

Displaying a string in assembly language is an essential task, often used in debugging or user interaction. This blog post explores an 8086 assembly language program that prints the string ‘hello’ to the console using DOS interrupt 21h.

data segment
msg1 db 'hello'
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov sp,0d000h
mov bx,offset msg1
mov cx,0005h
move:
mov ah,02h
mov dl,[bx]
int 21h
inc bx
dec cx
jnz move
mov ax,4c00h
int 21h
int 3
code ends
end start
Continue reading 8086 Assembly Program to Display String ‘hello’

8086 Assembly Program for Subtraction of Two 8 bit Numbers

Subtraction is a fundamental arithmetic operation in assembly language programming. This blog post explores an 8086 assembly language program that performs the subtraction of two 8-bit numbers using the SUB instruction. The result is stored in a 16-bit destination.

data segment
a db 2Ah
b db 13h
c dw ?
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov al,a
mov bl,b
sub al,bl
mov c,ax
int 3
code ends
end start
Continue reading 8086 Assembly Program for Subtraction of Two 8 bit Numbers