Sei sulla pagina 1di 14

MPI LAB Programs List

1. Write a program using two 8-bit numbers stored in memory location, perform the following
operation and store the result in another memory location.
a) Addition b) Subtraction c) Multiplication d) Division
2. Write a program for addition N 8-bit numbers.
3. a) Write a program to find the minimum number form the given array.
b) Write a program to find the maximum number form the given array.
4. a) Write a program to find out number of even and odd numbers from a given series of N 8-
bit numbers.
b) Write a program to find out number of negative and positive numbers from a given series
of N 8-bit signed numbers.
c) ) Write a program to find out number of zeros and ones in a given byte.
5. Write a program for
a) addition of two 3x3 matrices.
b) subtraction of two 3x3 matrices.
6. Write a program for product of two 3x3 matrices.
7. a) Write a program to arrange the given series of bytes in ascending order.
b) Write a program to arrange the given series of bytes in descending order.
8. Write a program to find out the square root of a two digit number. Assume the number is a
perfect square.
9. Write a program to perform 32x16 bit multiplication.
10. Write a program to subtract 16 bit number from a 32 bit number.
11. Write a program to find the squares of BCD numbers from 0 to 9 and store them sequentially
from 2000H offset onwards in the current data segment. Use a subroutine to for calculation
of the square of a number.
12. Write a program to find the factorial of a number using procedures.
13. Write a program to move a string of data words from offset 2000H to offset 3000H the length
of the string is 0FH.
14. Write a program to negate 10 bytes of data in memory location.
15. Write a program to scan a byte and to find its address in memory location.
16. Write a program to find the number of times the scanned byte is repeated.
17. Write a program to find the reverse of the string.
18. Write a program to find the length of the string.
19. Write a program to append the string.
20. Write a program to add N 16-bit numbers.
21. a) Write a program to convert the packed BCD to un packed BCD.
22. a) Write a program to convert the packed BCD to un packed BCD.
b) Write a program to convert the un packed BCD to packed BCD.
23. a) Write a program to convert hexadecimal to BCD.
b) Write a program to convert gray code to BCD.
c) Write a program to convert BCD to ASCII
24. a) Write a program to convert hexadecimal to ASCII.
b) Write a program to convert ASCII to hexadecimal.
c) Write a program to convert binary to gray code.
Interfacing Programs:
25. Write a program to interface an LED to 8086 using 8255 PPI.
26. Write a program to interface an seven segment display to 8086 using 8255 PPI and display
the numbers 0 to F.
27. Interface stepper motor to the 8086 microprocessor system and write an 8086 assembly
language program to control the stepper motor.
28. Write a program to control the traffic light system using 8086 and 8255 PPI.
29. Write a program to interface ADC with 8086 using 8255 PPI.
30. Write a program to interface the DAC with 8086 using 8255 PPI.


MPI LAB Programs
1. Write a program using two 8-bit numbers stored in memory location, perform the following
operation and store the result in another memory location.
a) Addition b) Subtraction c) Multiplication d) Division
2. Write a program for addition N 8-bit numbers.
3. a) Write a program to find the minimum number form the given array.
b) Write a program to find the maximum number form the given array.
4. a) Write a program to find out number of even and odd numbers from a given series of N 8-
bit numbers.
b) Write a program to find out number of negative and positive numbers from a given series
of N 8-bit signed numbers.
c) ) Write a program to find out number of zeros and ones in a given byte.
5. Write a program for
a) addition of two 3x3 matrices.
b) subtraction of two 3x3 matrices.
6. Write a program for product of two 3x3 matrices.
; PRODUCT OF TWO 3X3 MATRICES
MOV CH,03H ; ROW COL
MOV BX,4000H ; RESULT MATRIX
MOV SI,2000H ; MATRIX 1

NEXTROW: MOV DI,3000H ; MATRIX 2
MOV CL,03H ; ROWS

NEXTCOL: MOV DL,03H ; COLS
MOV BP, 0000H

