Home CPSC 305

Uppercase Exercise

 

Objective

To get experience dealing with memory and function calls in ARM assembly.
 

Task

For this lab, you will write an ARM assembly function which will take a character string, and convert it to uppercase. This function will take the character string as its only argument.

It should modify the characters in place, so that after the function is done, the letter characters at that memory address have been changed to capital ones.

You should use the C standard library toupper function to achieve this. This function takes one argument — a character — and returns a character which is the upper case version of the one it was passed. If the character passed in was not a lower case letter, then toupper returns it unchanged. Call this just with bl toupper.

Your function should loop over all of the characters in the array, calling toupper on each of them, and storing them back. When you hit the 0 character, the function should return.

Because we are calling a function from ours, we will have to be very careful of the calling convention so that we can return back, and not overwrite any registers we are not allowed to!

  1. Start by downloading a GBA skeleton program with an empty uppercase function:
    wget https://ianfinlayson.net/class/cpsc305/labs/uppercase.tar.gz
    tar xvf uppercase.tar.gz
    cd uppercase
    
  2. Compile the program so that you can see you have everything set up correctly:
    gbacc uppercase.s main.c
    
  3. Run the program.gba program this creates. It should print a message saying "This should be upper case!". The existing uppercase function does nothing so that the message is not, in fact, upper case.
  4. Edit the uppercase function in uppercase.s to substitute the letters with uppercase ones.

When you are done, your program should produce the following output:


 

Submitting

When you are done, please submit the assembly code under the assignment in Canvas.

Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.