FindMax Assembly Commenting

Overview

In this lab you'll analyze and comment FindMax.s, which is the assembly translation of FindMax.c.

Steps

  1. Read through FindMax.c, to be sure you understand how it works. In particular, be sure you understand how arrays are passed in C. The address of the starting point in the array is passed, and used as the basis for indexing into the array within the function.

  2. Go through FindMax.s, and get a general feel for how it relates to the C file. Look up any opcodes you see that haven't been covered in lecture yet.

  3. Comment FindMax.s to show how it corresponds with the C file. In particular:

    1. After every opcode place a comment briefly indicating what it does, e.g. "load max into r1"
    2. Add a single-line comment that is a copy of one of the C statements or expression, immediately before the assembly instructions that implementhat statement. Be sure every C statement appears somewhere in the commented FindMax.s file.
  4. Get an OK from me or an LA, and then submit your commented file.

Hints and Notes

  1. You may find that one or more stack frames have unused space in them. This is just a compiler inefficiency.
  2. Remember that a parameter int vals[] actually means that the address of the first element of the array is being passed.