NEXT_ELE: MOV AX,0000H
MOV AL,[SI]
MOV DH,[DI]
MUL DH
ADD BP,AX
INC SI
ADD DI,03H
DEC DL
JNZ NEXT_ELE
SUB DI,08H
SUB SI,03H
MOV [BX],BP
ADD BX,02H
DEC CL
JNZ NEXTCOL
ADD SI,03H
DEC CH
JNZ NEXTROW
INT 21H


7. a) Write a program to arrange the given series of bytes in ascending order.
b) Write a program to arrange the given series of bytes in descending order.
8. Write a program to find out the square root of a two digit number. Assume the number is a
perfect square.
; SQUARE ROOT OF A TWO DIGIT NUMBER
MOV SI,2000H
MOV CL,[SI]
MOV BL,01H
MOV AL,00H

UP:CMP CL,00H
JZ RES
SUB CL,BL
INC AL
ADD BL,02;
JMP UP

RES: INC SI
MOV [SI],AL
INT 21H
9. Write a program to perform 32x16 bit multiplication.
; 32X16 BIT MULTIPLICATION

MOV SI,1000H
MOV AX,2000H
MOV DS,AX
MOV AX,[SI]
MOV BX,[SI+02]
MOV CX,[SI+04]
MUL BX
MOV [SI+06],AX
MOV [SI+08],DX
MOV AX,[SI]
MUL CX
ADD [SI+08],AX
JNC LABEL1
INC DX
LABEL1:MOV [SI+0AH],DX
INT 21H

; INPUT : 16-BIT NUMBER (1111)
; : 1000 -11
; : 1001 -11
; 32 BIT NUMBER (3333 2222)
; : 1002 -22
; : 1003 -22
; : 1004 -33
; : 1005 -33
10. Write a program to subtract 16 bit number from a 32 bit number.
11. Write a program to find the squares of BCD numbers from 0 to 9 and store them sequentially
from 2000H offset onwards in the current data segment. Use a subroutine to for calculation
of the square of a number.
;SQUARES OF BCD NUMBERS FROM 0 TO 9 USING SUB ROUTINE
MOV SI,2000H
MOV CL,0AH ;COUNTER
MOV AL,00H

NEXTNUM: CALL SQUARE
MOV [SI],AH; STORING THE RESULT IN AH INTO MEMORY
INC AL
INC SI

DEC CL
JNZ NEXTNUM
INT 21H

;SQUARE PROCEDURE
SQUARE: MOV BH,AL
MOV CH,AL
XOR AL,AL
AGAIN: ADD AL,BH
DAA
DEC CH
JNZ AGAIN;
MOV AH,AL
MOV AL,BH
RET

12. Write a program to find the factorial of a number using procedures.
;FACTROIAL OF A GIVEN NUMBER USING PROCEDURES

MOV SI, 3000H
MOV AL,[SI]
CALL FACT
INC SI
MOV [SI],AX
INT 21H

; PROCEDURE
FACT: MOV CL,AL
SUB CL,01H
REPEAT1: MUL CL
LOOP REPEAT1
RET
13. Write a program to move a string of data words from offset 2000H to offset 3000H the length
of the string is 0FH.
; MOVING STRING OF DATA BYTES FROM 1000:2000H TO 2000:3000H THE
LENGTH OF THE STRING IS 0FH
MOV SI,2000H
MOV DI,3000H
MOV CX, 0FH
MOV AX,1000H
MOV DS,AX
MOV AX,2000H
MOV ES,AX
CLD
REP MOVSB
INT 21H
; GIVE INPUT DATA IN THE LOCATION 1000:2000 TO 1000:200F
; OUTPUT AT 2000:3000 TO 2000:300F
14. Write a program to negate 10 bytes of data in memory location.
; PROGRAM TO NEGATE 10 BYTES IN THE LOCATION 2000:1000 AND STORE
THEM IN 3000:2000
MOV SI,1000H
MOV AX,2000H
MOV DS,AX
MOV BX,3000H
MOV ES,BX
MOV DI,2000H
MOV CX,000AH

