Category Archives: 8086 TASM

8086 Assembly Program to Convert Binary Number into BCD Format

In this blog post, we will explore an 8086 assembly language program designed to convert a binary number into its Binary-Coded Decimal (BCD) format. This conversion is essential in applications where binary numbers need to be represented in a decimal-like format, such as digital displays or interfaces that require human-readable numbers.

The following assembly program performs the conversion:

DATA SEGMENT
NO1 DB "1001000000110110"
D1 DW 4 DUP (?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA SI, NO1
LEA DI, D1
MOV CX, 04H
TOP:
MOV BX, 00H
MOV AX, [SI]
ROR AX, 1
JNC P2
ADD BX, 08H
P2:
INC SI
MOV AX, [SI]
ROR AX, 1
JNC P3
ADD BX, 04H
P3:
INC SI
MOV AX, [SI]
ROR AX, 1
JNC P4
ADD BX, 02H
P4:
INC SI
MOV AX, [SI]
ROR AX, 1
JNC P5
ADD BX, 01H
P5:
MOV [DI], BX
INC DI
INC SI
DEC CX
JNZ TOP
INT 3
CODE ENDS
END START
Continue reading 8086 Assembly Program to Convert Binary Number into BCD Format

8086 Assembly Program to Convert BCD Number into Binary Format

​In this blog post, we’ll explore how to convert a BCD (Binary-Coded Decimal) number into its binary equivalent using an 8086 assembly language program. The following code snippet demonstrates this process:

DATA SEGMENT
NO1 DB "9036"
D2 DB ?
D1 DB 16 DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA SI, NO1
LEA DI, D1
MOV CX, 04H
TOP:
MOV AL, [SI]
MOV DX, 0CH
UP1:
ROL AX,1
DEC DX
JNZ UP1
AND AX, 1111000000000000B
MOV DX, 04H
UP2:
ROL AX, 1
JNC DN
MOV BX, 1
MOV [DI], BX
JMP DN2
DN:
MOV BX, 0
MOV [DI], BX
DN2:
INC DI
DEC DX
JNZ UP2
INC SI
DEC CX
JNZ TOP
INT 3
CODE ENDS
END START
Continue reading 8086 Assembly Program to Convert BCD Number into Binary Format

8086 Assembly Program to Find Reverse of an Array

In this blog post, we’ll explore how to reverse an array using an 8086 assembly language program. We will walk through the logic, the step-by-step execution, and provide a working code snippet to illustrate the process.

Overall Process:

  1. The program initializes registers and sets up pointers to the source (ARR) and destination (REV_ARR) arrays.
  2. It processes each element of the original array, copying it in reverse order to the destination array.
  3. After processing all elements, the program terminates, leaving the reversed array in memory.

8086 Assembly Code:

DATA SEGMENT
STR1 DB 01H,02H,05H,03H,04H
STR2 DB 5 DUP(?)
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA SI, STR1
LEA DI, STR2+4
MOV CX, 05H

BACK: CLD
MOV AL, [SI]
MOV [DI], AL
INC SI
DEC DI
DEC CX
JNZ BACK

INT 3
CODE ENDS
END START
Continue reading 8086 Assembly Program to Find Reverse of an Array

8086 Assembly Program to Check if String is Palindrome or not

A palindrome is a word, phrase, or sequence that reads the same forward and backward. This 8086 assembly program determines whether a given string is a palindrome by reversing the string and comparing it to the original.

The program follows these steps:

  1. Initialize the Data Segment: Load the string to be checked.
  2. Reverse the String: Store the reversed string in another memory location.
  3. Compare the Original and Reversed Strings: Use CMPSB to compare byte-by-byte.
  4. Print the Result: Display whether the string is a palindrome or not.
Continue reading 8086 Assembly Program to Check if String is Palindrome or not

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:

DATA SEGMENT
STRING1 DB 01H,02H,03H,04H,05H
STRING2 DB 4 DUP(0)
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
LEA SI,STRING1
LEA DI,STRING2
MOV CX,05H
CLD
REP MOVSB
INT 3
CODE ENDS
END START
Continue reading Performing Block Transfer using Assembly Language

8086 Assembly Program to Search an Element in an Array

In this blog post, we’ll explore how to search for an element in an array using an 8086 assembly language program. The following code snippet demonstrates this process:

DATA SEGMENT
STRING1 DB 11H,22H,33H,44H,55H
MSG1 DB "FOUND$"
MSG2 DB "NOT FOUND$"
SE DB 33H
DATA ENDS

PRINT MACRO MSG
MOV AH, 09H
LEA DX, MSG
INT 21H
INT 3
ENDM

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AL, SE
LEA SI, STRING1
MOV CX, 04H

UP:
MOV BL,[SI]
CMP AL, BL
JZ FO
INC SI
DEC CX
JNZ UP
PRINT MSG2
JMP END1

FO:
PRINT MSG1

END1:
INT 3
CODE ENDS
END START
Continue reading 8086 Assembly Program to Search an Element in an Array

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