100% found this document useful (1 vote)
331 views

MPMC - Module-02 - Programs - NPR

The document contains 13 assembly language programs (ALPs) for the 8086 microprocessor. The ALPs perform operations such as swapping numbers, transferring data, adding/subtracting/multiplying numbers, finding largest/smallest/average/sum/factorial/complement of numbers, and sorting data. The programs demonstrate the use of 8086 instructions to manipulate and process data stored in memory locations.

Uploaded by

Rehan Mohammed
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
100% found this document useful (1 vote)
331 views

MPMC - Module-02 - Programs - NPR

The document contains 13 assembly language programs (ALPs) for the 8086 microprocessor. The ALPs perform operations such as swapping numbers, transferring data, adding/subtracting/multiplying numbers, finding largest/smallest/average/sum/factorial/complement of numbers, and sorting data. The programs demonstrate the use of 8086 instructions to manipulate and process data stored in memory locations.

Uploaded by

Rehan Mohammed
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/ 14

ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

1. Write an ALP to swap a 16-bit number between 21000H and 21100H.

MOV AX,2000H

MOV SI,1000H

MOV DI,1100H

MOV AX,[SI]

MOV BX,[DI]

MOV [SI],BX

MOV [DI],AX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

2. Write an ALP to transfer 10 8-bit numbers from location 21000H to


21100H using string instruction.

MOV AX,2000

MOV SI,1000

MOV DI,1100

MOV CL,10

X1: MOV AL,[SI]

MOV [DI],AL

DEC CL

JNZ X1

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

3. Write an ALP to add two sets of 10 8-bit numbers stored in A4000H and
A4010H, and store the result in A4020H.

MOV AX,A000H

MOV DS,AX

MOV SI,4000H

MOV DI,4010H

MOV BX,4020H

X1: MOV AL,[SI]

ADD AL,[DI]

MOV [BX],AL

INC SI

INC DI

INC BX

DEC CL

JNZ X1

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

4. Write an ALP to add two sets of 25 16-bit numbers stored in 12000H and
12050H. The result must be stored in 12100H. The number of results produced
a carry must be stored in BL register.

CLC

MOV AX,1000H

MOV DS,AX

MOV SI,2000H

MOV DI,2050H

MOV BX,2100H

MOV CL,25

MOV CH,0

X2: MOV AX,[SI]

ADD AX,[DI]

MOV [BX],AX

JNC X1

INC CH

X1: ADD SI,2

ADD DI,2

ADD BX,2

DEC CL

JNZ X2

MOV BL,CH

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

5. Write an ALP to subtract two sets of 25 16-bit numbers stored in 12000H


and 12050H. The result must be stored in 12100H. The number of results
produced a borrow must be stored in BH register.

CLC

MOV AX,1000H

MOV DS,AX

MOV SI,2000H

MOV DI,2050H

MOV BX,2100H

MOV CL,25

MOV CH,0

X2: MOV AX,[SI]

SUB AX,[DI]

MOV [BX],AX

JNC X1

INC CH

X1: ADD SI,2

ADD DI,2

ADD BX,2

DEC CL

JNZ X2

MOV BH,CH

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

6. Write an ALP to count the number of 1’s present in the contents of an


accumulator, and store the result in CH register.

CLC

MOV AX,450AH

MOV CL,16

MOV CH,0

X2: SHL AX,1

JNC X1

INC CH

X1: DEC CL

JNZ X2

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

7. Write an ALP to find the largest of 25 16-bit numbers stored from


location 72000H, and store the largest number in 72100H.

MOV AX,7000H

MOV DS,AX

MOV SI,2000H

MOV CL,25

MOV AX,[SI]

X2: ADD SI,2

CMP AX,[SI]

JAE X1

MOV AX,[SI]

X1: DEC CL

JNZ X2

MOV [2100H],AX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

8. Write an ALP to multiply two sets of 10 bytes stored in D2000H and


D3000H, and store the result in D4000H.

MOV AX,D000H

MOV DS,AX

MOV SI,2000H

MOV DI,3000H

MOV BX,4000H

MOV CL,10

X1: MOV AL,[SI]

MOV DL,[DI]

MUL DL

MOV [BX],AX

INC SI

INC DI

ADD BX,2

DEC CL

JNZ X1

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

9. Write an ALP to find the factorial of a number and store the result in BX
register.

MOV AL,1

MOV CL,5

X1: MUL CL

DEC CL

JNZ X1

MOV BX,AX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

10. Write an ALP to find the sum of 20 16-bit numbers stored in 66000H,
and store the result in 67000H.

MOV AX,6000H

MOV DS,AX

MOV CL,20

MOV SI,6000H

MOV AX,[SI]

X1: ADD SI,2

ADD AX,[SI]

DEC CL

JNZ X1

MOV [7000H],AX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

11. Write an ALP to find the average of 20 16-bit numbers stored in 64000H,
and store the result in 65000H.

MOV AX,6000H

MOV DS,AX

MOV CL,20

MOV SI,4000H

MOV AX,[SI]

X1: ADD SI,2

ADD AX,[SI]

DEC CL

JNZ X1

MOV CX,20

DIV CX

MOV [7000H],AX

MOV [7002H],DX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

12. Write an ALP to find the complement of the contents of AX register. The
1’s complement must be stored in BX register and 2’s complement in DX
register.

MOV AX,FE01H

NEG AX

MOV DX,AX

DEC AX

MOV BX,AX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

13. Write an ALP to sort a set of 5 8-bit numbers stored from BA000H and
store the sorted result in BA100H.

MOV AX,B000H

MOV DS,AX

MOV CL,04

X3: MOV CH,CL

MOV SI,A000H

X2: MOV AL,[SI]

INC SI

CMP AL,[SI]

JLE X1

MOV AH,[SI]

MOV [SI],AL

DEC SI

MOV [SI],AH

INC SI

X1: DEC CH

JNZ X2

DEC CL

JNZ X3

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE


ECE3111 – MICROPROCESSORS AND MICROCONTROLLERS – 8086 PROGRAMS

14. Write an ALP to divide a 16-bit number by an 8-bit number.

MOV AX,FE07H

MOV BX,02H

DIV BX

HLT

Dr.Noel Prashant Ratchagar-Asst.Prof-ECE | PRESIDENCY UNIVERSITY BANGALORE

You might also like