Digital Logic and Microprocessor Lab Assessment 3 ALP 18MIS0079 Sriram.G

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Digital Logic and Microprocessor

Lab assessment 3
ALP
18MIS0079
Sriram.G

1) Write an ALP for adding two 16 bit numbers 0122H, 0127H stored in
registers B and C respectively.

Code:-
MOV BX,0122H
MOV AX,0127H
ADD AX,BX
HLT

o/p:
2) Write an ALP for adding two 8 bit numbers 02H, 1BH stored in registers B and C.
CODE:-
MOV AL,02H
MOV BL,1BH
ADD AL,BL
HLT

O/P:
3) Write an ALP for subtracting two 8 bit numbers stored in registers
CODE:-
MOV AL,07H
MOV BL,04H
SUB AL,BL
HLT
4) Write an ALP for storing the 16 bit data in memory address 1000 and 1001. Then
perform addition of these two numbers and store the result in the memory address
1003.

CODE:

MOV SI,1000H
MOV AX,[SI]
INC SI
INC SI
ADD AX,[SI]
HLT
5) Write an ALP for performing multiplication and division of 2 16 bit numbers.

CODE( DIV)
MOV AX,0004H
MOV BX,0002H
DIV BX
HLT

CODE(MUL)

MOV AX,0004H
MOV BX,0002H
MUL BX
HLT

O/P:
DIV
6) Write an ALP for transferring a block of ten 16 bit data from memory address starting
at 1000 to a memory location 3000.

CODE:

MOV SI,1000H
MOV DI,3000H
MOV CL,0AH
L:MOV AX,[SI]
MOV [DI],AX
INC SI
INC SI
INC DI
INC DI
DEC CL
JNZ L
HLT

O/P:
7) Write an ALP to display 13 numbers of the fibonacci series in a
memory location.

Code:
MOV SI,1000H
MOV CX,000DH
MOV [SI],00H
DEC CX
INC SI
MOV [SI],01H
DEC CX
L:MOV AL,[SI-1]
ADD AL,[SI]
JNE L
HLT

8) Write an ALP to find the largest number in a list of 10 numbers stored in a


Memory location starting from 2000H.

Code:
MOV SI,1000H
MOV CL,[SI]
MOV CH,00
INC SI
MOV AL,[SI]
DEC CL
INC SI
L1: CMP AL,[SI]
JNC SKIP
MOV AL,[SI]
SKIP: INC SI
LOOP L1
MOV [2000H],AL
HLT

9) Write an ALP to find the smallest number in a list of 10 numbers stored in a


memory location starting from 3000H.

Code:
MOV SI, 500
MOV DI, 600
MOV CL, [SI]
MOV CH, 00
INC SI
MOV AL, [SI]
DEC CX
INC SI
MOV BL, [SI]
CMP AL, BL
JC 0417
MOV AL, BL
LOOP 040E
MOV [DI], AL
HLT

10) Write an ALP to sort a list of 10 numbers stored in a memory location in


ascending order.

Code:
MOV SI, 500
MOV CL, [SI]
DEC CL
L1:MOV SI,500
MOV CH,[SI]
DEC CH
INC SI
L2:MOV AL,[SI]
L:INC SI
CMP AL,[SI]
JC L
XCHG AL,[SI]
DEC SI
XCHG AL,[SI]
INC SI
DEC CH
JNZ L2
DEC CL
JNZ L1
HLT
11) Write an ALP to sort a list of 10 numbers stored in a memory location in
descending order.

Code:
MOV SI, 500
MOV CL, [SI]
DEC CL
L1:MOV SI,500
MOV CH,[SI]
DEC CH
INC SI
L2:MOV AL,[SI]
L:INC SI
CMP AL,[SI]
JNC L
XCHG AL,[SI]
DEC SI
XCHG AL,[SI]
INC SI
DEC CH
JNZ L2
DEC CL
JNZ L1
HLT

You might also like