CLD
LABEL1: MOV AL,[SI]
NEG AL
STOSB
INC SI
LOOP LABEL1
INT 21H
; INPUT AT 2000:1000
;OUTPUT AT 3000:2000
15. Write a program to scan a byte and to find its address in memory location.
; program to find whether the given byte is in the string or not. If it is in the stirng, find out
the relative address of the byte from the starting location of the string.
MOV AX,1000H
MOV DS,AX
MOV ES,AX
MOV SI,2000H
MOV DI,3000H
MOV CX,000AH ; LENGTH OF THE STRING
CLD
LODSB

LABEL1: NOP
SCASB
JZ LABEL2
LOOP LABEL1
JMP LABEL3

LABEL2: DEC DI
MOV [SI],DI

LABEL3: INT 21H

; GIVE INPUT STRING IN 1000:3000 TO 1000:3009
; GIVE INPUT BYTE TO COMPARE AT 1000:2000
; RESULT WILL BE AT 1000:2001
16. Write a program to find the number of times the scanned byte is repeated.
; PROGRAM TO FIND THE NUMBER OF TIMES THE SCANNED BYTE IS
REPEATED
MOV SI,1000H
MOV DI,2000H
MOV AX,2000H
MOV BX,3000H
MOV DS,AX
MOV ES,BX
MOV CX,000AH ; LENGTH OF THE STRING
MOV BL,00H ; COUNTER WHICH GIVES HOW MANY TIMES THE NO. IS
REPEATED
CLD
LODSB

LABEL2: SCASB
JNZ LABEL1
INC BL

LABEL1: LOOP LABEL2
MOV [SI],BL
INT 21H

;INPUT : FROM 3000:2000 TO 3000:200A
; NO. TO CHECK AT LOCATION 2000:1000
; OUT AT LOCATION 2000:1001
17. Write a program to find the reverse of the string.
; PROGRAM TO FIND THE REVERSE OF THE STRING
MOV SI,1000H
MOV DI,2000H
MOV AX,2000H
MOV DS,AX
MOV ES,AX
MOV DL,00H
MOV AL,00H
CLD

LABEL2: SCASB
JZ LABEL1
INC DL
JMP LABEL2

LABEL1: SUB DI,02H
MOV CL,DL

LABEL3:
MOV AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP LABEL3
INT 21H

; ASSUME THE STRING TERMINATES WITH 00H
; INPUT AT 2000:2000
; OUTPUT AT 2000:1000

18. Write a program to find the length of the string.
; PROGRAM TO FIND THE LENGTH OF THE STRING
MOV SI,1000H
MOV DI,2000H
MOV AX,2000H
MOV DS,AX
MOV ES,AX
MOV DL,00 ; GIVES THE LENGTH OF THE STRING
MOV AL,00
CLD
LABEL2: SCASB
JZ LABEL1
INC DL
JMP LABEL2
LABEL1: MOV [SI],DL
INT 21H

; ASSUME THE STRING IS TERMINATED WITH 00 BYTE
; INPUT AT 2000:2000
; OUTPUT AT 2000:1000
19. Write a program to append the string.
;PROGRAM TO APPEND A STRING
MOV SI,1000H
MOV DI,2000H
MOV AX,1000H
MOV DS,AX
MOV ES,AX
MOV BL,00H ; COUNTER FOR LENGTH OF THE STRING 1
MOV CL,00H ; COUNTER FOR LENGTH OF THE STRING 2
CLD

LABEL2: LODSB
CMP AL,00H
JZ LABEL1
INC BL
JMP LABEL2

LABEL1: MOV AL,00H

LABEL4: SCASB
JZ LABEL3
INC CL
JMP LABEL4

LABEL3: MOV SI,1000H

MOV DI,3000H

LABEL5: MOVSB
DEC BL
JNZ LABEL5

MOV SI,2000H
LABEL6:
MOVSB
LOOP LABEL6
INT 21H

