0% found this document useful (0 votes)
11 views

MPCA LAB4 Programs

The document outlines the Microprocessor and Computer Architecture Laboratory assignments for the 4th semester, focusing on writing assembly language programs (ALP) for various tasks such as convolution, summation in matrices, string length calculation, and string copying. Each task includes specific algorithms and instructions for implementation using ARM architecture. The document is intended for students in the Computer Science and Engineering department, providing detailed guidelines for completing the laboratory exercises.

Uploaded by

deeptic82
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

MPCA LAB4 Programs

The document outlines the Microprocessor and Computer Architecture Laboratory assignments for the 4th semester, focusing on writing assembly language programs (ALP) for various tasks such as convolution, summation in matrices, string length calculation, and string copying. Each task includes specific algorithms and instructions for implementation using ARM architecture. The document is intended for students in the Computer Science and Engineering department, providing detailed guidelines for completing the laboratory exercises.

Uploaded by

deeptic82
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

MICROPROCESSOR AND

COMPUTER ARCHITECTURE
LABORATORY
4TH Semester(UE22CS251B)

LAB4
Saturday, March 15, 2025

Prof Deepti C
Computer Science and Engineering
Microprocessor & Computer Architecture Laboratory

LAB4 1. a)Write an ALP to perform Convolution using MUL instruction


(Addition of multiplication of respective numbers of loc A and loc B)
b) Write an ALP to perform Convolution using MLA instruction (Addition
of multiplication of respective numbers of loc A and loc B).
2. Write an ALP to implement Sum[i]+=a[i][j]
3. Write an ALP to find the length of a given string
4.Write an ALP to copy string from one location to another

ASSIGNMENT QUESTIONS
1.Write an ALP to find whether a given character is present in a string. If
present, find how many times the given character is present in a string.
2. Write a program in ARM7TDMI-ISA to generate a diagonal matrix.
;Note: do not read the matrix elements.
Microprocessor & Computer
Architecture (μpCA)

SWI #
Microprocessor & Computer
Architecture (μpCA)
SWI #
Microprocessor & Computer Architecture Laboratory

PROGRAM 1a,1b
LAB 4 a)Write an ALP to perform Convolution using MUL instruction
(Addition of multiplication of respective numbers of loc A and loc
B) such that the value ∑(a[i]*b[i]) is computed.
Write an ALP to perform Convolution using MLA instruction
(Addition of multiplication of respective numbers of loc A and loc
B).

a: .word 10, 20, 30, 40, 50


Algorithm b: .word 10, 20, 30, 40, 50
1. Declare the arrays A,B in .data segment
2. Let R0 contain address of A R5 (10*10)+(20*20)+(30*30)
3. Let R1 contain address of B +(40*40)+(50*50)
4. Let R2 contain number of elements in the array. =3000=00000bb8
5. Initialise sum=0 in r5.
6. Copy the element of A into a register R3
7. Increment r0 to point to the next location of A
8. Copy the element of B into a register R4
9. Increment r1 to point to the next location of B
10. Multiply the elements of A and B.
11. Save the multiplication result in R6.
12. Calculate sum=sum+multiplication result.
13. Decrement the count of elements(R2) One Screenshot-Choose your own value for array
14. Repeat steps 6 to 13 till R2 is not equal to zero elements.Show the Memory Window,Code window and
15. End program Register Window in the screenshot.
Microprocessor & Computer Architecture Laboratory

PROGRAM 2
WEEK
Write an ALP to implement Sum[i]+=a[i][j]
4
Algorithm Algorithm for Subroutine get_addr
1. Declare the array A in .data segment 10.Pop the values of i and j from stack back to registers R4 and R5
2. Let R0 contain address of A 11.Multiply no of columns in r3 with i value(in R4) add with j value( in R5)
3. Let R1=0=initial value of sum Store the result in R7
4. Let R2 contain max number of rows in the matrix,assume=3. 12.Multiply this result in R7 wih 4 to get address of next element.
5. Let R3 contain max number of columns in the matrix,assume=3. Save multiplication result in R6
6. Let R4 contain initial value of i=0 13.Save the values of i ,j and address (in R6) to stack
7. Let R5 contain initial value of j=0 14.Return to subroutine for_i for_j(Step 15)

Algorithm for Subroutine for_i and for_j


8.Save the current values of i and j on stack(Use R13 register)
9.Branch to subroutine that calculates address of current element of matrix
get_addr(step 10)
15.Retrieve the values of i,j and address from stack to registers r4,r5 and r6
16.Calculate address of a[i][j] (Add R0 with R6 store result in R6)
17.Copy the value from address a[i][j] to register R9
18.Add this value in R9 to the value of sum in R1
19.Increment j value in R5 by 1
20.Compare this with value max no of columns in R3
21.Repeat steps 8 to 20 until j becomes equal to max no of columns
22.Reset j value back to 0 to move to second row,first column of the matrix
23.Increment i value (in R4 ) by 1 Before a:.word 1,2,3,4,5,6,7,8,9
execution
24.Compare i value with max no of rows value in R2
25.If i has reached max no of rows,go to end of program After Addition 45 2D
Else Repeat steps 8 to 24 Execution result
26.End of Program
One Screenshot-Choose your own value for
array elements.Show the Memory Window,Code
window and Register Window in the
screenshot.
Microprocessor & Computer Architecture Laboratory
LAB4 PROGRAM 3

Write an ALP to find the length of a given string


Algorithm Before Execution
1.Initialise R0 to contain the address of the string
2.Let R1=0=Initial length of the string .data
3.Copy each character from the string into str: .asciz “Hello”
register R2(Use LDRB instruction)
4.Check if the character in R2 is zero
5.If valid character is found, increment R1. After Execution
6.Else end Program
7.Increment R0 to point to next character in the R1=00000005
string
8.Repeat step 3 to 5 until end of string
9.R1 contains final length of string
10.End Program
Microprocessor & Computer Architecture Laboratory
LAB 4 PROGRAM 4

Write an ALP to copy string from one location to another


Algorithm Before Execution
1.Initialise R0 to contain the address of
the string srcstr .data
2.Initialise R1 to contain the address of srcstr: .asciz "PES UNIVERSITY"
the string dststr
3.Copy character from srcstr to R2 dststr: .asciz "aaaaaaaaaaaaaa"
4.Copy character from R2 to dststr After Execution
5.Check if character in R2 is valid
character dststr: "PES UNIVERSITY"
6.Repeat step 3 to 5 until end of srcstr
8.Display srcstr and dststr using
SWI0x02
9.End Program
THANK YOU

Deepti C

Department of Computer Science and


Engineering
[email protected]

You might also like