CS 216, Lab #4

Submit by Friday of the week assigned

according to the couse webpage.

x2go troubles?, such as tab key not working

Assignment - A MIPS program and a C program

Get the files, design your code, and type it in before the lab period.

  1. loop6.a
    ## Question:
    ## "numbers" is an array of five words.
    ## Calculate the sum of all elements in "numbers"
    ## whose value is less than 1000.
    ##

  2. minmax.c - A C program to find the minimum and maximum values of an array of integers. (The printf() statement is provided for you.) Remember to test this C program also in mipsmark.

    The file minmax.c is set up with data and

    int main ()
    {  /* declare variables here */
            int mymin, mymax;               /* use these */
    
    Above the ----- start cut ------
    and below the ----- end cut --- is
        printf ("The minumum = %d and the %s = %d\n", mymin,"maximum", mymax);
    
        return 0;    /* 0 tells operating system "Normal termination" */
    }   /* end main */
    
    It is important to use the defined SIZE, not 10, in your loop. since this will vary from case to case.

    What initial values should you choose for mymin and mymax?

    Should you need it, the largest 32-bit signed integer is 2147483647, defined in <stdint.h>, located at /usr/include/
    # define INT32_MAX              (2147483647)
    # define INT32_MIN              (-2147483647-1)
    
    You can also write 0x7fffffff and 0x80000000 for the largest and smallest integers, in C as well as in assembly.

To compile and run a C program

compile with gcc :
gcc minmax.c

there will be either syntax errors, or
The executable file a.out
Run it with the command ./a.out

After it works, you will be able to test it with mipsmark, and submit with submit cs216, just like for .a files.

A classic C tutorial

Instructions:

Follow the instructions for Lab 2.
Comments in both programs!
For both programs, You must test your code using mipsmark, and
be sure your name is included as a comment, and submit a copy of the file using submit cs216.

If you have trouble with mipsmark, check the validity of your calculations. 

cat mark.log          # will show you what happened
showcase loopc.a 2    #
will give you a file for case 2 (loopc_2.a) which you can use for testing, it will also have the correct answer for that case.
(C programs will give you minmax_1.a, rename to .c)

Then see common reasons mipsmark may fail.