Home CPSC 305

Uppercase Exercise


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


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 can use the 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.

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 cs.umw.edu/~finlayson/class/spring18/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:


When your program works, email the .s file to ifinlay@umw.edu.

Copyright © 2018 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.