0% found this document useful (0 votes)
21 views9 pages

Exp 6

This document describes two problems: 1) arranging numbers in ascending order and 2) performing matrix addition for 2x2 matrices. For the first problem, it shows the process of sorting 5 numbers over 4 passes using comparisons and swaps. For the second problem, it outlines using registers like BX, SI, DI to load matrix data from memory and adding elements by looping through the matrices. It provides sample data and memory locations to complete and test the assembly language programs for both problems.

Uploaded by

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

Exp 6

This document describes two problems: 1) arranging numbers in ascending order and 2) performing matrix addition for 2x2 matrices. For the first problem, it shows the process of sorting 5 numbers over 4 passes using comparisons and swaps. For the second problem, it outlines using registers like BX, SI, DI to load matrix data from memory and adding elements by looping through the matrices. It provides sample data and memory locations to complete and test the assembly language programs for both problems.

Uploaded by

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

Experiment 6: Arranging numbers

in ascending order and finding


matrix addition for two numbers
BITS Pilani Department of EEE
Hyderabad Campus
ALPs to be completed

Problem 1: Arrange numbers in ascending order.

Problem 2: Find matrix addition (2 × 2) for two numbers.

Title| Presenter 2 BITS Pilani, Hyderabad Campus


6.1 Arrange numbers in ascending order
Assume the numbers and memory locations are given by

Data A2H 23H 66H 12H 7DH


Address. 5001 5002 5003 5004 5005

Number of passes required: N-1

A2h 23h 66h 12h 7Dh


23h A2h 66h 12h 7Dh
Pass1 23h 66h A2h 12h 7Dh
23h 66h 12h A2h 7Dh
23h 66h 12h 7Dh A2h

(1 number sorted)

Title| Presenter 3 BITS Pilani, Hyderabad Campus


6.1 Arrange numbers in ascending order

23H 66H 12H 7DH A2H


Pass 2
23H 12H 66H 7DH A2H (2 numbers sorted)

23H 12H 66H 7DH A2H


Pass 3 12H 23H 66H 7DH A2H
(3 numbers sorted)

12H 23H 66H 7DH A2H


Pass 4
12H 23H 66H 7DH A2H (All numbers sorted)

Title| Presenter 4 BITS Pilani, Hyderabad Campus


6.1 Arrange numbers in ascending order
MOV SI,XXXXH Assume SI = 5000H
MOV CL,[SI]
DEC CL Load the following numbers in the exact order:
LOOP3:MOV SI,XXXXH A2, 23, 66, 12, 7D
MOV CH,[SI]
Load the number in the RAM prior to execution
DEC CH
of your code.
INC SI
LOOP2:MOV AL,[SI]
INC SI
CMP AL,[SI]
JC LOOP1
XCHG AL,[SI]
XCHG [SI-1],AL
LOOP1:DEC CH
JNZ LOOP2
DEC CL
JNZ LOOP3
INT 03H

Title| Presenter 5 BITS Pilani, Hyderabad Campus


6.1 Review Questions

1. What should be the content of the memory location


0000:5000?

2. Repeat the problem using the data in the following order:


22H,33H,55H,44H,66H,11H,AAH,77H,99H,88H

3. Arrange numbers in Descending order using the data in


the following order:
99H,12H,56H,45H,36H

Title| Presenter 6 BITS Pilani, Hyderabad Campus


6.2 Matrix addition (2 × 2) for two numbers

 Matrix to be stored in the form of array in the memory location.


 Storing matrix data to be taken care by BX, SI and DI registers.
 Arithmetic operation to be done element wise.
 Loop instruction to be used to repeat the operations
 CX register to store the number of data in a matrix.

2. To be loaded by SI register

+ =
[ 99 34
𝐴 9 90 ]
Matrix 1 Matrix 2 Matrix 3

1. To be loaded by BX register 3. To be loaded by DI register

Title| Presenter 7 BITS Pilani, Hyderabad Campus


6.2 Matrix addition (2 × 2) for two numbers

MOV BX,0000H
Assume: BX = 4000H; BP = 5000H;
MOV BP,0000H
SI=0001H and DI = 7000H.
MOV SI, 0000H
MOV DI,0000H Changes are to be made to
complete the ALP.
MOV CX,0004H

MAT:MOV AX,[BX+SI]
ADD AX,[BP+SI]
MOV [DI],AX
INC SI
INC DI
LOOP MAT
INT 03H

Title| Presenter 8 BITS Pilani, Hyderabad Campus


6.2 Review Questions

1. What should be the value of CX represent in the given


code?

2. Change the previous code to solve the following.


+

Title| Presenter 9 BITS Pilani, Hyderabad Campus

You might also like