0% found this document useful (0 votes)
78 views

Microprocessor Practical Codes-1

The documents provide examples of assembly language programs for microprocessors to perform tasks like adding BCD numbers, unpacking packed BCD numbers, moving data between memory blocks, counting bits in a number, searching an array, checking palindromes, calculating factorials, computing Fibonacci series, and finding the average of numbers.

Uploaded by

kambliakshay22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Microprocessor Practical Codes-1

The documents provide examples of assembly language programs for microprocessors to perform tasks like adding BCD numbers, unpacking packed BCD numbers, moving data between memory blocks, counting bits in a number, searching an array, checking palindromes, calculating factorials, computing Fibonacci series, and finding the average of numbers.

Uploaded by

kambliakshay22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Microprocessor : Practical 4

Program to add 16 bit BCD number


.model small
.data
A DB 09H
B DB 02H

.code
MOV AX, @data
MOV DS, AX
MOV AL, A
MOV BL, B
ADD AL, BL
DAA
MOV AH, 4CH
INT 21H
end

Tasm terminal : -
OUTPUT : -
Microprocessor : Practical 5

Program to unpack the packed BCD number


.MODEL SMALL
.DATA
DATA SEGMENT
PACKED_BCD_NO DB 43H

UNPACKED_NO_1 DB ?
UNPACKED_NO_2 DB ?
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA

START:
MOV AX, DATA
MOV DS, AX
MOV AL, PACKED_BCD_NO
AND AL, 0FH
MOV UNPACKED_NO_1, AL
MOV BL, AL
MOV AL, PACKED_BCD_NO
AND AL, 0F0H
ROR AL, 04H
MOV UNPACKED_NO_2, AL
MOV CL, AL
MOV AX, 4CH
INT 21H
CODE ENDS
END START
Tasm terminal : -

OUTPUT : -
Microprocessor : Practical 6

Program to move set of numbers from one memory block to another


.MODEL SMALL
.DATA
ARR DB 1,2,3,4,5,6,7,8,9,12
ARR1 DB 10 DUP(?)
COUNT DW 10
.CODE

START:
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
LEA SI, ARR
LEA DI, ARR1
MOV CX, COUNT
CLD
REP MOVSB
MOV AH, 4CH
INT 21H
END START

Tasm terminal : -
OUTPUT : -

A) Dump values before transfer

B) Dump values after transfer


Microprocessor : Practical 7

Program to count no. of 1’s and 0’s in the given 16 bit number
DATA SEGMENT
NUM DW 5648H
Z DW ?
O DW ?
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AX, NUM
MOV BX, 00H
MOV CX, 10H
MOV DX, 00H

UP:
ROL AX, 1
JC ONE
INC BX
JMP NXT

ONE:
INC DX

NXT:
DEC CX
JNZ UP

MOV Z, BX
MOV O, DX
MOV AX, 4CH
INT 21H
CODE ENDS
END START
Tasm Terminal : -

OUTPUT : -
Microprocessor : Practical 8

Assembly program to search an element in an array


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

Tasm Terminal Output : -

A) Search for input value 33H

B) Search for input value 66H


Microprocessor : Practical 9

Program to check whether a given string is a palindrome or not


.MODEL SMALL
.DATA
ARR DB "sai"
ARR1 DB 10 DUP(?)
COUNT DW 3

MSG1 DB "STRING IS PALLINDROME$"


MSG2 DB "STRING IS NOT PALLINDROME$"
.CODE

START:
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
LEA SI, ARR
LEA DI, ARR1
MOV CX, COUNT
ADD DI, CX
DEC DI
AGN:
CLD
LODSB
STD
STOSB
LOOP AGN
LEA SI, ARR
LEA DI, ARR1
MOV CX, COUNT
CLD
REPE CMPSB
LEA DX, MSG2
JNZ OVER
LEA DX, MSG1

OVER:
MOV AH, 09H
INT 21H
MOV AH, 4CH
INT 21H
END START

Tasm Terminal Output : -

A) For string “sai”

B) For string “mom”


Microprocessor : Practical 10

Write a program to find factorial

DATA SEGMENT
A DB 5
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA, CS:CODE
START:
MOV AX, DATA
MOV DS, AX
MOV AH, 00
MOV AL, A
L1: DEC A
MUL A
MOV CL,A
CMP CL,01
JNZ L1
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Tasm terminal : -
Tasm Terminal Output : -

A) For value 5 factorial is 120

B) For value 4 factorial is 24


Microprocessor : Practical 11

Write a program in assembly language of 8086 to compute fibonacci series


of N terms

.MODEL SMALL
.DATA
COUNT DW 0AH
RES DB 10 DUP(?)
.CODE

MOV AX, @data


MOV DS, AX
MOV CX, COUNT
MOV SI, OFFSET RES
MOV AL, 00H
MOV BL, 01H
MOV [SI], AL
INC SI
MOV [SI], BL
INC SI

UP:
MOV AL, [SI-2]
MOV BL, [SI-1]
ADD AL, BL
MOV [SI], AL
INC SI
LOOP UP
MOV AH, 4CH
INT 21H
END
Tasm terminal : -

OUTPUT : -
A) Dump values before fibonacci series
B) Dump values after fibonacci series
Microprocessor : Practical 12

Write a program to find average of 3 numbers using mixed language


programming

Code :-

Output : -

You might also like