<< Assembly Unit Home

 ! 
 difficulty rating

Objectives
Write small leaf procedures (10-15 instructions) using solution template.

Valid HTML 4.01!

 ! 
 ! 
SPIM Exercise 2.1 15 Minutes
Run the strcpy() example in SPIM. Use this solution template to start. Step through the code and watch registers.

 ! 
 ! 
SPIM Exercise 2.2 15 Minutes
Modify strcpy() to work with Unicode (2-byte) strings. Assume that the string is terminated with the half-word 0.

 ! 
 ! 
SPIM Exercise 2.3 30-40 Minutes
Write the procedure int strlen(char s[]) which accepts an ASCII string s[] and returns its length. Load your procedure in SPIM to test it. Use this solution template. (Hint: write the C function first.)

 ! 
 ! 
SPIM Exercise 2.4 30 Minutes
Write the procedure char *toUpper(char s[]) which accepts an ASCII string s[] and changes it to uppercase. For example, if s[]="lower", then the procedure should make the string "LOWER". The procedure should return the same address passed as input. Load your procedure in SPIM to test it. Use this solution template [view]. (Hint: use andi with suitable mask to change to uppercase.)