MPMC - Module-02 - Programs - NPR
MPMC - Module-02 - Programs - NPR
MOV AX,2000H
MOV SI,1000H
MOV DI,1100H
MOV AX,[SI]
MOV BX,[DI]
MOV [SI],BX
MOV [DI],AX
HLT
MOV AX,2000
MOV SI,1000
MOV DI,1100
MOV CL,10
MOV [DI],AL
DEC CL
JNZ X1
HLT
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
ADD AL,[DI]
MOV [BX],AL
INC SI
INC DI
INC BX
DEC CL
JNZ X1
HLT
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
ADD AX,[DI]
MOV [BX],AX
JNC X1
INC CH
ADD DI,2
ADD BX,2
DEC CL
JNZ X2
MOV BL,CH
HLT
CLC
MOV AX,1000H
MOV DS,AX
MOV SI,2000H
MOV DI,2050H
MOV BX,2100H
MOV CL,25
MOV CH,0
SUB AX,[DI]
MOV [BX],AX
JNC X1
INC CH
ADD DI,2
ADD BX,2
DEC CL
JNZ X2
MOV BH,CH
HLT
CLC
MOV AX,450AH
MOV CL,16
MOV CH,0
JNC X1
INC CH
X1: DEC CL
JNZ X2
HLT
MOV AX,7000H
MOV DS,AX
MOV SI,2000H
MOV CL,25
MOV AX,[SI]
CMP AX,[SI]
JAE X1
MOV AX,[SI]
X1: DEC CL
JNZ X2
MOV [2100H],AX
HLT
MOV AX,D000H
MOV DS,AX
MOV SI,2000H
MOV DI,3000H
MOV BX,4000H
MOV CL,10
MOV DL,[DI]
MUL DL
MOV [BX],AX
INC SI
INC DI
ADD BX,2
DEC CL
JNZ X1
HLT
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
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]
ADD AX,[SI]
DEC CL
JNZ X1
MOV [7000H],AX
HLT
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]
ADD AX,[SI]
DEC CL
JNZ X1
MOV CX,20
DIV CX
MOV [7000H],AX
MOV [7002H],DX
HLT
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
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
MOV SI,A000H
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
MOV AX,FE07H
MOV BX,02H
DIV BX
HLT