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

Mpca Lab1 Programs

The document outlines the Microprocessor and Computer Architecture Laboratory course for the 4th semester, detailing weekly programs that involve writing assembly language programs (ALPs) for various tasks such as addition, subtraction, checking even or odd numbers, calculating factorials, and finding the GCD of two numbers. Each program includes algorithms and examples demonstrating the use of ARM instruction sets. The course is taught by Prof. Deepti C from the Department of Computer Science and Engineering.

Uploaded by

deeptic82
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)
9 views

Mpca Lab1 Programs

The document outlines the Microprocessor and Computer Architecture Laboratory course for the 4th semester, detailing weekly programs that involve writing assembly language programs (ALPs) for various tasks such as addition, subtraction, checking even or odd numbers, calculating factorials, and finding the GCD of two numbers. Each program includes algorithms and examples demonstrating the use of ARM instruction sets. The course is taught by Prof. Deepti C from the Department of Computer Science and Engineering.

Uploaded by

deeptic82
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/ 7

MICROPROCESSOR AND

COMPUTER ARCHITECTURE
LABORATORY
4TH Semester

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

WEEK PROGRAMS
2 1. Write an ALP to add if the numbers are equal, otherwise subtract
them.
2. Write an ALP using ARM instruction set to check if a number stored in
a register is even or odd.
3. Write a program to find the factorial of a given number.
4. Write a program to find GCD of two numbers.
Microprocessor & Computer Architecture Laboratory

WEEK Write an ALP to compare the value of R0 and R1, add if R0 = R1,
else subtract.
2

Algorithm
1.The first number is to be saved in R0
2.The second number is to be saved in R1
3.Compare the two numbers
4.If they are equal,branch to location L1
where both numbers are added.
5.Save the addition result in R2 and end
execution

6.If the numbers are not equal subtract the


two numbers.
7.Save subtraction result in R2 and end
execution.
(Two Screenshots-Choose your own
example to cover all two cases)
Microprocessor & Computer Architecture Laboratory

WEEK 4.Write an ALP using ARM instruction set to check if a number


2 stored in a register is even or odd.
Note: at the end of the program execution R2 contains 0 if number is
even, otherwise R2 contains 1.

Algorithm CASE 1 R0 0x06


1.The number is to be stored in R0
2. AND operation between the given R1 After 0x00
number and constant 1,result of AND AND
operation is stored in R1 operation
(Use instruction ANDS to ensure flags are
updated) R2 (EVEN) 0
4. If the LSB bit of R1 after the AND CASE 2 R0 0x05
operation is zero,it indicates even number
If true,Branch to label Location 1,copy 00
into R2 register R1 After 0x01
Else AND
5. If the LSB bit of R2 after the AND operation
operation is one,it indicates odd number
If true,Branch to label Location 2,copy 1 R2 (ODD) 1
Microprocessor & Computer Architecture Laboratory

WEEK Write an ALP to find the factorial of a number stored in R0. Store
the value in R1 (without using LDR and STR instructions).Use
2
only registers.
Algorithm
1.The number n is to be saved in R0
2.Let R1=1
3.Multiply contents of R0 and R1
Save the result in R1
4.Subtract the contents of R0 by 1 to
calculate n-1 1st Iteration R0=0x05
5.Check if the content of R0 is one R1=0x04
6.Repeat steps 3 to 5 till R0 reaches one R1=0X14=Decimal 20
9.End execution when R0=1 2nd Iteration R1=0x14
(One Screenshot-Choose your own R0=0X03
R1=0x3C=Decimal 60
example)
3rd Iteration R1=0x3C
R0=0X02
R1=0x78
4th Iteration R1=0x78
R0=0X01
R1=0x78 =Decimal 120
Microprocessor & Computer Architecture Laboratory

WEEK Write an ALP to find GCD of two numbers (without using LDR
and STR instructions).Both numbers are in registers. Use only
2
registers.

Algorithm
1.The first number is to be saved in R0
2.The second number is to be saved in R1
3. Compare both numbers in R0 and R1.
4.If they are equal, end execution
5.If R0 is greater than R1,R0= R0-R1
6.Repeat steps 3 to 6 till R0=R1, end
execution
7. If R0 is lesser than R1,R1= R1-R0
(Three Screenshots(A=B,A<B,A>B)
Choose your own example)
THANK YOU

Deepti C

Department of Computer Science and


Engineering
[email protected]

You might also like