8086 Lab Programs
8086 Lab Programs
8086 Lab Programs
.data
num1 db 50h
num2 dw 1234h
.code
mov ax,@data
mov ds,ax ;DATA SEGMENT INITIALIZATION
mov al,num1
mov ah,al
mov bh,ah
mov bl,al ;MOVES BYTE LENGTH OF DATA FROM REG.AL TO REG.BL
mov cx,num2
mov dx,cx
mov si,ax
mov di,si ;MOVES WORD LENGHT OF DATA FROM REG.CX TO REG.DX
ret
org 00h
.code
mov al,10h
mov ah,10
mov cl,50h
mov ch,50 ;MOVES IMMEDIATE VALUE TO 8 BIT REGISTER
mov bx,1234h
mov dx,1234 ;MOVES IMMEDIATE VALUE TO 16 BIT REGISTER
mov si,4000h
mov di,2000h
ret
.data
num1 db 05h
num2 db 06h
num3 dw 1234h
num4 dw 0002h
sum db ?
sum2 dw ?
.code
mov ax,@data
mov ds,ax ;INITIALIZES DATA SEGMENT
mov al,num1
mov bl,num2
add al,bl ;ADD THE 2 BYTES
mov sum,al ;STORES THE RESULT IN MEMORY
mov cx,num3
add cx,num4 ;ADD THE 2 WORDS
mov sum2,cx ;STORES THE RESULT IN MEMORY
ret
Org 00h
.data
num1 dw 1234h
num2 dw 0ffffh
res dw 5 dup(0)
.code
mov ax,@data
mov ds,ax ;INITIALIZATION OF DATA SEGMENT
mov ax,num1
mov dx,num2
mul dx ;MULTIPLIES 2 16-BIT NUMBERS
mov res,ax
ret
Org 100h
.data
dvd dd 12345678h
dvr dw 0ffffh
quot dw ?
remd dw ?
.code
mov ax,@data
mov ds,ax ;INITIALIZATION OF DATA SEGMENT
mov cx,dvr
div cx
mov quot,ax
mov remd,dx
ret
PROGRAM: 6
TO WRITE A PROGRAM TO PERFORM SUBTRACTION X-Y WHERE X AND Y ARE 48 BIT NUMBERS.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV AX,2000H
MOV DS,AX
MOV SI,000AH
MOV AX,[BX]
SUB [SI],AX
MOV AX,[BX+2]
SBB [SI+2],AX
MOV AX,[BX+4]
SBB [SI+4],AX
MOV AL,0
ADC AL,AL
MOV [SI+6],AL
HLT
PROGRAM: 2
TO WRITE A PROGRAM TO MULTIPLY 4 AND 5 IN ASCII AND STORE THE RESULT.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV AH,0
MOV AL,'4'
MOV BL,'5'
SUB AL, 30H
SUB BL, 30H
MUL BL
AAM
ADD AX,3030H
HLT
PROGRAM: 3
TO FIND THE LARGEST NUMBER FROM A BLOCK OF 15 BYTES
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV SI,0000H
MOV AX,2000H
MOV DS,AX
MOV CL,0FH
MOV AL,[SI]
L1: CMP AL,[SI+1]
JNB J1
MOV AL,[SI+1]
J1:
INC SI
LOOP L1
HLT
PROGRAM: 4
TO WRITE A PROGRAM TO ARRANGE A DATA BLOCK IN ASCENDING ORDER.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV AX,0050H
MOV DS,AX
MOV BL,0FH
L2: MOV SI,0000H
MOV CX,000FH
L1:INC SI
MOV AL,[SI]
CMP AL,[SI+1]
JB J1
JMP J2
J1: XCHG [SI+1],AL
MOV [SI],AL
J2: LOOP L1
DEC BL
JNZ L2
HLT
PROGRAM: 5
To write a program to arrange a data block in descending order.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV AX,0050H
MOV DS,AX
L2: MOV SI,0000H
MOV CX,000FH
L1:INC SI
MOV AL,[SI]
CMP AL,[SI+1]
JB J1
JMP J2
J1: XCHG [SI+1],AL
MOV [SI],AL
J2: LOOP L1
LOOP L2
HLT
MOV [SI],AL
J2: LOOP L1
LOOP L2
HLT
PROGRAM: 6
To write a program to compare two data blocks
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV AX,2000H
MOV DS,AX
MOV AX,3000H
MOV ES,AX
MOV BX,0000H
MOV SI,0000H
MOV DI,0000H
MOV CL,07H
L1: CMPSB
JZ J1
INC BX
J1:
LOOP L1
HLT
PROGRAM: 7
To write a program to scan for a specific word in the block and to store the
location of
the word at a suitable memory location.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
; COM FILE IS LOADED AT CS:0100H
ORG 100H
MOV AX,3000H
MOV DS,AX
MOV AX,2000H
MOV ES,AX
MOV DI,0000H
MOV CL,05H
MOV AX,1234H
REPNZ SCASW
SUB DI,0002H
MOV [0000H],DI
HLT
PROGRAM 8:
To write an assembly language program to solve following arithmetic equation:
3AX+5DX+BP.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
org 100h
MOV BX,AX
SAL AX,1
ADD BX,AX
ADD BX,DX
ADD CL,02
SAL DX,CL
ADD BX,DX
SAL BP,1
ADD BX,BP
MOV CX,BX
HLT
PROGRAM 9:
To write a program to add series of 20 bytes.
REQUIREMENT: EMU 8086 SOFTWARE, PC.
PROGRAM
MOV AX, 2000
MOV DS,AX
MOV SI,0000
MOV CX,20
XOR AX,AX
XOR BX,BX
LI: MOV BL,[SI]
ADD AX,BX
INC SI
DCR CX
JNZ L1
MOV [DI],AX
HLT
PROGRAM 10:
AIM: To write an 8086 Assembly Language Program to Convert 8 � bit Binary Number
to BCD Number.
Apparatus Required: MASM Assembler
Program:
ORG 0100h