CS 135: In-class Lab Exercise 2 Week 9

Now that you've written code to compute inner product of two vectors (arrays)  and code to determine the greater of two numbers, or absolute values of a number), write the LC-3 assembly code for finding the maximum of a list of positive numbers in memory. R0 contains the location in memory of the start of the list, and the end of the list of numbers is signified by a zero or negative number. The code should place the greatest of the values in the list into register R5. If the first number of the list is zero or negative, R5 should contain zero. (You can use the code you wrote during lab exercises in previous week, and  for the vector inner product during class.)

For example, if R0 contains the value x4000, and the memory contains the following values:

  x4000: 10
  x4001: 20
  x4002: 15
  x4003: -1

In this case, the code should put the value 20 in register R5. Hint: the example on pages 139-141 of the textbook may help you.