Important programs of 8086

1. Write an ALP to find factorial of number for 8086.

MOV AX, 05H MOV CX, AX
Back: DEC CX
MUL CX
LOOP back
; results stored in AX
; to store the result at D000H MOV [D000], AX
HLT

2. Write a program to display string ‘Bachelor of Computer Science and Information Technology’ for 8086.

Title display the string
.model small
.stack 100h
.data
String1 db ‘Bachelor of Computer Science and Information Technology’, $
.code Main proc
MOV AX, @data MOV DS, AX MOV AH, 09H
MOV DX, offset String1 INT 21H
MOV AH, 4CH INT 21H
Main endp End Main

3. Write a program to reverse the given string for 8086.

Title reverse the given string Dosseg
.model small
.stack 100h
.data
String1 db ‘assembly language program’, $
Length dw $-String1-1
.codeMain proc
MOV AX, @data MOV DS, AX
MOV SI, offset String1 MOV CX, Length ADD SI, CX
Back: MOV DL, [SI]
MOV AH, 02H INT 21H
DEC SI
LOOP Back MOV AH, 4CH INT 21H
Main endp End Main

4. Write a program to multiply 2 numbers (16-bit data) for 8086.

Title multiply two numbers
org 100h
.model small
.stack 100h
.data
Multiplier dw 1234h
Multiplicant dw 3456
Product dw ?
.code MULT proc
mov ax,@data
mov ds,ax
mov ax, Multiplicant
mul Multiplier
mov Product, ax
mov Product + 2, dx
mov ah,4ch
int 21h
endp
ret

5. Sum of series of 10 numbers and store result in memory location total.

Title Sum of series
.model small
.org 100h
.data
List db 12,34,56,78,98,01,13,78,18,36
Total dw ?
.code Main proc
MOV AX, @data MOV DS, AX MOV AX, 0000H
MOV CX, 0AH ; counter MOV BL, 00H ; to count carry MOV SI, offset List
Back: ADD AL, [SI]
JC Label Back1: INC SI
LOOP Back MOV Total, AX
MOV Total+2, BL MOV AH, 4CH INT 21H
Label: INC BL
JMP Back1 Main endp End Main

6. Write a program to find Largest No. in a block of data. Length of block is 0A. Store the maximum in location result.

.model small
.data
List db 01h,12h,03h,04h,01h,02h
Sum db ?
.code
main arraysum proc
mov ax,@data ;Initialize Data segment
mov ds,ax
lea si,List ;Load si with the offset address of n1
mov ax,0000h ;Clear accumulator
mov cx,06h ;Load cx with count
mov dx,0000h ;Clear dx
clc ;clear carry
up:add ax,[si] ;Add the first element with accumulator
inc si ;Increment si twice
dec cx ;Decrement the count
jnz up ;If cx?0, repeat the loop
jnc down ;else if carry =0, jump to label down
inc dx ;if carry=1, increment dx
down:mov Sum,al ;Store the result in memory pointed to ;by si
mov Sum+1,dl ;Store carry in next memory location
mov ah,4ch ;Terminate the program
int 21h
endp
end
ret

7. Find number of times letter ‘e’ exist in the string ‘exercise’, Store the count at memory ans.

Title string operation Dosseg
.model small
.stack 100h
.data
String db ‘exercise’, $ Ans db ?
Length db $-String
.code Main proc
MOV AX, @data MOV DS, AX MOV AL,00H
MOV SI, offset String MOV CX, Length
Back: MOV BH, [SI]
CMP BH, ‘e’
JNZ Label INC AL
Label: INC SI
LOOP Back MOV Ans, AL MOV AH, 4CH INT 21H
Main endp End Main
end main

0 Comments