CPSC 371 SPARC ARCHITECTURE LAB 1 This lab asks you to use gcc as an assembler, and the gdb debugger to understand the structure of the SPARC risc architecture. 1. Use "gcc -S" to compile the following program into an assembly (.s) program. /* ------------------- */ #include void main() // 1 { // 2 int i, j, x, y; // 3 char c; // 4 // 5 for(i=0; i<10; i++) // 6 printf("Hello, I'm a C program!\n"); // 7 // 8 printf("input a integer, up to 4 digits: "); // 9 scanf("%4d",&x); // 10 // 11 i = &c; // 12 printf("\n I don't like types! %d",i); // 13 c = x + 32; // 14 printf("\n integers are chars, %c\n",c); // 15 if (c) printf(" and chars are booleans too!\n"); // 16 } /* ------------------- */ Look at the assembly code, and, using comments, associate each line of assembly with a line in the original c program. Comment as much as possible in addition. pay special attension to how the for loop and the if statements where translated. 2. Modify the program so that the for loop is executed after the scanf (in assembly! ) 3. (due next week) Write FROM SCRATCH, a SPARC assembly program that reads in a string and prints a. the string backwards b. if there is a non-alphabetical character in the string. BOTH parts should be implemented as functions (a function to reverse a string or return a new string, and a function that tests if all the characters in the string are alphabetical. Remember that strings end in a 0 byte. Use C library functions for IO (printf, getc, etc).