0% found this document useful (0 votes)
90 views6 pages

Microprocessor Quiz: Array Swapping Program

The document contains a quiz for a microprocessor class. It has two questions. Question 1 asks the student to write a program to swap the data between three arrays. Question 2 asks the student to add the first and third arrays and store the results in memory starting at location 0450h. The document provides the code written by the student to answer each question.

Uploaded by

Abuzar Sheikh
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
0% found this document useful (0 votes)
90 views6 pages

Microprocessor Quiz: Array Swapping Program

The document contains a quiz for a microprocessor class. It has two questions. Question 1 asks the student to write a program to swap the data between three arrays. Question 2 asks the student to add the first and third arrays and store the results in memory starting at location 0450h. The document provides the code written by the student to answer each question.

Uploaded by

Abuzar Sheikh
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

University of Engineering and Technology, Taxila

Department of Computer Engineering


Quiz No. 1
Course: Microprocessor Class: [Link]. (19-CP)
Time Allowed: 30 Minutes Max. Marks: 10
Name: Sheikh Abuzar Amjad Roll No: 19-CP-6
Question-1: Show by writing a program to swap the arrays as given.
• Swap array 2 data in array 1
• Swap array 3 data in array 2
• Swap array 1 data in array 3
Array 1= 1,3,5,7,9,11,13,15,17,19
Array 2= 2,4,6,8,10,12,14,16,18,20
Array 3= 1,2,3,4,5,6, 7,8,9,10
CLO [1] 2.5x3 = 7.5 marks

CODE
org 100h

LEA DI,[Array1]

LEA SI,[Array2]

LEA BX,[Array3]

;Swapping Array 2 to 1

MOV AL,[SI]

MOV [DI],AL

MOV AL,[SI+1]

MOV [DI+1],AL

MOV AL,[SI+2]

MOV [DI+2],AL

MOV AL,[SI+3]

MOV DI+3,AL

MOV AL,[SI+4]

MOV DI+4],AL

MOV AL,[SI+5]

MOV DI+5],AL

MOV AL,[SI+6]

MOV DI+6],AL
University of Engineering and Technology, Taxila
Department of Computer Engineering
Quiz No. 1
MOV AL,[SI+7]

MOV DI+7],AL

MOV AL,[SI+8]

MOV DI+8],AL

MOV AL,[SI+9]

MOV DI+9],AL

;Swapping Array 3 to 2

MOV AL,[BX]

MOV [SI],AL

MOV AL,[BX+1]

MOV [SI+1],AL

MOV AL,[BX+2]

MOV [SI+2],AL

MOV AL,[BX+3]

MOV [SI+3],AL

MOV AL,[BX+4]

MOV [SI+4],AL

MOV AL,[BX+5]

MOV [SI+5],AL

MOV AL,[BX+6]

MOV [SI+6],AL

MOV AL,[BX+7]

MOV [SI+7],AL

MOV AL,[BX+8]

MOV [SI+8],AL

MOV AL,[BX+9]

MOV [SI+9],AL

;Swapping Array 1 to 3
University of Engineering and Technology, Taxila
Department of Computer Engineering
Quiz No. 1
MOV AL,[DI]

MOV [BX],AL

MOV AL,[DI+1]

MOV [BX+1],AL

MOV AL,[DI+2]

MOV [BX+2],AL

MOV AL,[DI+3]

MOV [BX+3],AL

MOV AL,[DI+4]

MOV [BX+4],AL

MOV AL,[DI+5]

MOV [BX+5],AL

MOV AL,[DI+6]

MOV [BX+6],AL

MOV AL,[DI+7]

MOV [BX+7],AL

MOV AL,[DI+8]

MOV [BX+8],AL

MOV AL,[DI+9]

MOV [BX+9],AL

Array1 DB 1,3,5,7,9,11,13,15,17,19

Array2 DB 2,4,6,8,10,12,14,16,18,20

Array3 DB 1,2,3,4,5,6,7,8,9,10

ret
University of Engineering and Technology, Taxila
Department of Computer Engineering
Quiz No. 1
OUTPUT:

Question-2:
Proceed by adding array 1 and array 3 and show the result in the array starting from 0450h
location.
CLO [1] 2.5 marks

CODE:
org 100h

LEA BP, ARRAY1

LEA SI, ARRAY3

MOV DI,0450H

MOV CX,10

LOOP1:
University of Engineering and Technology, Taxila
Department of Computer Engineering
Quiz No. 1
MOV AH,[BP]

MOV BH,[SI]

ADD AH,BH

MOV [DI],AH

INC SP

INC SI

INC DI

LOOP LOOP1

Array1 DB 1,3,5,7,9,11,13,15,17,19

Array2 DB 2,4,6,8,10,12,14,16,18,20

Array3 DB 1,2,3,4,5,6,7,8,9,10

Ret
University of Engineering and Technology, Taxila
Department of Computer Engineering
Quiz No. 1
OUTPUT:

You might also like