Subroutine Calls
Objective of this lab:
To explore ARM subroutine calls and implement them in Keil uVision5
Preparation
Read lab lecture notes.
Lab Assignment
Program#1:
Write an ARM assembly language program CountVowelsTwo.s
to count how many vowels and how many non-vowels are in the following string.
"ARM assembly language is important to learn!",0
You are required to implement this by using a subroutine to
check if a character is vowel or not, and count the vowels and non-vowels in the calling function.
Recommendations for writing the program:
- Put the string in the memory by using DCB.
- Use R0 to hold the address of a character in the string.
- Use R2 to be the counter for vowels.
- Use R3 to be the counter for non-vowels.
- Build the program, debug until there is no error.
- Make a screenshot to show that the build is successful with no errors.
- Run the program step by step and see how values are changing in
the registers.
OR just run the program and see the final results in the register R2 and R3.
- Make a screenshot to capture the results in your designated registers.
You will hand in the following:
- The source code in the file CountVowelsTwo.s
- All the required components in the file CountVowelsTwo.pdf
- The source code in the file CountVowelsTwo.s
- The screenshot (print screen) to show the program has been successfully built
- The screenshot showing the number of vowels in R2 and non-vowels in R3.
Program#2:
Write an ARM assembly language program that will have a user defined
function/procedure factorial
to calculate the factorial for a given number.
For example:
The factorial of 5 is 5! = 5 x 4 x 3 x 2 x 1
The factorial of 0 is defined as 0! = 1
In general, n! = n x (n-1)!, where n is a positive integer.
If we write f(n) = n!, then f(n) = n f(n-1).
It is a recursive function.
Please implement it by using stack.
When you test it, you can use relatively smaller numbers such as 3, 4, 5, or 6.
For marking purpose, put the input number in the R1 and
put your final result in the register R0 or
indicate it specifically in your hand-in assignment.
You will hand in the following:
- The source code in the file Factorial.s
- All the required components in the file Factorial.pdf
- The source code in the file Factorial.s
- The screenshot (print screen) to show the program has been successfully built
- The screenshot showing the input number in R1 and the result in R0
Copyright: Department of Computer Science, University of Regina.