Assignment Three: Color Typer Solution




Write an assembly program that will turn on and off the red, green and blue elements of the onboard RGB LED when the corresponding letter is typed on the computer’s keyboard. It will also display to the name of the color, one of the following:

1. **OFF**

1. **RED**

1. **GREEN**

1. **BLUE**


1. **CYAN (GREEN & BLUE)**

1. **PURPLE (RED & BLUE)**



Try to use a switch statement-like setup for checking to see which key on the keyboard was pressed (repeated comparisons). The function `cio_getc()` can be used **to wait** for a single character input, when this function returns the character that was typed will be in `r15`.

For printing the name of the color, enter the color names into the `.rodata` section (read-only data) and construct an array of those addresses. Find the equivalence between the value in `P2OUT` and what color is displayed. Relate this back to the array to **calculate mathematically** which name should be printed to the screen. Use the function `cio_print()` which takes a single argument: the address of the array of characters to print.

[`libemb` Library Documentation](


1. Remember that `P1DIR` is _the direction register_, it dictates if a pin on the microcontroller is an **input** or an **output**.

1. `P1OUT` is _the output register_, it dictates if a pin on the microcontroller is an **turned on** or a **turned off** (when it is _also_ set as an **output**).

1. `minicom` needs both a newline _and_ carriage return characters.

1. Memory addresses on the MSP430 are **2 bytes** (16-bits) in length. If an array is an array of memory addresses (also known as pointers), then _each entry is two bytes ahead of the previous one_.


When you have an issue or you are getting unexpected results, _reach for the debugger_. This is your best view into how the CPU is operating at any given moment. Confirm the contents of registers or the arguments of function calls. There are many resources available on different `gdb` commands, but I’ve [tried to collect important ones here](