Assigned: 23 September 2004

Due: 5 October 2004

Write a function “num2str” that converts a 32 bit integer into a null-terminated ascii string of characters.

void num2str(int num, char str[]);

Inside your function you may assume that there is sufficient space allocated in the output argument string to store all the characters of num.

Then write the main program, which calls the num2str function and displays the generated string in the console window. You may use syscall 4 to display the string, as described in the textbook pages A-48 to A-49. You’ll want to make sure that the pointer you pass to your function points to a sufficiently large area to contain the resulting string. 9 or 10 bytes should be plenty.

Your program must run in SPIM without error.

This assignment is the second part of a three-assignment series.

23 September 2004