Category Archives: Snippets

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

8086 Assembly Program for Multiplication of Two 8 bit Numbers

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

data segment
a db 09h
b db 02h
c dw ?
data ends

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

8086 Assembly Program for Division of Two 8 bit Numbers

In this blog post, we will explore an 8086 assembly language program designed to divide two 8-bit numbers. This operation is fundamental in arithmetic computations where division is required, such as financial calculations or embedded system applications.

The following assembly program performs the division:

data segment
a db 28h
b db 02h
c dw ?
data ends

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