; ASSUME THE STRING TERMINATES WITH 00H
; INPUT AT 1000:1000 (STRING 1)
; 1000:2000 ( STRING 2)

; OUTPUT APPENDED STRING AT 1000:3000
20. Write a program to add N 16-bit numbers.
21. a) Write a program to convert the packed BCD to un packed BCD.
22. a) Write a program to convert the packed BCD to un packed BCD.
; PACKED BCD TO UNPACKED BCD
MOV SI,2000H
MOV DI,3000H
MOV BX,1000H
MOV DS,BX
MOV AL,[SI]
MOV CL,04H
AND AL,0FH
MOV [DI],AL
MOV AL,[SI]
AND AL,0F0H;
ROR AL,CL
INC DI
MOV [DI],AL
INT 21H

;INPUT AT 1000:2000
;OUTPUT AT 1000:3000
b) Write a program to convert the un packed BCD to packed BCD.
; UNPACKED TO PACKED BCD
MOV SI,2000H
MOV DI,3000H
MOV AX,1000H
MOV DS,AX
MOV AL,[SI]
INC SI
MOV BL,[SI]
MOV CL,04H
ROR BL,CL
ADD AL,BL
MOV [DI],AL
INT 21H

; INPUT AT 1000:2000 AND 1000:2001
; OUTPUT AT 1000:3000

23. a) Write a program to convert hexadecimal to BCD.
b) Write a program to convert gray code to BCD.
c) Write a program to convert BCD to ASCII
; PROGRAM FOR BCD TO ASCII
MOV SI,2000H
MOV AX,1000H
MOV DS,AX
MOV AX,0000H
MOV AL,[SI]
MOV BL,AL
AND AL,0FH
ADD AL,30H
MOV CL,04H
ROR BL,CL
AND BL,0FH
ADD BL,30H
INC SI
MOV [SI],BL
INC SI
MOV [SI],AL
INT 21H

;INPUT AT 1000:2000 -05
; OUTPUT AT 1000:2001-30 AND 1000:2002-35
24. a) Write a program to convert hexadecimal to ASCII.
;HEX TO ASCII
MOV AX,2000H
MOV DS,AX
MOV SI,1000H
MOV AL,[SI]
INC SI
CMP AL,0AH
JC LESS
ADD AL,37H ; FOR ASCII LETTERS
; (ASCII OA TO 0F IS 41 TO 47)
JMP END

LESS: ADD AL,30H; FOR NUMBERS 0-9(ASCII IS 30-39)

END: MOV [SI],AL
INT 21H

;INPUT AT 2000:1000
; OUTPUT AT 2000:1001
b) Write a program to convert ASCII to hexadecimal.
;ASCII TO HEX
MOV AX,2000H
MOV DS,AX
MOV SI,1000H
MOV AL,[SI]
SUB AL,30H
CMP AL,09H
JG CHAR
JMP HEX

CHAR: SUB AL,07H

HEX: INC SI
MOV [SI],AL
INT 21H

;INPUT AT 2000:1000
; OUTPUT AT 2000:1001
c) Write a program to convert binary to gray code.
; BINARY TO GRAY
MOV AX,2000H
MOV SI,2000H
MOV DS,AX
MOV AX,0000H
MOV AL,[SI]
MOV BL,AL
CLC
RCR AL,01H
XOR BL,AL
INC SI
MOV [SI],BL
INT 21H

; INPUT AT 2000:2000
; OUTPUT AT 2000:2001
Interfacing Programs:
25. Write a program to interface an LED to 8086 using 8255 PPI.
26. Write a program to interface an seven segment display to 8086 using 8255 PPI and display
the numbers 0 to F.
27. Interface stepper motor to the 8086 microprocessor system and write an 8086 assembly
language program to control the stepper motor.
28. Write a program to control the traffic light system using 8086 and 8255 PPI.
29. Write a program to interface ADC with 8086 using 8255 PPI.
30. Write a program to interface the DAC with 8086 using 8255 PPI.

Potrebbero piacerti anche